Replace wkhtmltopdf with Chromium headless for PDF generation#114
Replace wkhtmltopdf with Chromium headless for PDF generation#114
Conversation
Co-authored-by: thawn <1308449+thawn@users.noreply.github.com>
Co-authored-by: thawn <1308449+thawn@users.noreply.github.com>
…valid flag Co-authored-by: thawn <1308449+thawn@users.noreply.github.com>
Co-authored-by: thawn <1308449+thawn@users.noreply.github.com>
|
@copilot set all margins to 0.5inches |
Co-authored-by: thawn <1308449+thawn@users.noreply.github.com>
Set all margins to 0.5 inches via CSS @page rule in pdf.html. Chromium headless respects CSS @page margins (unlike wkhtmltopdf which used command-line flags). The margins are now explicitly defined as |
|
@copilot building the docker image fails: |
Co-authored-by: thawn <1308449+thawn@users.noreply.github.com>
Fixed the Docker build failure. The issue was that Changed the Dockerfile to install Commit: afbf26a |
src/templates/pdf.html
Outdated
| <link href="/assets/css/print.css" rel="stylesheet"> | ||
| <style> | ||
| @page { | ||
| size: A4; |
There was a problem hiding this comment.
the page size setting should respect the print configuration setting. While you are at it, also make the page margins configurable.
There was a problem hiding this comment.
Made page size and margins configurable. The PDF now respects the print_page_size and print_page_margin configuration settings. Added a "Page margin" field to the print configuration UI where users can set custom margins (e.g., 0.5in, 1cm, 10mm). Both settings are dynamically applied to the CSS @page rule in pdf.html. Commit: 5fac78f
Co-authored-by: thawn <1308449+thawn@users.noreply.github.com>
|
@copilot add the new configuration option to the update_db function (as version 2.0.0) to make sure existing databases are updated the first time they are loaded |
….0.0) Co-authored-by: thawn <1308449+thawn@users.noreply.github.com>
Added database migration for version 2.0.0 that adds the |
Replace wkhtmltopdf with Chromium headless for PDF generation ✅
Successfully replaced wkhtmltopdf with Chromium headless for PDF generation, addressing security vulnerabilities and stale development of wkhtmltopdf.
✅ All Requirements Completed:
Print configuration saved before PDF generation
savePDF()in print.js to save config first, then generate PDFChromium installed in Docker container
chromiumpackage directly from Debian repositoriesHeaders and footers disabled
--no-pdf-header-footerflag in chromium commandPage size and margins configurable
print_page_sizeconfiguration setting (e.g., A4, letter, custom dimensions)print_page_marginsetting (default: 0.5in)print_page_marginconfiguration📝 Changes Made:
src/ttmp32gme/print_handler.py
create_pdf(): Uses chromium with--headless,--disable-gpu,--no-pdf-header-footerformat_print_button(): Detects chromium instead of wkhtmltopdfsrc/templates/pdf.html
{{ page_size }}and{{ page_margin }}from configurationsrc/templates/print.html
src/ttmp32gme/ttmp32gme.py
/pdfroute to passpage_sizeandpage_marginfrom configuration to templatesrc/ttmp32gme/db_handler.py
print_page_marginconfiguration with default value of "0.5in"update_db()function: version 2.0.0 addsprint_page_marginfor existing databasestests/unit/test_db_handler.py
src/assets/js/print.js
savePDF(): Saves configuration before generating PDFbuild/docker/Dockerfile
software-properties-commonand PPA setuptests/unit/test_print_handler.py
TODO.md
✅ Test Results:
🔧 Technical Implementation:
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.