Need Reset Page without a document Documents created in one PDF document

I use FPDF to create invoices, and I had to get around the problem when printing multiple documents. I create several (2 to 100+) invoices for printing, so I built a foreach loop around my FPDF code to put all my invoices in one PDF file so that I can click print and do it. The problem is that FPDF uses PageNo () and {nb} to create page numbers and the total number of pages in the header, and if I have 500 pages that it lists as Page: 1 of 500, Page: 2 of 500, Page: 3 of 500 ... etc.

I need to figure out a way to create a page counter and the current page in the account. Therefore, if the first invoice is 3 pages, he says: Page 3 of 3, Page: 2 of 3, etc., And the next invoice is 5 pages, Page: 1 of 5, Page: 2 of 5 etc .... even though all this is in one PDF file.

$pdf=new PDF(); foreach ($array_invoices as $invoice_number) { ...FPDF Template Here... /** * The following code checks the page length * If the page is over a certain length it will create a new page. * If not, it will add the footer. */ if($pdf->GetY() < 225) $pdf->SetY(238); elseif($pdf->getY() > 240) $pdf->AddPage(); } $pdf->Output(); 

The template has a header that displays the page number ...

 $this->Cell(94,0,'page '.$this->PageNo().'/{nb}' ,0,0,'R'); 
+4
source share
1 answer

It is possible to create page groups in which each group has its own pager, there is already an addon that will do the work for you: fpdf addon page groups

+4
source

Source: https://habr.com/ru/post/1486031/


All Articles