mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2025-12-18 20:04:17 +01:00
# Description of Changes ## What was changed - Introduced a shared `PDFJS_DEFAULT_OPTIONS` object and applied it across frontend modules using PDF.js: - Sets `cMapUrl`, `cMapPacked`, and `standardFontDataUrl` so PDF.js can correctly load CMaps and standard fonts. - Switches all `GlobalWorkerOptions.workerSrc` usages to the dynamic `pdfjsPath + 'pdf.worker.mjs'`. - Exposed `pdfjsPath` globally in `navbar.html` to support deployments under subpaths/reverse proxies. - Updated multiple pages and utilities to use the new defaults: - `DecryptFiles.js`, `downloader.js`, `merge.js`, Multi-Tool (`PdfContainer.js`), and feature pages (`add-image.js`, `adjust-contrast.js`, `change-metadata.js`, `crop.js`, `pdf-to-csv.js`, `sign.js`, `rotate-pdf.html`, `convert/pdf-to-pdfa.html`, `merge-pdfs.html`). - Comparison tool hardening: - Added robust worker protocol (`type: 'COMPARE' | 'SET_*'`) and safer logs. - Improved text tokenization, adaptive batch diffing with overlap de-duplication, and color fallbacks. - Early validation for empty/oversized/invalid PDFs with clearer user messages. - Disabled PDF.js worker in specific templates where legacy CMap handling caused issues (`disableWorker: true`) to prevent rendering failures. - UI/UX tweaks: processing state on the compare button, progress hints during text extraction, and more resilient error handling. - Fixed relative path to popularity data (`./files/popularity.txt`) to respect base paths. ## Why the change was made - PDFs using CID fonts (e.g., CJK and other complex scripts) were rendering with missing glyphs or falling back incorrectly because CMaps and standard font data were not being provided to PDF.js. Providing proper CMap and font resources resolves CID character visibility issues and related console warnings. - Some environments (subpath deployments, reverse proxies) broke PDF.js worker/static asset resolution; centralizing `pdfjsPath` and using it consistently fixes this. - The comparison feature struggled with large/complex documents and lacked robust validation; improvements reduce timeouts, improve accuracy, and provide clearer feedback. Closes #4391 --- ## Checklist ### General - [x] I have read the [Contribution Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md) - [x] I have read the [Stirling-PDF Developer Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md) (if applicable) - [ ] I have read the [How to add new languages to Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md) (if applicable) - [x] I have performed a self-review of my own code - [x] My changes generate no new warnings ### Documentation - [ ] I have updated relevant docs on [Stirling-PDF's doc repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/) (if functionality has heavily changed) - [ ] I have read the section [Add New Translation Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md#add-new-translation-tags) (for new translation tags only) ### UI Changes (if applicable) - [ ] Screenshots or videos demonstrating the UI changes are attached (e.g., as comments or direct attachments in the PR) ### Testing (if applicable) - [ ] I have tested my changes locally. Refer to the [Testing Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md#6-testing) for more details. |
||
|---|---|---|
| .. | ||
| common | ||
| core | ||
| proprietary | ||
| allowed-licenses.json | ||