Inconsistent image size between pdf and screenshots when viewport-relative sizes are used
See original GitHub issueI’m trying to correctly render in pdf this slide:
(snapshot generated by decktape)
Its resulting code is:
<section class="present" style="top: 0px; display: block;">
<h2 id="hi-res-default">Hi res, default</h2>
<img src="4k.jpeg" style="
max-width: 95vw;
max-height: 80vh;
object-fit: contain;
">
</section>
When rendering in pdf, however, the vw
/vh
units seem to be broken and relative to something different than the page size, and images get rendered much smaller than they should be.
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (2 by maintainers)
Top Results From Across the Web
If PDFs or images aren't the correct size in Preview on Mac
In Preview on your Mac, you can set PDFs and images to be displayed at the same size on all screens, regardless of...
Read more >Minimizing PDF File Size While Maximizing Graphics
The final size of a PDF file is a function of two primary issues related to graphic images used on each page: 1....
Read more >2023 Social Media Image Sizes for All Networks [CHEATSHEET]
The most recent image size specifications for different social media networks, including Instagram, Twitter, Facebook, LinkedIn, and more.
Read more >Understanding PDF File Size - Evermap
It is crucial to understand the actual file size allocation between various PDF ... The image resolution (image dimension in pixels) is also...
Read more >Xcode: Vector images from PDF bad quality - Stack Overflow
I would set the Preserve Vector Data flag on the asset here: enter image description here. This will make it render as a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@jonathan-g man you really saved my day. I enabled a double generation of my slides in CI, both via decktape and via chromium headless. They seem to work nicely.
I don’t know enough about the internals of Chromium to know how to make a good bug report for this.
But the good news is that there’s a workaround: Chrome and Chromium seem to do fine at rendering reveal.js slides to pdf from a terminal command prompt, with none of the problems I see with puppeteer and decktape.
Basically you want to serve your slides to
localhost:8000
and then execute (you can play around with whether you want to disable the GPU and how large you want to set the maximum time budget for rendering):And it’s easy enough to wrap this command line in a script to make things less cumbersome.