Hi!
I would like to import every page of a file called C:\input.pdf ,
add one line "Hello World" at the bottom of the page,
and save the output to C:\output.pdf
Unfortunately I can not get the Hello World to appear.
Can anyone help me?
Thank you
Teniel Gordon
I use the code reproduced below
package com.ch.iText;
import java.awt.Color;
import java.io.FileOutputStream;
import java.io.IOException;
import com.lowagie.text.Chunk;
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.Element;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.PdfCopy;
import com.lowagie.text.pdf.PdfImportedPage;
import com.lowagie.text.pdf.PdfReader;
import com.lowagie.text.pdf.PdfWriter;
public class TestPDF {
public static void main(String[] args) {
Document document = new Document();
try {
PdfReader reader = new PdfReader("C:\\Input.pdf");
PdfCopy writer = new PdfCopy(document, new FileOutputStream("C:\\Output.pdf"));
document.open();
PdfImportedPage page;
for (int i = 1; i<reader.getNumberOfPages()+1; i++ ) {
page = writer.getImportedPage(reader, i);
writer.addPage(page);
document.add(new Paragraph("Hello World"));
}
} catch (DocumentException de) {
System.err.println(de.getMessage());
} catch (IOException ioe) {
System.err.println(ioe.getMessage());
}
document.close();
}
}
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
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/