Node-html-pdf: Split pages

Created on 24 Apr 2018  路  5Comments  路  Source: marcbachmann/node-html-pdf

Is there a good method to split lines into separate pages?
Example:
<div id="page1">Title1 content1 </div><div id="page2"> Title2 content2 </div>

For now i need to add a css class like this:
.div { width: 800px; height:1000px; }

But the compatibility is poor for the page size is different between machines(OS)

Most helpful comment

I use page-break-inside: avoid !important; but it does not do anything for me, unfortunately. I don't understand why.

All 5 comments

I'm not exactly sure what you mean by lines, but you can maybe make use of page-break-inside property in CSS (or before/after). They we're discussed in #49 (and many other issues). I find page-break-inside: avoid; to work pretty well. Hope that helps!

I use page-break-inside: avoid !important; but it does not do anything for me, unfortunately. I don't understand why.

@molerat619 are you using that property on a div? It might not behave correctly on elements that don't have display: block.

@molerat619 are you using that property on a div? It might not behave correctly on elements that don't have display: block.

I have used display:inline as display:inline-block also , no luck

I had an issue where I was setting the top parent container div a style="position:relative;top: 40pt", because I needed to get the cover page of the document to be started a bit lower than the rest of the pages.

The top positioning then broke the page-break-before completely for the document, it would not work anywhere. Not sure why, could not find anything in the documentation.

My suggestion is make sure that the page-break-before works at all by seeing the print preview in Chrome.

If it doesn't, you have some kind of a positioning issue with your html. You can find that issue by removing parts of the HTML until your print preview gets it's page breaks back.

If it does have those page-break-before rendered correctly in the print preview, only then this issue might be related to this library.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

B-StS picture B-StS  路  5Comments

tsp1996 picture tsp1996  路  5Comments

Mortuie picture Mortuie  路  4Comments

antiframes picture antiframes  路  4Comments

RodolfoSilva picture RodolfoSilva  路  3Comments