Files
bio-performx/playright.py
T
bolade 1ae1ec2369 Add requirements.txt, tailwind configuration, and initial truth report HTML
- Created requirements.txt with a comprehensive list of dependencies.
- Added tailwindconfig.js for Tailwind CSS configuration.
- Introduced truth_report.html with structured content and Tailwind CSS styling for a visually appealing layout.
2025-09-26 16:37:46 +01:00

24 lines
671 B
Python

from playwright.sync_api import sync_playwright
def html_to_pdf(html_path, pdf_path):
with sync_playwright() as p:
browser = p.chromium.launch()
page = browser.new_page()
# Load local HTML file
page.goto(f"file://{html_path}")
# Export to PDF with A4 size
page.pdf(
path=pdf_path,
format="A4", # <-- built-in A4 support
margin={"top": "20mm", "bottom": "20mm", "left": "15mm", "right": "15mm"},
print_background=True # include Tailwind background colors/images
)
browser.close()
# Example usage
html_to_pdf("table_of_contents.html", "report.pdf")