> Bruno Lowagie wrote:
>
> OK. And do you know which PdfTemplate has the page
> number you want to change? If so, you could change
> the content of the template (not the ideal way to
> do it, but probably the best one available).
>
Now I read the section in chapter 18 in which you explain why it is not a good
idea to use pdf as a format for editing. Your arguments are all true, but the
only problem that I've got, is that I must implement such a solution in my pdf
document.
At the moment I read the base document with the total page num on each page.
For each page I check if there a some templates. If there are some templates
on this page I take them and change the text in it. But the total page num
doen't change. Is there somethig wrong in my implementation. My list of
templates consist only of PdfTemplates and I change there value with showText
().
Code example:
PdfReader readerBase = new PdfReader(Test.pdf);
int pagenumBase = readerBase.getNumberOfPages();
PdfStamper stamper = new PdfStamper(readerBase, new FileOutputStream
(Test_New.pdf));
int i = 1;
while (i <= pagenumBase) {
if (templatesMap.get(i).size() > 0){
Iterator<APdfTemplate> templateIterator = templatesMap.get(i).iterator();
while(templateIterator.hasNext()) {
APdfTemplate template = templateIterator.next();
PdfTemplate tpl = template.getTemplate();
IReportText reportText = template.getIReportTextObj();
BaseFont font = getFontTypeHelper().convertFont(reportText.GetFontName
(), reportText.GetFontSize(), reportText.GetFontColor(), reportText.GetFormat
(), getContextConnector()).getBaseFont();
String text = "" + (pagenumBase + offset);
float fontSize = (float) reportText.GetFontSize();
tpl.beginText();
tpl.setFontAndSize(font, fontSize);
tpl.setTextMatrix(0, 0);
tpl.showText(text);
tpl.endText();
}
}
i++;
}
stamper.close();
-------------------------------------------------------------------------
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
Buy the iText book: http://itext.ugent.be/itext-in-action/