|
Hey Paulo,
I added the following lines to create my custom footer inside of PdfDocument float w = (footer.getMiddle()).font().getBaseFont().getWidthPoint(pageNumberMaxChars,(footer.getMiddle()).font().size()); float h = (footer.getMiddle()).font().size(); footerPageNumberTemplate = (writer.getDirectContent()).createTemplate(w,h); footerPageNumberTemplate.setFontAndSize((footer.getMiddle()).font().getBaseFont(),footer.getMiddle()).font().size()); footerPageNumberImage = Image.getInstance(footerPageNumberTemplate); footerPageNumberChunk = new Chunk(footerPageNumberImage,0,0); footerParagraph.addSpecial(footerPageNumberChunk); The following variables are private variables in the
PdfDocument. So I can save the references.
footerPageNumberTemplate
footerPageNumberImage footerPageNumberChunk pageNumberMaxChars ------ is a
variable holding "000000", as a default width for the template.
I used an image to contain the footerPageNumberTemplate so that the text will flow around the template naturally, and since I don't know the exact location to place the template. Then in the close funciton I back patch the template since I now know the number. Rectangle rec = footerPageNumberTemplate.getBoundingBox(); rec.setRight(6); footerPageNumberTemplate.setBoundingBox(rec); Image img = footerPageNumberChunk.getImage(); img.setRight(6); footerPageNumberImage.setRight(6); footerPageNumberTemplate.beginText(); footerPageNumberTemplate.showText(String.valueOf(writer.getPageNumber() - 1)); footerPageNumberTemplate.endText(); Obviously I need the width by calculating the width of the total number of
pages. However for testing purposes I just put in the value of 6.
How come the size of the template is not changing. Or is it not
possible to change the width once it has already been added to the
document.
I have a patch for my changes to the latest CVS, and example files to show
the output. If you would like them to look at please let me know.
thanks
scott
----- Original Message ----- From: "Paulo Soares" <[EMAIL PROTECTED]> To: "'William S. Hayes'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Wednesday, November 05, 2003 5:47 AM Subject: RE: [iText-questions] Changing the size of a PDFTemplate > You can change the bounding box at will. > > Best Regards, > Paulo Soares > > > -----Original Message----- > > From: William S. Hayes [SMTP:[EMAIL PROTECTED] > > Sent: Tuesday, November 04, 2003 19:32 > > To: [EMAIL PROTECTED] > > Subject: [iText-questions] Changing the size of a PDFTemplate > > > > > > I am trying to modify the src of iText HeaderFooter to support "page X or > > Y" by default. I have it working for both the PDF and RTF engine. > > However inorder to do it with a PDF you have to use a PDFTemplate to back > > patch the total pages(Y). However you do not know the value, hence the > > size of the text to insert, whether it is 10 or 100, or 1000, or 100000. > > > > So my question is, Is there anyway to change the width of a PDFTemplate > > after it has been added to each HeaderFooter object of every page, once > > you have the value? > > > > I know a better solution is to use the PageEvent model, however I have to > > support both RTF and PDF. > > > > thanks > > scott > |
- [iText-questions] Changing the size of a PDFTemplate William S. Hayes
- RE: [iText-questions] Changing the size of a PDFTemp... Paulo Soares
- William S. Hayes
