Read html file and make pdf with pyppeteer
import asyncio | |
from pyppeteer import launch | |
async def main(): | |
browser = await launch( | |
options={ | |
'headless': True, | |
'args': [ | |
'--no-sandbox', | |
'--disable-setuid-sandbox', | |
'--disable-dev-shm-usage', | |
'--disable-accelerated-2d-canvas', | |
'--no-first-run', | |
'--no-zygote', | |
'--single-process', | |
'--disable-gpu', | |
], | |
}, | |
) | |
page = await browser.newPage() | |
await page.goto('file:///root/sample.html') | |
await page.screenshot({'path': 'sample.png'}) | |
await page.pdf({'path': 'sample.pdf'}) | |
await browser.close() | |
asyncio.get_event_loop().run_until_complete(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment