Hi,
I am using iText to concatenate two pdf-documents and add an overall "pagefooter", that is, a consistent looking pagenumbering and a watermark. Now, I would like the pagenumber to be a rectangle with some text and a background color. So far I havn't succeded in doing that. Also, the watermark doesn't appear at all. I have tried using PdfCopy as well as PdfWriter as writer-object.


This is my code: (I have "highlighted" where I believe the changes are to be made with %%%%% )

while (f < files.length) {
PdfReader reader = new PdfReader(files[f]);
reader.consolidateNamedDestinations();
int n = reader.getNumberOfPages();
if (f == 0) {
document = new Document(reader.getPageSizeWithRotation(1));
try {
Watermark watermark = new Watermark(Image.getInstance("D://XO//Projekter//Test//Eksempel.jpg"), 200, 320);
document.add(watermark);
}
catch(Exception e) {
System.err.println("Path to watermark is wrong!");
}
writer = PdfWriter.getInstance(document, new FileOutputStream(outFile));
document.open();
cb = writer.getDirectContent(); }
PdfImportedPage page;
for (int i = 0; i < n; ) {
document.newPage();
++i;
page = writer.getImportedPage(reader, i);
cb.addTemplate(page, 0, 0);
cb.beginText();
cb.setFontAndSize(bf, 10);
Color colorBlue = new Color(0x00,0x00,0xFF);
cb.setColorFill(colorBlue);
if(i%2==0) {
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
cb.showTextAligned(PdfContentByte.ALIGN_LEFT, "text " + i + "/" + total, 0, 40, 0);
}
else {
cb.showTextAligned(PdfContentByte.ALIGN_RIGHT, "test " + i + "/" + total, 595, 40, 0);
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
cb.endText();
f++;
}


Thanks

Martin



-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to