Stirling-PDF/app
Ludy c760d1a93a
fix(frontend/pdfjs): ensure CID character rendering via CMaps & stabilize PDF compare/preview (#4762)
# 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.
2025-11-25 09:52:42 +00:00
..
common feat(docker-runtime): unified Debian-based images, dynamic path resolution & enhanced UNO/LibreOffice handling (#4880) 2025-11-24 23:07:54 +00:00
core fix(frontend/pdfjs): ensure CID character rendering via CMaps & stabilize PDF compare/preview (#4762) 2025-11-25 09:52:42 +00:00
proprietary build(deps): bump io.swagger.core.v3:swagger-core-jakarta from 2.2.40 to 2.2.41 (#4979) 2025-11-25 09:43:55 +00:00
allowed-licenses.json feat(cbr-to-pdf,pdf-to-cbr): add PDF to/from CBR conversion with ebook optimization option (#4581) 2025-10-04 11:15:23 +01:00