brenden / node-webshot

Easy website screenshots in Node.js
2.12k stars 286 forks source link

How to Render Multiple PDF Pages From HTML #171

Closed turnerniles closed 7 years ago

turnerniles commented 7 years ago

I am trying to render HTML to multiple PDF pages. I am using the CSS attribute "page-break-inside: avoid" on the div where I want a page break. Webshot / Phantom will create a new page because of this but all of the content is appearing on the first page. Any idea why?

Below are my options:

    var options = {
                    siteType: 'html',   
                    'paperSize': {
                        'format': 'Letter', 
                        'orientation': 'portrait'
           }
        };

I also tried using phantom2 via the phantompath option instead of phantom1.9. But I still get the same result.

turnerniles commented 7 years ago

Turns out it was a simple CSS issue where parent divs have to be positioned relative with the child elements positioned absolute.