-
DescriptionI want to ship a pdf for my presentation, which is otherwise in revealjs. Of course, I can try to use the But I notice that revealjs has a "pdf export" mode which works pretty well from a browser. Is there a way that I can automate that output to genrate that view and then "print" it to a pdf direclty, emulating what a user would do if they did that? |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 5 replies
-
You can use anything that can interact with a browser, such as https://github.com/rstudio/webshot2 in R, etc. For reference: https://quarto.org/docs/presentations/revealjs/presenting.html#print-to-pdf. |
Beta Was this translation helpful? Give feedback.
-
Thanks. SO there is no simple workflow to generate an HTML file then open in with some CLI tool on the print to pdf and print it out? Might be a nice output type for quarto if there isn't? I use python but am happy to install any pip packages/etc. |
Beta Was this translation helpful? Give feedback.
-
Update: The The But it is pretty good. I would suggest you consider a new output type Wanted to reiterate what an amazing product quarto is. It already has so many quality features, but I can now understand why you are doubling down on revealjs. |
Beta Was this translation helpful? Give feedback.
-
Thanks. I think the main benefit from having it builtin to a future quarto release for other people would be the installation integration. It was a pain (and having an extension wouldn't help with that issue). |
Beta Was this translation helpful? Give feedback.
-
I have run into this issue when creating PDF version of slides for a class so that my students can follow along and mark up on their iPads. I could not get Decktape working, so I put together a simple solution using Playwright. I have a Python script that launches a headless Chromium browser, opens the Reveal JS presentation in print mode, and then prints to PDF. It seems to work for my class slides and saves me the hassle of doing it manually with Chrome. import os
import argparse
from playwright.sync_api import sync_playwright
parser = argparse.ArgumentParser(description = "Generate PDF slides from Reveal.js HTML")
parser.add_argument("input", help = "HTML filename", type = os.path.abspath)
parser.add_argument("output", help = "PDF filename", type = os.path.abspath)
args = parser.parse_args()
with sync_playwright() as p:
browser = p.chromium.launch()
page = browser.new_page()
url = "file://" + args.input
page.goto(url + "?print-pdf", wait_until = "networkidle")
page.locator(".reveal.ready").wait_for()
page.pdf(path = args.output, prefer_css_page_size = True) |
Beta Was this translation helpful? Give feedback.
It depends what you mean by "simple", Reveal.js also advertise dectape for this, see https://revealjs.com/pdf-export/.