I have already modified the code that handles
outputing HeaderFooter to a RTF document. This enables
users to easily display "page 1 of 5" in a
footer. In rtf docs it is super easy, just need the following line to
display the total number of pages.
{\field{\*\fldinst {\cs19 NUMPAGES
}}{\fldrslt {\cs19\lang1024\langfe1024\noproof 4}}}
Easy.
So I figured I would change the HeaderFooter class
to have an additional data member.
private Phrase middle = null;
This middle phrase would go inbetween the to
page numbers. i.e. " of " typically.
A new constructor is needed.
/**
* Constructs a <CODE>Header</CODE>-object with a pagenumber at the end. * * @param before the <CODE>Phrase</CODE> before the pagenumber * @param middle the <CODE>Phrase</CODE> between the pagenumber and total pages * @param middle the <CODE>Phrase</CODE> after the pagenumber * @param numbered <CODE>true</CODE> if the page has to be numbered */ public HeaderFooter(Phrase before, Phrase middle,Phrase after) { super(0, 0, 0, 0); setBorder(TOP + BOTTOM); setBorderWidth(1); this.numbered = true; this.before = before; this.middle = middle; this.after = after; } Also created a class called RtfPageNumbers, which
handles outputing the correct rtf code for the total pages. So my question is, it was fairly easy to add the
functionality to an RTF document, to make pdfs work, I simply need to modify
HeaderFooter.paragraph() to output a template inside a chunk, if middle is
set. And then on close of the document fill in the template. However
I don't access to the writer to grab a template.
Does this look do-able? Any
hints. Maybe I need to modify the code that outputs the HeaderFooter
to do something special instead of calling .paragraph(), much in the same way
RtfWriter does.
thanks for any input.
w. scott hayes
I think this functionality would be a nice feature
for people wanting to write documents for output of pdf and rtf.
|