One more weird thing happening with the code that is meant to copy application.pdf onto app2.pdg is the file sizes are different. The application.pdf is 71826 bytes. Whereas app2.pdf is only 70348 bytes long!!!!

rw-r--r--    1 mgandikota dba         70348 May 10 14:02 app2.pdf
-rw-r--r--    1 mgandikota dba         71826 May  9 11:21 application.pdf

I don't see "hello there" printed anywhere. My objective is to move to
a certain position in the form and print "hello" or whatever that makes
sense. I want to do this way given that the application.pdf does not contain
any fields. I am not in a position to regenerate this document with fields.
I'd appreciate your help
Thanks
Murthy
murthy gandikota <[EMAIL PROTECTED]> wrote:
Sorry the correct web site is
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.


New Yahoo! Messenger with Voice. Call regular phones from your PC and save big.

Reply via email to