embedpdf 1.2.9: embed PDFs in Quarto HTML pages and slides that also work on phones #15196
jmgirard
started this conversation in
Show and Tell
Replies: 1 comment 1 reply
|
Related and similar extension: |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Putting a PDF in a Quarto HTML page comes up often in this forum: slides in a course site, a CV, a paper's supplement, a figure saved as PDF. Pandoc's
works well on desktop browsers. On phones it does not. Chrome on Android shows a blank box or a download prompt, and users report that older iOS versions show only the first page.embedpdf is a shortcode extension that handles this:
{{< pdf slides.pdf width=100% height=600 >}}What it does:
.embed-resources: true. The PDF goes inside the HTML file. It shows in desktop Safari too, which does not show a PDF inlined as adata:address (Embed PDF with embed-resources: true — fails to display in Safari on Mac #11953).page=3opens the PDF at page 3, also in desktop Safari where it can.\includepdf(pdfpages). In other formats (docx, typst, epub, ...), it writes a download link.Other options:
renderer=auto|native|pdfjs,border,toolbar=false,class, andbutton="Download PDF". You can set defaults for a document or a project under theembedpdfmetadata key.Limits: the PDF.js viewer has no text search or selection. A PDF from another site needs that site to send an
Access-Control-Allow-Originheader before PDF.js can read it. Without it, the embed shows a link that opens the PDF.Guide and live examples (try them on a phone): https://jmgirard.github.io/embedpdf/example.html
Related threads: #10313, #11953, #7918, #5863, #10177, #13189, and #12001.
Bug reports and requests are welcome at https://github.com/jmgirard/embedpdf/issues.
All reactions