Read html file and make pdf with pyppeteer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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