mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2026-09-03 05:10:16 +03:00
# Description of Changes This PR fixes PNG signature application issues in the PDF signing workflow. ## What was changed - Reworked signature application to create locked and printable PDFium stamp annotations with dedicated appearance streams. - Removed the use of `FPDFPage_GenerateContent()` from the signature workflow. - Preserved the signature's original position and dimensions when converting from the viewer's top-left coordinate system to PDF coordinates. - Added CropBox-aware coordinate conversion for PDFs whose visible page origin differs from the MediaBox origin. - Improved signature image extraction to handle internal EmbedPDF asset references and nested image data. - Refactored PDFium bitmap creation so image objects can safely be transferred to annotations. - Corrected PDFium bitmap ownership and cleanup to prevent duplicate destruction. - Added a PDFium WASM integration test covering: - Existing page-content preservation - Stamp appearance generation - Signature coordinates and dimensions - Printable, read-only, and locked annotation flags - Persisted image data taking precedence over internal asset references ## Why the change was made Applying a PNG signature previously regenerated the complete page content through PDFium. This could corrupt existing vector or font-based page elements, including the university logo reported in the linked issue. The previous coordinate conversion also relied only on the page height and did not account for CropBox offsets, allowing the applied signature to move from its preview position. Creating a PDFium stamp annotation with its own appearance stream avoids regenerating existing page content while retaining the selected signature position and size. Closes #7083 --- ## Checklist ### General - [ ] I have read the [Contribution Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md) - [ ] I have read the [Stirling-PDF Developer Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/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) - [ ] I have performed a self-review of my own code - [ ] 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) ### Translations (if applicable) - [ ] I ran [`scripts/counter_translation.py`](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/docs/counter_translation.md) ### 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 run `task check` to verify linters, typechecks, and tests pass - [ ] I have tested my changes locally. Refer to the [Testing Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/DeveloperGuide.md#7-testing) for more details.