serhii.net

In the middle of the desert you can say anything you want

28 Oct 2024

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

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?

Decttape (?)

Nel mezzo del deserto posso dire tutto quello che voglio.
comments powered by Disqus