"""Render an HTML file to PNG (for checking) or PDF (for the kit) with the pre-installed Chromium.""" import sys, asyncio from playwright.async_api import async_playwright async def go(src, out, width=1260, scale=1, footer=None): async with async_playwright() as p: try: b = await p.chromium.launch() except Exception: b = await p.chromium.launch(channel='chrome') # no Playwright browser installed: use Google Chrome pg = await b.new_page(viewport={'width': width, 'height': 800}, device_scale_factor=scale) await pg.goto('file://' + src); await pg.evaluate('document.fonts.ready'); await pg.wait_for_timeout(300) if out.endswith('.pdf'): kw = dict(display_header_footer=True, header_template='', footer_template= '