mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-06-21 23:15:03 +00:00

# Description of Changes This pull request introduces enhancements and code cleanup to the `EmlToPdf` utility class, focusing on improving email-to-PDF conversion, handling embedded images, and simplifying the codebase. Key changes include better handling of inline images, enhanced Jakarta Mail dependency checks, and refactoring for improved readability and maintainability. ### Enhancements to Email-to-PDF Conversion: * Added support for processing inline images (`cid:` references) by converting them into data URIs for proper inline display. * Improved attachment handling to always include embedded images regardless of size, ensuring inline display functionality. * Enhanced email HTML generation to process inline images and include them in the email body. ### Attachment Handling Enhancements: * Replaced the attachment icon placeholder (`icon` or 📎 emoji) with a new marker (`@`) for consistency across the application (non-fat images did not support the emoji, however @ is supported accross the board.) * Updated the annotation logic to use `AttachmentMarkerPositionFinder` instead of `EmojiPositionFinder`, aligning with the new attachment marker system. ### Jakarta Mail Dependency Handling: * Added detailed checks for core Jakarta Mail classes to determine availability in different environments (e.g., Docker). * Introduced validation for Jakarta Mail multipart and part types to prevent processing invalid objects. * Explicitly parse in the classes: - jakarta.mail.internet.MimeMessage – Core email message parsing - jakarta.mail.Session – Email session management - jakarta.mail.internet.MimeUtility – MIME encoding/decoding utilities - jakarta.mail.internet.MimePart – Individual MIME parts (attachments, body parts) - jakarta.mail.internet.MimeMultipart – Multi-part MIME messages - jakarta.mail.Multipart – Base multipart interface - jakarta.mail.Part – Base part interface ### Code Cleanup and Refactoring: * Simplified utility classes (`StyleConstants`, `MimeConstants`, `FileSizeConstants`) by removing unnecessary constructors and unused constants. * Updated log messages for clarity, such as distinguishing between general content processing errors and multipart-specific issues. --- ## 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/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/HowToAddNewLanguage.md) (if applicable) - [x] 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/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) - [x] I have tested my changes locally. Refer to the [Testing Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/DeveloperGuide.md#6-testing) for more details.