How to display full viewport?
See original GitHub issueI’m trying to switch to use electron-pdf
lib from phantomJS
. I can generate the PDF from my HTML page, however, I don’t know how to modify the viewport to make the UI in PDF is generated correctly.
Please see the screenshot, even I set ‘landscape’, the UI still be rendered incorrectly. I want to make the viewport of page to be larger, which options will I use to do it?
Issue Analytics
- State:
- Created 6 years ago
- Comments:8
Top Results From Across the Web
How to make a div 100% height of the browser window?
A full page is called a 'viewport' and you can design an element according to its viewport in CSS3.
Read more >CSS Make A Div Height Full Screen [THREE SIMPLE WAYS]
Learn the three QUIKEST ways to make a div full screen using pure CSS that are height:100%, height:100vh and position:absolute.
Read more >Viewport concepts - CSS: Cascading Style Sheets | MDN
What is a viewport? ... A viewport represents the area in computer graphics being currently viewed. In web browser terms, it is generally...
Read more >Viewport Height for Full Screen Div? - CSS-Tricks
I have a DIV element that needs to fill the entire screen until the user scrolls and reveals ... Viewing 6 posts -...
Read more >Stretching body to full viewport height: the missing way
First, we apply min-height: 100% to the html element to stretch it to the full minimal viewport height. Then we use display: flex...
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
First of all, try version 1.2.1 which uses Electron 1.4.x. I recently noticed really bad stuff like what you’re seeing after upgrading to version 1.3 of electron-pdf which is using Electron 1.6.x.
If you want the browser window to be larger, than you will have to set custom sizes, for example
--pageSize '{"width":304800,"height":228600}'
(that is 12 x 9 inches). I’d recommend you take a look at thewindowTailor.js
file https://github.com/fraserxu/electron-pdf/blob/master/lib/windowTailor.jsYou need to be fairly intentional about either designing your document to be responsive or increasing your output size. If you want stuff to export well onto Letter size PDFs then you’ll need to design your page for an appropriately sized window (816 x 1056)
The code emits lots of events that you can use to see what it is doing. It is also helpful to set
--browserConfig '{"show":true,"x":0,"y":0}'
because what shows up in the window may not be what you get in your PDF.Running directly from the CLI will be a bit more challenging to debug, but you could hack some of the code to leave the Electron process running if you want to pike around in the Chromium browser manually.
Here is my solution: We use the command to generate the PDF with landscape
electron-pdf <input> <output> -l --marginsType '0'
Also, we update the layout of webpage to have full viewport.