Developer forum

Forum » CMS - Standard features » Add page break when generating PDF

Add page break when generating PDF

Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Guys,

I am using the &pdf=true&print=true paramters to generate a proforma invoice for orders placed.

Everything is fine for orders with a few Orderlines. As soon as I get more than 10 orderlines, the height of the page requires a new page but I don;t know how to control when the page breaks. the default behavior is that the PDF just gets to the next page cutting a few details of the page.

I believe there should be a standard way of adding a page break with some HTML tag or something similar?

Thank you,

Adrian


Replies

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi Adrian,

 

You should be able to do that with standard CSS for page break.

https://www.w3schools.com/cssref/pr_print_pageba.asp

 

We did this for BioLegend, so you have access to those templates too. It's a specific Product list template called productListPdf.cshtml and you can search for page-break css class.

 

Best Regards,

Nuno Aguiar

 
Morten Bengtson Dynamicweb Employee
Morten Bengtson
Reply
This post has been marked as an answer

Hi Adrian,

You can use the page-break-before, page-break-after and page-break-inside CSS styles.

<div style="page-break-before:always">&nbsp;</div>

More info here: http://www.websupergoo.com/helppdfnet/source/3-concepts/g-htmlrender.htm

Votes for this answer: 1
 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi guys,

Thank you all for the fast reply.

Before opening the task I have tried the page-break-before:always without any luck.

Tha's why I thought maybe ther something particular about it.

i will give it another try. Seems that i am on the right path.

Thank you very much.
Adrian

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

I can confirm it works.

My mistake was trying to break a table based on the style set on the TR or TD.

I have changed my approach and now everything is fine.

Thank you,

Adrian

 

You must be logged in to post in the forum