www.foxitsoftware.com
murthy gandikota <[EMAIL PROTECTED]> wrote:
Hi Bruno
I am not looking to overlay one pdf on another. I want to fill up a form that has no fields. If you look at foxit.com you will see that they have a way to fill a form that has no fields. Here is my code to do it. But it doesn't work. Thanks for your help
import com.lowagie.text.*;
import com.lowagie.text.pdf.*;
//import com.lowagie.text.Document;
//import com.lowagie.text.pdf.PRAcroForm;
//import com.lowagie.text.pdf.PdfCopy;
//import com.lowagie.text.pdf.PdfImportedPage;
//import com.lowagie.text.pdf.PdfReader;
import java.io.FileOutputStream;
import java.util.*;
import java.awt.Color;
import java.io.*;
//import com.lowagie.text.pdf.PdfStamper;
public class Foxit{
/**
* Reads a form and fills in the fields.
* @param args no arguments needed
*/
public static void main(String[] args) {
System.out.println("Filling in a form");
try {
//Document document = new Document(PageSize.LETTER, 90, 54, 72, 72);
//document.open();
PdfReader reader= new PdfReader("application.pdf");
int n = reader.getNumberOfPages();
Document document = new Document(reader.getPageSizeWithRotation(1));
// step 2: we create a writer that listens to the document
PdfCopy writer = new PdfCopy(document, new FileOutputStream("app2.pdf"));
// step 3: we open the document
document.open();
PdfImportedPage page;
for (int i = 0; i < n; ) {
++i;
page = writer.getImportedPage(reader, i);
writer.addPage(page);
//writer.add(new Phrase("hello world"));
}
PdfContentByte cb = writer.getDirectContent();
Font font9 = FontFactory.getFont(FontFactory.TIMES_ROMAN, 9);
cb.beginText();
BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
cb.setFontAndSize(bf,20);
cb.setTextMatrix(10,10);
cb.showTextAligned(PdfContentByte.ALIGN_CENTER, "hello there", 10,20, 0);
//cb.setLiteral("Helo there how are you");
//document.add(new Phrase("hello there"));
cb.endText();
document.close();
}
catch (Exception de) {
de.printStackTrace();
}
}
}
bruno <[EMAIL PROTECTED]> wrote:murthy gandikota wrote:
> Can someone please tell me how to overlay text on a PDF?
http://article.gmane.org/gmane.comp.java.lib.itext.general/21595/
br,
Bruno
-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Yahoo! Messenger with Voice. PC-to-Phone calls for ridiculously low rates.
Yahoo! Messenger with Voice. PC-to-Phone calls for ridiculously low rates.
