quarto-dev / quarto-cli

Open-source scientific and technical publishing system built on Pandoc.
https://quarto.org
Other
3.98k stars 328 forks source link

Convert PDF images to SVG for Typst format (as done for PDF/LaTeX) #8185

Open mcanouil opened 10 months ago

mcanouil commented 10 months ago

Discussed in https://github.com/quarto-dev/quarto-cli/discussions/8180

Originally posted by **psads-git** January 9, 2024 ### Description Consider the code: ``` --- title: Page Layout format: typst: papersize: a4 margin: x: 1cm y: 1cm # columns: 2 --- # Introduction ![My image](excel01.pdf){width=80%} ``` When compiling, I get the error: ``` [typst]: Compiling Untitled-1.typ to Untitled-1.pdf...error: unknown image format ┌─ Untitled-1.typ:251:16 │ 251 │ #box(width: 80%,image("excel01.pdf")) │ ^^^^^^^^^^^^^^^^^^^^ ``` I am aware that `typst` does not accept PDF images. My question is: Is there another way to insert `PDF` images with `quarto` than manually convert them to, say, `SVG`? Thanks!
cderv commented 10 months ago

Adding some context:

We do convert SVG to PDF image when rsvg-convert is present for format: pdf. Though we do that because Pandoc does it and we needed compatibility with the feature.

https://github.com/quarto-dev/quarto-cli/blob/e6dd9d52051015adb82daad927524cf9373d3a1a/src/resources/filters/quarto-post/pdf-images.lua#L4-L21

We could think of something similar to do the work internally if for example pdf2svg utility is present. Though we don't want to handle every cases.