Leena Kulkarni wrote:

> We are using the following as suggested by you in one of the examples 
> you shared where PageNumbersWebDraftEventHelper is the class we have 
> written that has all the onPageEnd etc methods.
>  
> PageNumbersWebDraftEventHelper events = *new 
> *PageNumbersWebDraftEventHelper();
> writer.setPageEvent(events);

Page Events are the best way to add headers/footers.

>  <>HeaderFooter header1 = *new *HeaderFooter(*new *Phrase(),*new 
> *Phrase("# "+(ID)+" Text"));

HeaderFooter is an obsolete way to add headers/footers.

These are two completely different ways.
You can't mix them.

> document.setHeader(header1);
> header1.setAlignment(Element.ALIGN_LEFT);
> //document is the Document object and is is InputSource object formed 
> using the XML
> //String
> XmlParser.parse(document, is);
>  
> It is printing the page numbers and header for us as of now.
>  
> This header is same for the entire PDF.
>  
> We wanted different header for different sections in the PDF.

I suggest that you remove the lines that refer to the HeaderFooter object
from your code and that you draw the header in the onEndPage method
of your PageNumbersWebDraftEventHelper.
I still don't understand at which point you want to change the headers,
but the best way to do this, is to add a member variable for the header
to the event class and to subclass the XML handler class so that it changes
this header when necessary.

best regards,
Bruno

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to