Footer Header utils: import nt; import Element; import ; import Text . When creating PDF documents, the first thing we usually do, is create a header and footer for every page. Adding an image to the header, helps. This page will provide the tutorial for how to add header and footer in every page of PDF using iText in java. iText provides.

Author: Sagis Kigalkree
Country: Poland
Language: English (Spanish)
Genre: Literature
Published (Last): 10 April 2008
Pages: 345
PDF File Size: 16.45 Mb
ePub File Size: 10.5 Mb
ISBN: 276-3-58017-479-8
Downloads: 80080
Price: Free* [*Free Regsitration Required]
Uploader: Kazirg

Use that example as inspiration. September 19, You only need to fpoter one extra page event, the Watermark class. By clicking “Post Your Answer”, you acknowledge that you have read our updated terms of serviceprivacy policy and cookie policyand that your continued use of the website is subject to these policies.

The PDF document we generated contains a clean header with an image.

Add Header and Footer in PDF Using iText in Java

By extending from this class adding overriding these methods, we can write additional data to the PDF document when these events occur. You also discovered two other important objects: You can use adring more simple example, such as the one in the answer to How to add Header and Footer in dynamic pdf using iTextLibrary? Sign up using Facebook. You created several “Hello World” examples that demonstrated the famous “five steps” that were used in every example of part 1.


The other varies depending on the current topic. Gilles-Antoine Nys 1, 8 April 2, Sign up using Email and Password.

How to add text as a header or footer? | iText Developers

Iext the previous example, you added a header and footer with the showTextAligned method. September 15, In the first cell, you add the text for the header. In the second cell, you add “page X of ” where X hedaer the value returned by writer.

For instance, how can you add a page header while creating a PDF document. First, take a look at the footer: January 19, When creating PDF documentsthe first thing we usually do, is create a header and footer for every page. I want to add a header image and page numbers as footer to my PDF file.

Please take a look at the official iText documentation before posting a question on StackOverflow. Post as a guest Name.

Adding Header and Footer in PDF using iText in Java

We have already discussed seven methods of the PdfPageEvent interface; four more methods involving the document and its pages remain: By using our site, you acknowledge that you have read and understand our Cookie PolicyPrivacy Policyand our Terms of Service.


Your answer essentially uses the same technique as the earlier, accepted answer.

Nov 30 ’16 at You can define a bottom border for each cell so that the header is underlined. NOTE When the document is closed, the newPage method is triggered to perform finalizattions on the current page.

The other solution involves a PdfTemplate object and page events. Topic 3 explained how to add content at a lower level: Angel Addimg Ayala Ochoa 5. Adding page events to PdfWriter iText 5. Initially you added custom features to Chunk, Paragraph, topic, and Section objects. On the bottom right you can see the current page number together with the total page number.

This name is set using the setHeader setter geader. I get an error with: The third cell is special: