1

I have more than 20 letters which I am printing into PDF using html2pdf. The HTML code goes inside the foreach loop, I am using the ... data ... in the foreach loop to print each letter. However the page numbers that are comming is applying to the entire PDF, I would like the page number to reset for each tag in the PDF. Ex if letter1 goes up 2 pages, then for letter 2 in the same PDF it should start the page number from 1. Below goes my sample code. I am wondering if there is any alternative solution to fix it.

foreach ($orders as $order) 
{
?>
<page backtop="10mm" backbottom="10mm" backleft="8mm" backright="8mm">
<page_header>
    <div style="width:730px; text-align:right;"><?php echo $order->order_id;?> page [[page_cu]] of [[page_nb]]</div>
</page_header>
..HTML code of my letter goes here
</page>
<?php
}
?>

Ex- If we have 3 letters the page number goes like

page 1 of 3 page 2 of 3 page 3 of 3

Instead I want page 1 of 1, page 1 of 1, page 1 of 1 for each 3 letters. Note that a letter may have more than one page so for such situation it should be like page 1 of 2 for letter 1 first page, page 2 of 2 for letter 1 second page, then for letter 2 it should again start from page 1 of 1.

I have tried to be more clear regarding my question, kindly let me know if I am confusing here.

Thanks in advance.

1 Answers1

1

look at the html2pdf examples. There are sample that uses [page_cur][page_nb] (something similar to that). That special tags render page number and page count.

fasisi
  • 396
  • 5
  • 23