The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

Aparna (1) [Avatar] Offline
I am generating pdf in java using itext. I want to display the different
headers on different pages. I'm using one single document and pages are
getting added to it at run time. I have got 5 servlets written to generate
the whole pdf. At start of every servlet i've written the code for header
the problem is when its get generated the header gets added to the one more
extra page.
to get clear idea i am including the eg below.
Eg 1-3 pages i want header1 to get display.
4-7 pages I want header2 to get display.
8-10 Pages I want header3 to get display
The actual output which i get is as follows.
1-4 header1
5-8 header2
9-10 header3

Even I used the page event method onStartPage for this, but same problem continues.
Please help me to resolve this issue.
blowagie (284) [Avatar] Offline
Re: Headers are not getting added properly in itext document.
That's because you did something wrong.
The first thing you could do to correct this, is to read this thread that was ON TOP OF THIS FORUM:
Then you should go to and post the question on the appropriate place. However: your question reveals that this isn't a bug in iText; it's a bug in your code (to be solved using elementary logic), so you'll have to provide more info or you won't get any answer there either.