Insert a page break after every item in print format

Dear Community,

Is there any way that I can insert a page break after every item? I am using a Custom HTML for the items table.

I have tried using

as per below.

<table class="table table-bordered">
    <tbody>
        {%- for row in doc.items -%}
        <tr>
            <td style="width: 3%;">{{ row.idx }}</td>
            <div class="page-break"></div> 
<td style="width: 20%;">
                {{ row.item_name }}
                {% if row.item_code != row.item_name -%}
                <br>Item Code: {{ row.item_code}}
                {%- endif %}
            </td>
            <td style="width: 37%;">
                <div style="border: 0px;">{{ row.description }}</div></td>
            <td style="width: 10%; text-align: right;">{{ row.qty }} {{ row.uom or row.stock_uom }}</td>
            <td style="width: 15%; text-align: right;">{{
                row.get_formatted("rate", doc) }}</td>
            <td style="width: 15%; text-align: right;">{{
                row.get_formatted("amount", doc) }}</td>
        </tr>
        {%- endfor -%}
    </tbody>
</table>

Thanks!

Sorry but there isn’t any solution to this?

Hi @mulyadi-agtechsg,
Try this

<table class="table table-bordered ">
        {%- for row in doc.items -%}
        <div class="row">
            <div class="col-xs-2" >{{ row.idx }}</div>
        <div class="col-xs-2" >
                {{ row.item_name }}
                {% if row.item_code != row.item_name -%}
                <br>Item Code: {{ row.item_code}}
                {%- endif %}
            </div>
             <div class="col-xs-2" >
                <div style="border: 0px;">{{ row.description }}</div></div>
            <div class="col-xs-2">{{ row.qty }} {{ row.uom or row.stock_uom }}</div>
            <div class="col-xs-2">{{
                row.get_formatted("rate", doc) }}</div>
            <div class="col-xs-2">{{
                row.get_formatted("amount", doc) }}</div>
                  
        </div>
        <div class="page-break"></div> 

        {%- endfor -%}
  
</table>
1 Like

Hi @shraddha,

Still doesn’t work though. In ERPNext Print Preview, it shows the page break line though.

However, when it comes to actual printout, there isn’t any page break.

Thanks!

Hi

After reading this post. It solves the problem for me. At least for Delivery Note.

This is a must have step.

  1. Create format from the print format doctype i.e Setup > Print Format > New

  2. This is the setup. Print Format Type: Server



3.This is my sample code. You need to put <div class="page-break"></div> before {%- endfor -%}

        {%- for row in doc.items -%}
        <div class="row">
            <div class="col-xs-2" >{{ row.idx }}</div>
        <div class="col-xs-2" >
                {{ row.item_name }}
                {% if row.item_code != row.item_name -%}
                <br>Item Code: {{ row.item_code}}
                {%- endif %}
            </div>
             <div class="col-xs-2" >
                <div style="border: 0px;">{{ row.description }}</div></div>
            <div class="col-xs-2">{{ row.qty }} {{ row.uom or row.stock_uom }}</div>
            <div class="col-xs-2">{{
                row.get_formatted("rate", doc) }}</div>
            <div class="col-xs-2">{{
                row.get_formatted("amount", doc) }}</div>
                  
        </div>
            <div class="page-break"></div> 


        {%- endfor -%}
2 Likes