-
-
Notifications
You must be signed in to change notification settings - Fork 11
Fix: Print to PDF #53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes issue #52 by encoding HTML content to base64 before generating PDFs, which prevents issues with special characters and URL encoding in data URLs.
- Encodes HTML to base64 in the PHP backend before sending to the Electron print service
- Updates the data URL format to indicate base64 encoding in the Electron plugin
Reviewed Changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/System.php | Adds base64 encoding to HTML content before sending to print-to-pdf endpoint |
| resources/electron/electron-plugin/src/server/api/system.ts | Updates data URL format to handle base64-encoded HTML |
| resources/electron/electron-plugin/dist/server/api/system.js | Compiled version of the TypeScript changes |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| }); | ||
|
|
||
| await printWindow.loadURL(`data:text/html;charset=UTF-8,${html}`); | ||
| await printWindow.loadURL(`data:text/html;base64;charset=UTF-8,${html}`); |
Copilot
AI
Nov 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The data URL format syntax is incorrect. According to RFC 2397, the correct format for a base64-encoded data URL should be data:text/html;charset=UTF-8;base64,${html} (with base64 as the last parameter before the comma). The current order will cause the browser to not properly decode the base64 content.
| await printWindow.loadURL(`data:text/html;base64;charset=UTF-8,${html}`); | |
| await printWindow.loadURL(`data:text/html;charset=UTF-8;base64,${html}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't believe the parameter order matters
gwleuverink
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great! Thanks for your contribution 🚀
Fixes issue #52