Allow Changing of PDF Render Page Size?
rjbprime opened this issue · 5 comments
Hi @jsnee,
Is it possible to change the page size of the output PDF? I use A4 size paper, and I have added to my style.css the dimensions for it, but when I render the PDF, it outputs to Letter. Is it possible to allow the changing of output page size? Even a predefined list of page sizes would be appreciated.
Kind regards,
rjbprime
It should be possible to change the output size just by modifying the CSS. I checked that when I originally wrote this extension. But it is possible that some change along the way messed that up. I'll check it out and get back to you!
Further to this I've rendered two documents, one A4, one with default measurements. The default measurements one works, as to be expected. The A4 one renders with white space on the right-hand and bottom-side of the page, and adds a blank page afterwards and the bottom of the page on a separate page (edited due to using wrong code). Attached is both the resulting PDF and the file used to generate it. Had to rename A4.md to A4.txt, so that it would upload to github.
Perfect! Thank you for providing those, they help immensely! I do see what you're seeing and I'll work on the fix!
Fixed in version 0.5.7
I will add additional features in a future version that will allow you to set the paper size for an entire campaign, but for your benefit, I made a quick fix for you to be able to set it on a per document basis until then! Simply set the page size at the very beginning (make sure there are no empty lines or any other text before this block or it will be rendered instead of interpreted as PDF options) of the markdown file like so:
---
pageSize: A4
---
<style>
...
</style>
Lorem ipsum
...
Notes
- For your reference (or anybody else's) until I can update the documentation, you can find a list of
pageSize
options in the changelog here.- These are defined by the
Puppeteer
library, so apologies if there are any paper sizes not supported.
- These are defined by the
- This options block isn't required for any markdown files, just the ones where you want to set the PDF's page size
- If you omit this option (or the whole block from
---
to---
) from a markdown file, it simply defaults to the 'Letter' setting
- If you omit this option (or the whole block from
- This does not fix needing to include custom CSS styles (at least not yet)
- If I remember to, I'll come back and comment on this issue when I add the ability to simply specify this option and not need any additional CSS styles to render non US Letter sized documents