Chapter and Section should have the option of generating or not the table of 
content. Meanwhile use a generic tag to keep track of what you are adding.

Paulo
  ----- Original Message ----- 
  From: phishl...@gmail.com 
  To: itext-questions@lists.sourceforge.net 
  Sent: Wednesday, April 21, 2010 8:29 PM
  Subject: [iText-questions] Header through PageEvent, need to modify text per 
"chapter"


  I've been trying different approaches to this problem for a few days, but 
keep running into dead ends.

  I'll use some familiar objects to lay out my problem:

  I have Orders and Line Items.  I'm printing a document of all Orders for a 
given day (a nightly report).  Each Order has many Line Items, so the table of 
Line Items spans multiple pages.  The header for each page has the report name 
in bold, then the order number below in a different font.

  I need to change the order number in the header (and start a new page in the 
document) whenever I start adding Line Items for a new Order to the PDF.

  I'm using a custom PageEvent for the header already.  At one point, it looked 
like Chapters were perfect for what I needed, especially the "onChapter" method 
that is automatically triggered on PageEvent.  Unfortunately, the users do NOT 
want a Table of Contents in their report, and I wasn't able to find a way to 
suppress this (from what I can see in the PdfDocument.add(Element element) 
code, displaying it isn't configurable).

  I thought maybe I could subclass PdfDocument, then realized that the only 
class I have access to is Document - I don't see a way to force iText to create 
an instance of my PdfDocument subclass instead of the usual class (no 
configurable factory, etc).  Anyway, overriding the add(Element element) method 
would be awful, basically gutting the functionality.  Not being able to use a 
custom subclass also prevents me from using a "updateHeaderSubtitle" method or 
something similar on my (imaginary) PdfDocument subclass.

  The only workable solution I've come up with yet is writing a special method 
on my PageEvent to update the header subtitle variable, then saving a reference 
to my PageEvent instance as I add it to the Document so I can access it later 
(every time I switch Orders).  This (accessing methods on PageEvent directly) 
doesn't seem like it fits with the usual pattern for this library - is there 
another solution that I'm missing, that would fit in better with the general 
design?

  Meghan
------------------------------------------------------------------------------
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.itextpdf.com/book/
Check the site with examples before you ask questions: 
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/

Reply via email to