I am using PdfSharp/Itextsharp to stitch together a number of documents and stamp a page number at the bottom of each page. The first document in the package is the Table of Contents and is not paginated. I start the pagination with the first page after ToC. The problem is the page number that is displayed on the document is not the same as the page number indicated by the Adobe Reader.
I checked with other documents and it looks like pdf supports the option to somehow reset the page number so page 1 can start again later in the document.
How can I do this with pdfsharp or itextsharp?
The page numbers shown in Adobe Reader are defined by "Page Labels".
For instance: you number the TOC with i, ii, iii, iv, v and so on. The real page numbers are 1, 2, 3, 4, 5, and so on.
Here's a Java example from my book that shows how to work with Page Labels: http://itextpdf.com/examples/iia.php?id=234 [archived] It should be very easy to adapt it for use in C#.
If not, look for the corresponding example on this site: http://kuujinbo.info/iTextInAction2Ed/index.aspx
Related
How to generate a Table of Contents “TOC” from merged file.TOC should be heading of each pages.i have seen many examples, all TOC example worked on page number basis.I am using text pdf 5.5.11.
I would try following workflow:
Extract the text where you expect the header to be
Store (List of String) all headers and their corresponding pages
Loop over the list, and flatten it (eg [TitleA, TitleA, TitleB, ..] should become [TitleA, TitleB])
Now you have information on when every header appears for the first time
Use this information to build a TOC
If your document is tagged, this can be done in a way that will work more often (considering that using the approximate position of headers and simply extracting text there is a bit of a heuristic approach)
I have a box label form and it all works great but we would like to be able to automatically generate sequential box labels. So on the form we would have a [Total Boxes] form field. If the user put in "5" then on the labels we would generate a different label for each box e.g. 1 of 5, 2 of 5, 3 of 5, 4 of 5, 5 of 5. I would be happy with this happening at the time they are printed, or generating a new PDF with all the pages. Either way this needs to be a very simple process for the end user of the forms. Any ideas?
I never found a perfect solution to this in Acrobat. I decided to simply recreate the form in Excel and lock the sheet except for the fields needed and then it was easy to create multiple pages.
Have a questions regarding page numbering in a report book. Point is: I have a client that does name-giving of page numbers like this:
Chapter 1, page 6 (4th page that chapter) = 1-4
Chapter 2, page 12 (3th page that chapter) = 2-3
etc.
Now, it's possible to make it happen with al different reports in the Content-section, but How do I display this pages/properties in the table of contents?
The report book supports some method that gives that bookmark-names back, but uses the $V{MASTER_CURRENT_PAGE} to print the page number. How could I show the page-numbers that are actually beneath the pages of the bookmark?
Please let me know, struggle with this one.
Regards, Gert
Let me explain the scenario.
1) i have an existing pdf with TOC named A.pdf with 10 pages
2) i have two more pdf named B.pdf, C.pdf with TOC with 5 pages
3) Now i need to add B.pdf to A.pdf after 3rd page
4) and C.pdf to A.pdf after 7th page.
5) And need to update the TOC based on the Final sequence
Could any one have idea how to implement by using itext.
Please read the documentation, more specifically chapter 7 of my book. You'll find an example named ConcatenateBookmarks that does exactly what you're asking. That is: if by TOC, you are referring to bookmarks stored in an outline tree. In the example, we read all bookmarks using the SimpleBookmark class, we compose a new outline tree, shifting the bookmarks depending on the number of pages in each of the existing documents, and then we add the composed outline tree to the resulting PDF using the setOutlines() method.
If by TOC you mean, a sequence of pages showing a table of contents without any semantics or interactive features, you're asking something that is impossible due to the nature of PDF (which you'll discover once you start reading ISO-32000).
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