"""Render an HTML file to PNG (for checking) or PDF (for the kit) with Playwright's Chromium, or Google Chrome if Playwright has no browser of its own.""" import sys, asyncio from playwright.async_api import async_playwright async def go(src, out, width=1260, 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}) 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= '