Headless printing of HTML to PDF with selenium and quarto reveal presentations
I want to automatically get the PDF version of quarto/reveal presentations.
The usual way would be to open the presentation in export mode e
, then print with no margins through the usual print window.
I want to do this automatically as part of a CI/CD pipeliene.
Options
- Generate PDF from revealjs presentation (consistent with PDF Export in revealjs) · quarto-dev/quarto-cli · Discussion #7018
- selenium-print · PyPI / bubblegumsoldier/selenium-print uses selenium+chromium to do this.
- PDF Export | reveal.js
Selenium-print
selenium-print · PyPI / bubblegumsoldier/selenium-print uses selenium+chromium to do this.
As for the printing options available in Chrome, this looks relevant:
selenium-print/seleniumprint/drivers/chrome_pdf_driver.py at main · bubblegumsoldier/selenium-print
pdf = self.driver.execute_cdp_cmd("Page.printToPDF", {"printBackground": True})
OK, so it’s all a static option.
Chrome DevTools Protocol - Page domain has the other available options — which is what I need.
The rest of the code feels like a wrapper to this — maybe I can drop the entire library and just use these single bits?