OnlineFreeTools.org
  • Home
  • Tools
    Health & body →
    BMI Calculator — How to Calculate Body Mass IndexBMR & TDEE Calculator — How to Calculate Daily CaloriesBody Fat Calculator — How to Estimate Body Fat PercentageHeart Rate Zone CalculatorIdeal Weight Calculator — How to Estimate Ideal Body WeightMacro Calculator — Calories to Protein Carb Fat GramsOne-Rep Max Calculator (Epley)Pace Calculator — min/km and Speed
    Personal money →
    CAGR Calculator — How to Calculate Compound Annual Growth RateCompound Interest Calculator — How to Calculate Future ValueDebt Payoff Calculator — Months to Clear a BalanceDiscount Calculator — How to Calculate Sale PriceEMI Calculator — How to Calculate Loan PaymentsInflation Calculator — Future Purchasing PowerPercentage Change Calculator — From Old Value to NewPresent Value Calculator — PV and FV ModesRule of 72 Calculator — Years to DoubleSalary to Hourly Calculator — How to Convert Pay RatesTip Calculator — Tip Amount and SplitVAT / GST Calculator — Add or Extract Tax
    Business finance →
    Create a budget spreadsheetCreate an Excel timesheetCreate an invoice spreadsheetBreak-Even Calculator — How to Calculate Break-Even PointContribution Margin Calculator — Price Minus Variable CostGross Margin Calculator — How to Calculate Gross MarginIRR Calculator — Internal Rate of ReturnHow to Calculate Marginal Revenue — MR Calculator (ΔTR / ΔQ)Markup Calculator — How to Calculate Markup PercentageHow to Calculate NPV — Net Present Value CalculatorPayback Period Calculator — Years to Recover InvestmentProfit Margin Calculator — Net or Operating MarginROI Calculator — How to Calculate Return on Investment
    Math & stats →
    Confidence Interval Calculator — How to Calculate a CIExponent Calculator — How to Calculate PowersGPA Calculator — How to Calculate Weighted GPALogarithm Calculator — How to Calculate LogsMean Calculator — Average of a Number ListMedian and Mode CalculatorP-Value Calculator — How to Calculate a P-ValuePermutation and Combination CalculatorQuadratic Equation Solver — Roots and DiscriminantSample Size Calculator — How to Estimate Required nScientific Notation Calculator — How to Convert Scientific NotationSignificant Figures Calculator — How to Count and Round Sig FigsStandard Deviation Calculator — How to Calculate SD and VarianceZ-Score Calculator — How to Calculate a Standard Score
    Geometry & measure →
    Aspect Ratio Calculator — How to Calculate and Scale RatiosCircle Calculator — Area and CircumferenceGradient Calculator — Multivariable ∇f (Partial Derivatives)Pythagorean Theorem Calculator — How to Find a Missing SideSlope Calculator — How to Calculate Slope Between Two PointsTriangle Area CalculatorVolume Calculator — Box and SphereUnit Converter — Length / Mass / Temperature / Area / Volume / Speed
    Science & physics →
    Acceleration Calculator — Change in VelocityDensity Calculator — Mass over VolumeOhm’s Law Calculator — Resistance and PowerVelocity Calculator — Distance over TimeMeasuring Magnetic Fields — Field strength calculator
    Home & DIY →
    Concrete Calculator — How to Estimate Concrete VolumePaint Calculator — How to Estimate Paint NeededTile Calculator — How to Estimate Tile QuantitySquare Feet to Square Meters — Area Converter for Homes & Renovation
    Time & calendar →
    Age Calculator — Chronological Age from BirthdateDate Difference Calculator — Days and WeeksTime Zone Converter — Compare One Moment WorldwideUnix Timestamp Converter — Epoch ↔ Readable Time
    PDF & docs →
    Add a visible integrity mark to a PDFAdd text to a PDF fileBatch compress PDFs for emailInspect PDF/A indicatorsCombine files into one PDFCompare two PDFsReduce PDF file sizeConvert HTML to PDFExport PDF text to DXF for AutoCADConvert PDF to PDF/AConvert Word document to PDFCreate a PDF formCrop PDF — Trim Page Margins in Your BrowserEdit PDF form fieldsEdit PDF text onlineExtract text from a PDFFill out a PDF formMake a PDF fillableMake a PDF flipbookCombine PDF files into oneOpen a PDF in the browserOrganize PDF — Reorder or Remove Pages in Your BrowserAdd Page Numbers to PDF — In Your BrowserPDF Page to Image Sizes — Multi-Size Export PackConvert PDF pages to JPGPDF to Markdown — Extract Text for Notes in Your BrowserPDF Watermark — Stamp Text on Every Page in Your BrowserPrint a PDFPassword-protect a PDFRotate PDF — Fix Page Orientation in Your BrowserSign a PDF documentSplit my PDFTurn PDF into an editable text documentTurn PDF into Word documentUnlock my PDFWrite a PDF document online
    Image & media →
    Add Text Watermark to Photo — Local Browser ToolAmazon main image sizeApple-touch-icon 180×180Batch watermark product photosBulk compress PNG imagesBulk compress product photos (JPEG, PNG, WebP)Bulk convert images to JPGBulk convert images to PNGBulk convert images to WebPExtract Colors from Image — Palette & Click PickFlip Image — Mirror Horizontally or VerticallyAdd Border to Image — Color & Width OnlineImage Compressor — Shrink photos on your deviceCrop & Resize Image — Local Aspect PresetsPhoto EXIF Viewer & Remover — GPS, Camera & Local StripImage Format Converter — PNG JPEG WebP AVIF BMP GIF ICO SVGConvert Image to Grayscale — Black & White OnlineMerge Images — Combine Photos into One CollageImage Optimizer — Smaller files with on-device encodersOverlay Images — Put a Logo on a PhotoImage to Base64 Converter — Encode & Decode LocallyImages to GIF — Make an Animated GIF LocallyTurn JPG into PDFImages to PowerPoint — Photos to PPTX SlidesImages to Word — Build a DOCX from PhotosInstagram post sizeInstagram story sizeiOS app icon sizeiPhone 6.9 screenshot sizeLinkedIn banner sizeOpen Graph image sizeSVG optimizerYouTube thumbnail size
    Design & brand →
    Generate Brand Color Scale — 50–950 Palette & CSS TokensBrand Style Guide — Generate a Modular Draft You Can EditSmart Website Color Scheme — Semantic CSS TokensWCAG Contrast Checker — AA/AAA Ratio Online
    SEO & growth →
    Check if a URL is blocked by robots.txtCheck SSL certificate expirationtool_cwv_titleFind and validate XML sitemaptool_hreflang_titleIndexNow — Submit URLs to Bing without waiting for crawltool_serp_titletool_meta_titletool_onpage_titletool_og_titletool_robots_titletool_schema_titletool_sitemap_titleSPF DKIM DMARC checkertool_utm_titleValidate security.txt
    Network & IP →
    Add WWW to DNS — Point www at your apex domainAWS VPC CIDR planner — Split a VPC into AZ subnetsCIDR cheat sheet — Click a prefix to see mask and hostsCIDR to IP range — Expand a prefix into usable addressesDomain Lookup — Check DNS Records & Registration OnlineWhat Is My IP Address — See Your Public IP (IPv4 or IPv6)IP range to CIDR — Turn start–end addresses into prefix listsIPv6 CIDR calculator — Expand a prefix into its address rangePrivate CIDR ranges — Check if an IP or prefix is private or special-useTerraform cidrsubnet — Get the child CIDR Terraform would returntool_headers_title
    Dev & data →
    Base64 Encode & Decode — Convert Text in Your BrowserChatGPT export to MarkdownCSV ↔ JSON Converter — Convert tables in your browsercurl to fetchCopy common Excel formulasHTML Entity Encoder & Decoder — Escape, Unescape & LocalJSON Schema Validator — See path errors on your deviceJWT Decoder — Read Header & Payload Locally (No Verify)tool_markdown_titleWrap a formula with IFNAWrite a COUNTIF formula in ExcelWrite an IFS formula in ExcelWrite a nested IF formula for ExcelYAML ↔ JSON Converter — Convert configs in your browser
    AI prompt tools →
    Android prompt builder — Local + Optional AIFilm prompt builder — Local + Optional AIiOS prompt builder — Local + Optional AIMidjourney prompt builder — Local + Optional AIProduct design prompt builder — Local + Optional AIPrompt template builder — Local + Optional AIShort drama prompt generator — Local + Optional AISketch.app prompt generator — Local + Optional AIWriting prompt generator — Local + Optional AI
    Text compare →
    Compare two text files onlineCompare two Word documents for differencesExcel compare filesJSON diff checker onlineCheck difference between two texts
    Security & IDs →
    Batch checksum release filesFile Hash Checker — Verify Digests in Your BrowserFile metadata analyzerRandom Password Generator — Create Passwords LocallyUUID & ULID Generator — Create IDs in Your Browser
    Files & archives →
    Archive Extractor Online — Open Compressed Files in Your BrowserCreate zip fileMagnet Link Decoder — Parse Info Hash and Trackers LocallyUnzip File Online — Extract ZIP Files in Your Browser
  • Tool topics
  • Tool types
  • Dev Logs
☕ Buy me a coffee

Navigation

Home

Fixed three remaining Chinese PDF sample crashes: unlock now decrypts with Cantoo pdf-lib, stamps fall back from CJK Helvetica, Word sample PDF uses WinAnsi-safe text. | Dev Logs

Back to Logs

Date: 2026-09-06 10:06 Summary: Fixed three remaining Chinese PDF sample crashes: unlock now decrypts with Cantoo pdf-lib, stamps fall back from CJK Helvetica, Word sample PDF uses WinAnsi-safe text. Visibility: people

[question] 继续

Tool links (English)

  • https://onlinefreetools.org/tools/add-digital-signature-to-pdf
  • https://onlinefreetools.org/tools/protect-pdf
  • https://onlinefreetools.org/tools/turn-pdf-into-word-document
  • https://onlinefreetools.org/tools/unlock-pdf Chinese: https://onlinefreetools.org/zh/tools/unlock-pdf

[try to solve]

Context

After the html2pdf.js / jsPDF wiring fix, three other Chinese PDF tools still failed on page-entry samples (2026-09-06 auto-QA): unlock-pdf, add-digital-signature-to-pdf, and turn-pdf-into-word-document. None of them used html2pdf. The user asked to continue those remaining failures.

Process

  1. Read the three page implementations and the zh i18n shards. Auto-QA showed generic convert/unlock errors with no pageerror, so the exceptions were caught and mapped to fallback copy.
  2. unlock-pdf. The sample calls doc.encrypt({ userPassword: 'sample' }) then PDFDocument.load(bytes, { password }). The script loaded pdf-lib-with-encrypt, whose encrypt() writes a password on save but cannot decrypt. Official pdf-lib@1.17.1 documents the same gap (EncryptedPDFError; ignoreEncryption: true does not produce a usable unlocked file). password on load() was ignored, so the sample always hit err_unlock.
  3. Switched unlock (and protect-pdf, so this site’s encrypt/decrypt pair share one engine) to @cantoo/pdf-lib@2.9.1 UMD (window.PDFLib). Cantoo supports load({ password }) and encrypt() (AES-256 by default). Probe now uses ignoreEncryption: true + doc.isEncrypted; unlock uses load({ password }) then save().
  4. add-digital-signature-to-pdf. The stamp draws msg.marked with Helvetica. zh copy is「已数字标记」. pdf-lib’s WinAnsi encoder throws on any code point > 255. Same for ja / ru / ar. SHA-256 and the ISO timestamp were already ASCII. Added winAnsiOrFallback(text, 'Digitally marked') before drawText.
  5. turn-pdf-into-word-document. loadSample drew msg.sampleText (zh:「来自 PDF 的 Word 示例句。」) with Helvetica — same WinAnsi throw, so conversion never started. Sample PDF text now falls back to Hello Word sample from PDF.; user-uploaded PDFs still extract CJK via pdf.js (not Helvetica).
  6. Bumped PAGES_CACHE_VERSION 4.15 → 4.16, prerendered the four slugs, gzipped, uploaded local R2, restarted wrangler on 8788.
  7. Playwright (headless Chrome, ~10s after domcontentloaded) on /zh/tools/{slug}: no danger text, download enabled, no pageerror.

Root cause / analysis

Two unrelated bugs, both masked as「处理失败 / 解锁失败」:

Tool Real failure
unlock Library can encrypt but not decrypt a user password
digital mark / PDF→Word sample Standard 14 fonts cannot encode CJK (and other non-Latin-1) UI strings

pdf.js was already loading; the Word and stamp pages did not need a new renderer. protect-pdf was not in the fail list, but leaving it on pdf-lib-with-encrypt would mean files from「保护 PDF」could not be opened on「解锁 PDF」.

Solution

  • Unlock/protect: @cantoo/pdf-lib@2.9.1 (https://cdn.jsdelivr.net/npm/@cantoo/pdf-lib@2.9.1/dist/pdf-lib.min.js).
  • Stamp / Word sample: skip Helvetica for non-Latin-1 strings; stamp label becomes Digitally marked when needed; Word sample PDF uses an English demo sentence.

Local checks (2026-09-06):

  • /zh/tools/unlock-pdf — status「样例已就绪 — 密码为「sample」」, download on
  • /zh/tools/add-digital-signature-to-pdf — status「完成」, SHA-256 shown, download on
  • /zh/tools/turn-pdf-into-word-document — extracted Hello Word sample from PDF. + Load sample on entry, download on
  • /zh/tools/protect-pdf — sample still produces protected.pdf

Notes / boundaries

  • Real Adobe/Acrobat encrypted files should now decrypt when the open password is known; this is not cracking. AES-256 from Cantoo protect-pdf is the in-house round trip. Exotic or broken encryptors can still fail with a readable error.
  • The visible stamp on CJK locales is English on the PDF page; the on-page hash label stays localized. Embedding a CJK font would restore localized stamp glyphs at a large download cost.
  • zh Example copy for PDF→Word still describes a Chinese sample sentence; the generated sample PDF is ASCII until that copy is revised.
  • Production needs upload:r2 + git push (PAGES_CACHE_VERSION 4.16).

[actions]

  • src/pages/unlockPdfPage.ts: Cantoo pdf-lib; probe isEncrypted; load({ password })
  • src/pages/protectPdfPage.ts: same Cantoo UMD so encrypt/decrypt match
  • src/pages/addDigitalSignatureToPdfPage.ts: WinAnsi fallback for stamp title
  • src/pages/turnPdfIntoWordDocumentPage.ts: WinAnsi fallback for sample PDF text
  • wrangler.jsonc: PAGES_CACHE_VERSION 4.15 → 4.16
OnlineFreeTools.org · Learning project · Iterating
About·Privacy·Terms·Contact·GitHub