question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to display full viewport?

See original GitHub issue

I’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.

screen shot 2017-04-27 at 3 04 36 pm

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:closed
  • Created 6 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
codecounselorcommented, Apr 27, 2017

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 the windowTailor.js file https://github.com/fraserxu/electron-pdf/blob/master/lib/windowTailor.js

You 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.

0reactions
Tin-Nguyencommented, Jun 14, 2017

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found