Page break in print formats

How do I insert a page break in print formats. for example i want terms to always be on the next page.

@yashwantc

add following code for page break before printing Terms and condition

<div class="page-break"></div>

also you need to add letterhead after page break.
reference

2 Likes

Is there no way to put page break via standard template without using HTML?

@yashwantc you can create print format using print format builder.
In print format builder, you just need to do drag and drop and add html field with page break code.

1 Like

Hi sambhaji, i used the code

in custom HTML field but it doesnt add a page break. is there anything I am missing.

@yashwantc
You need to click on <> button and then add html code <div class="page-break"></div>

1 Like

I did that but it still does not break the page. I even added a new section and added HTML field with the above code. It doesn’t work.

@yashwantc
Then final option is, you can create your own print format using Custom Print Format and HTML code.

Can you share what type of print format were you having? I would like to see if I can recreate this problem and find a resolution.

Thanks it works for me.

Doesn’t work for print format builder type print formats. anyone have another solution they can share?

You can define page break using a Custom CSS code
example: .section-break:nth-child(8) {page-break-after: always}

On the print format>Customize>Edit Properties>Custom CSS Code

Have to figure out to adapt this to a non-child-table based situation. But narrowed down the issue to the PDF generator.

HTML page break using

<div class="page-break"></div>

as recommended in this thread works if using the standard PRINT button. But if using the PDF button to generate the PDF, the page break is not folllowed.

I’m trying to get a page break in a table for a script report. I don’t want the image to get split into two pages. Any ideas?

{% rows.forEach(function(item, index) { %}

{% i = parseInt(item,10) %}
{%= dateutil.str_to_user(data[i][(“measurement_date__time”)]) %}
{%= data[i][
(“calculated_daily_volume”)] %}
{% url_site_gps_image = encodeURIComponent(data[i][__(“site_gps_image”)]) %}

<img src = {%= url_site_gps_image %}
style = “max-height: 20px, width: auto”>

	{% }) %}

I gave up on trying to break a table into two pages. Presented like this instead.

{% var rows = frappe.query_report.datatable.rowmanager.getCheckedRows() %}
{% rows.forEach(function(item, index) { %}
{% i = parseInt(item,10) %}
{% if ( i>1 && i%2 == 0 ) { %}

 


{%= (“Site Photos with GPS Location”) %}


{% } %}



{%= ("Date: ") %} {%= dateutil.str_to_user(data[i][(“measurement_date__time”)]) %}
{%= ("Daily Volume: ") %} {%= data[i][(“calculated_daily_volume”)] %}
{% url_site_gps_image = encodeURIComponent(data[i][
(“site_gps_image”)]) %}

	<div style="max-width: 70%; margin-right: 10px;">
			<img src = {%= url_site_gps_image %} 
			style="width: 100%" >
	</div>
	<br>
</p>

{% }) %}