node-html-pdf icon indicating copy to clipboard operation
node-html-pdf copied to clipboard

Is there any way to make page breaks?

Open ghost opened this issue 10 years ago • 10 comments

I'm trying to schematize a pdf, but there's no way to make page breaks.

ghost avatar Jul 21 '15 10:07 ghost

Sorry, I don't know that this css style exists. Solved page break with:

style="page-break-after:always;"

ghost avatar Jul 21 '15 10:07 ghost

Thanks! <br><div style="page-break-after:always;"></div> worked perfectly for me.

lucdetellis avatar Aug 01 '15 03:08 lucdetellis

style="page-break-after:always;" Works perfect!

vrunoa avatar Aug 07 '15 19:08 vrunoa

you can use media queries too:

@media print { p {page-break-inside: avoid;} h1 {page-break-before: always;} footer {page-break-after: always;} }

that may give anybody reading this an idea #2018 :)

zurcacielos avatar Jan 15 '18 20:01 zurcacielos

@lucdetellis you are a god!

vieiralucas avatar Feb 23 '18 20:02 vieiralucas

Sorry to revive an old thread, but have any of you had any luck doing the same with css grid? page-break-after doesn't seem to work within a grid.

selven avatar Sep 04 '19 15:09 selven

Hi Techies, I am facing problem of page-break not working for table row (tr), I have tried all above methods but no luck, FYI ., i am using Nodejs, serverless framework having html-pdf as dependancy

somasekharn avatar Sep 25 '19 09:09 somasekharn

if you are running into problems where "page-break-after: always;" does NOT work, then a cheap way to get around it is to install something like "merge-pdf-buffer" to merge multiple pdf buffers. It's how I solved my problem. instead of creating 1 pdf-buffer create multiple and merge them using the "merge-pdf-buffer" package.

aleem-ahmed avatar Jun 03 '21 06:06 aleem-ahmed

guys can I get some help with this? https://stackoverflow.com/questions/69858192/add-page-break-to-ejs-template

AhsanNissar avatar Nov 05 '21 19:11 AhsanNissar

style="page-break-after:always;" worked for me. Thanks

PriyankMotivaras avatar Aug 25 '22 12:08 PriyankMotivaras