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.
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
|
||||
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")
|
||||
Reference in New Issue
Block a user