Multiple page numners in HTML2PDF - html2pdf

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.

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.

Related

page number inside section

I have a section and I am trying to use the page number from word and I am getting page 1 in all pages.
I try link headers but I don't want the same header n my last page
header
<?for-each#section:G_1?>
page1/2
here is table i want to show up in every page
<?end for-each?>
-------------------------------------------
main body i have some groub by in tables
----------------------------------
i have different last page that calculate all my resuts and with no header
page1/2 <here is the error i want 1,2,3,4/120> and iam getting 1,1,1,1,1,1,1/2
Sections will reset page numbers.
You can bypass this by putting the following code anywhere in your template:
<?initial-page-number:'AUTO'?>

Adding 2 additional pages to the end of a crystal Report

I have a report for orders and i would like to add 2 pages at the end of the order. My order is most of the time 1 page, sometimes it will be 2 pages. So I want to add my terms & conditions to the end of it. This terms&conditions is always 2 pages.
I tried to add a text object in the report footer. Than in Section Expert, I select Report footer --> and Check the New Page Before ( I also tried it with the New Page After)
I also suppress the sections that I don't want to appear on the 2 last pages by using : PageNumber > TotalPageCount - 2
As far as this all works, but if I open my report. On the second page of the report you see the beginning of the terms&conditions. On the third page of the report you will see also de terms&conditions. But the second portion of the first page, of the terms&conditions, is also on the second page of the terms&conditions. therefore, there is always a part of the text that is duplicated
For example: my example of terms&conditions exist of 14 points. On the first page of the terms you will see point 1 to point 8. on the second page you will see point 6 to point 10. and on the third page you will see point 9 to point 14
--> Thats very annoying!!
I also tried it to check 'Suppress if duplicated' --> but nothing is changing??
Can someone help me with my problem please??
Place the terms and conditions in sub report and place that sub report in report footer

FPDF Multiple Documents Generated In One PDF, Need To Reset Page No Per Document

I am using FPDF to generate invoices and I had to work around an issue when printing multiple documents. I am generating multiple (anywhere from 2 to 100+) invoices for print so I built a foreach loop around my FPDF code to put all my invoices in one PDF so I can hit print and be done. The problem is, FPDF uses PageNo() and {nb} to generate page numbers and the total page count in the header and if I have 500 pages it lists as Page: 1 of 500, Page: 2 of 500, Page: 3 of 500... etc.
I need to figure out a way to generate a page count and current page by invoice. So if the first invoice is 3 pages it says Page: 1 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 it's all in the same PDF.
$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 an include to the header which outputs the page number...
$this->Cell(94,0,'page '.$this->PageNo().'/{nb}' ,0,0,'R');
It is possible to create pagegroups, where every group has its own pagerange there is already an addon that will do the work for you: fpdf addon page groups

How to add page number in multipage pdf report

I have created multiple pages pdf report using iReport as below.
Pdf report
How to put page number like (page 1 of 2) in this pdf report ?
If i will put same in iReport it will take all pages as separate page and give numbers accordingly, like:
for page1.jrml >> page 1 of 2 and page 2 of 2
for page2.jrml >> agian same page 1 of 1
...
it should be like:
for page1.jrml >> page 1 of 3 and page 2 of 3
for page2.jrml >> page 3 of 3
Please suggest.
You page numbering won't be correct because by using that approach you are creating 2 reports and merging them into 1 PDF, instead of creating a single report.
If you embed the second report into the first as a subreport, the page numbering should then be correct.
Im guessing you are putting the page number inside subreport. Page numbers should be in the page footer section of the main report.

JasperReport start page numbering after page break

How to start new (from 1) page numbering after page break?
I have 5 pages well page numbered. And after that 5 pages I want to insert page break and after that page break I want to add 5 more pages with page number start from 1.
page1(#1)
page2(#2)
page3(#3)
page4(#4)
page5(#5)
pagebreak
page6(#1)
page7(#2)
page8(#3)
page9(#4)
page10(#5)
You can create a jasper report variable, which will reset after the page break (for whichever group).