typst / svg2pdf

Converts SVG files to PDF.
Apache License 2.0
287 stars 34 forks source link

Multiple pages #15

Closed FrankenApps closed 2 years ago

FrankenApps commented 2 years ago

Sorry to ask a question here. Is it possible to split a SVG into multiple PDF pages? If not is support for this feature planned in the future?

reknih commented 2 years ago

This is currently neither supported nor planned.

How would you intend to use such a feature / what is your use case?

FrankenApps commented 2 years ago

Well, let's say that I have a SVG with a viewbox of 0 0 10 30 and then using the svg2pdf::Options I could specify a "pageSize" of 10x10, I would hope to get 3 pages. My use case is that I want to generate a nice looking PDF file for a Webservice that might need more than one page to display the information (e.g. I'd like the pages to be of A4 format and do not want to scale the content to maintain good visibility).

I could probably generate multiple PDFs and then merge them, but that would mean that I would need to handle the page break manually myself.

reknih commented 2 years ago

svg2pdf does not offer such an automated procedure. However, you can use it in combination with pdf-writer to generate such files manually:

The convert_tree_into function allows you to convert your SVG into a reusable PDF Form XObject. You can then use that on multiple pages without duplicating it in the file and just scale and move it appropriately, everything that the page cannot fit is cropped. This approach requires some familiarity with the PDF standard.