How to trigger a page break in jinja template

Hi,
Anybody can help me how to trigger a page break in custom format, when i use the {% set counter = 0 %} and {% set counter = counter + 1 %} in my loop (for item in doc.items) and use the counter to make a condition if the counter reaches 40 records it should initiate a page break but the counter is still 1. Thanks in advance.

@EdmundDelima Did you find any solution ?

@SufyanSadiqOffice @EdmundDelima Please check this code in your jinja template

{% set count = namespace(cnt=0) %}
# for loop of items
{% for items in doc.items %}
# update the count
{% set count.cnt = count.cnt + 1 %}
{% endfor %}

@Meet Your provided code will count the length of items table.
My question is that how to go on next-page after every iteration using css.

@SufyanSadiqOffice For page break please check this docs Page break in print formats - #2 by kolate_sambhaji

@Meet I have read the doc but the class ‘page-break’ is not working in the print format.

I also faced this problem.Kindly let me know when you find any solution.

Hi, I have inserted this in my table:
page break