Discussions

XML & Web services: Inserting text to existing PDF file

  1. Inserting text to existing PDF file (21 messages)

    I have a PDF File that contains fields ID,name etc, one below the other. The user details from web page(or XML) are to be inserted against the appropriate fields in PDF files. I tried inserting texts using Itext Software for PDf. But it overwrites the existing file and is not suitable to my needs. Can anybody suggest a solution on how to insert texts at appropriate place without overwriting existing PDF file using JSP.

    Threaded Messages (21)

  2. I don't know of any easy way to do this. PDF is designed to be a platform-independent printing specification, not a data-storage format.

    I strongly suggest you store your data in something other than a PDF (XML is good), then use some other utility (say XSL-FO) to convert your data to PDF as needed.

    If you absolutely must do things the hard way (because you don't have control over the data format), the best you can do is directly hack the contents of the PDF file. This is going to be very ugly and very error prone. Check out:

    http://partners.adobe.com/asn/tech/pdf/specifications.jsp
  3. Thanks for information[ Go to top ]

    Thanks for the information. But to tell the truth I thought that the response will be different. As for meI adore reading. Very often I find books that are worth reading in pdf format (maybe because I use this pdf seach engine http://pdf.rapid4me.com but it's very nice and it can find any book I want). Of course I can't read without making notes. That is why I needed a positive response so much.
  4. A pdf editor[ Go to top ]

    if you want to fill in a pdf form, you can use a Pdf editor to add text to pdf file. Because it has a form-filling mode to automatically detect blanks  or check box then you can write on it as you want. And save all the added text in original PDF file with a click.  It's very convenient!

  5. you can read some precise info from here: http://www.convertpdf.org/add-text-to-pdf.html

  6. taking notes on a pdf file[ Go to top ]

    copy paste into another format, or print and take notes the old fashioned way?

  7. iText PdfReader[ Go to top ]

    Use iText

    http://www.mail-archive.com/itext-questions at lists dot sourceforge dot net/msg06170.html

    http://www.lowagie.com/iText/tutorial/ch13.html
  8. Basic iText Example[ Go to top ]

    This will take an existing PDF called "somePDF.pdf" read the file, then add content to the fields in the PDF, then write the file to a new file called "aNewPDF.pdf". This is the most basic form of this method. For instance if the field names are unknown you can get a list of all field names and iterate through them. If you wish to combine pdfs into a single document you can. As I said this is just a bit of basic code.

    import com.lowagie.text.pdf.*;
    import com.lowagie.text.DocumentException;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    import java.util.*;

    //Insert the following into a servlet or adapt it to a standard java class
        ServletContext context = getServletContext();
            
        //get a handle to the file location
        templatePath = context.getRealPath("/SomeDirectory");

        
        if(templatePath == null)
            {templatePath = File.separator;}
        else if(!templatePath.endsWith(File.separator))
            {templatePath += File.separator;}

    //Reads in the pdf Template
    PdfReader reader = new PdfReader(templatePath + "somePDF.pdf ");
        
    try
        {
        PdfStamper stamp = new PdfStamper(reader, new FileOutputStream("aNewPDF.pdf"));
        AcroFields form = stamp.getAcroFields();
                    
        //set the field values in the pdf form
        form.setField("fieldName","aValue");
        ...etc...
        ...etc...
                    
        stamp.setFormFlattening(true);
        stamp.close();}
                    
    catch(Exception e)
        {System.out.println("Error: " + e);}
  9. This is a nice example to explan how to insert text into pdf template file. In thie example, it make a new pdf file that is not I want. My requirement is to insert data into pdf template file and make a new pdf datastream and response to WEB http via servlet... I think it just need to change a little bit. But I have no idea how to do. Does anyone who can answer my question?
  10. How to do this with Web Application.[ Go to top ]

    Instead of using a File OutputStream use a ByteArrayOutputStream and get the bytes from the ByteArrayOutputStream
  11. pdf[ Go to top ]

    Simon, I appreciate the codes you shared here regarding text insertion in pds files

    sell sheet design

  12. inserting text into pdfs[ Go to top ]

    has anyone got the solution for this problem.
  13. iText is a library that allows you to generate PDF files on the fly. Please find more details on iText on below link.
    http://www.lowagie.com/iText/

    Here is a code snippet which takes multiple PDFs stream as input and merging them to a new PDF file


    Hope it did answer your question
  14. Thanks![ Go to top ]

    Thanks a lot the last comment helped me a great deal!

  15. PDF is largely based on PostScript but simplified to remove flow control features like these, while graphics commands such as lineto remain. Thanks.

    Regards,

    law school personal statement ideas

  16. PDF is largely based on PostScript but simplified to remove flow control features like these, while graphics commands such as lineto remain. Thanks.

    Regards,

    law school personal statement ideas

  17. thx. really helped me this topic. urologie

  18. there is any way to add a video to a pdf document? thx finisaje

  19. video[ Go to top ]

    yes a video tutorial would be helpful to further explain SOA

    monroe dimaggio

  20. Of course it is possible. but i suggest you'd better choose some tools . have you ever tried someone. if not, i want to recommend a professional PDF Plugin i've used before. it is pretty a genius. i believe you can add page numbers and consecutive numbers in locked PDF documents with the help of it. you can also other free trials of Yiigo. to deal with different files of documents, images, and barcodes. i wish i've offered a good choice for you. Bset Regards Arron
  21. convert[ Go to top ]

    Couldn't you just convert it to .docx and then back to .pdf
  22. pdf[ Go to top ]

    i hate editing  PDF! learn to bartend