You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Venkatesh Prasad <ve...@trv.envestnet.com> on 2009/05/04 17:21:01 UTC

Please help ...

Sir,
 
I have been successful in developing the code to set values to the form-fields of a PDF doument. I have a few questions listed below related to merging of 2 PDF documents as well as about setting fonts. Can someone help?
 
1. I have 3 PDF documents where I have set the form-field values in each of them. I want to combine the 3 PDF documents to create a single PDF document. I have tried the addPage option as well as importPage option but the issue is that the form fields of second and third PDF documents are not visible (or not set) in the combined document.
 
   try {
    PDDocument document = PDDocument.load("test.pdf");
    PDDocument doc = PDDocument.load("test1.pdf");
    List allPages = doc.getDocumentCatalog().getAllPages();
 
    PDPage page = (PDPage)allPages.get(0);
    PDPage page1 = doc.importPage(page);
    document.importPage(page1);
    document.save("parent_1.pdf");
    document.close();
    doc.close();
   } catch (Exception e) {
   }

2. When we set the value of a form field in a PDF document using the setValue option, can I specify the font type and size using which the value needs to be displayed (overriding the font type and size used while creating the control)?
 
This has been my third posting and unfortunately <|:-( there has been no response to the other two! Hope I am lucky with this one! <|:-)
 
Thanks & Regards
 
Venkatesh Prasad.B.K.

RE: Please help ...

Posted by Venkatesh Prasad <ve...@trv.envestnet.com>.
I have found the PDFMergerUtility using which I was able to merge the documents without losing the form-field values in the combined PDF. 
 
    PDFMergerUtility mergePDFs = new PDFMergerUtility();
    mergePDFs.addSource("test.pdf");
    mergePDFs.addSource("test1.pdf");
    mergePDFs.addSource("test2.pdf");
    mergePDFs.addSource("test3.pdf");
    mergePDFs.setDestinationFileName("test_all.pdf");
    mergePDFs.mergeDocuments();
 
The issue with regard to my Point 2 still remains, which I repeat below. We have a case where the name being set for one of the fields in the PDF is longer than the space provided and one solution is to reduce the font size and/or use a different font type. 
 
2. When we set the value of a form field in a PDF document using the setValue option, can I specify the font type and size using which the value needs to be displayed (overriding the font type and size used while creating the control)?
 
Thanks & Regards
 
Venkatesh Prasad.B.K.

________________________________

From: Venkatesh Prasad
Sent: Mon 5/4/2009 8:51 PM
To: pdfbox-users@incubator.apache.org; pdfbox-users@incubator.apache.org
Subject: Please help ...


Sir,
 
I have been successful in developing the code to set values to the form-fields of a PDF doument. I have a few questions listed below related to merging of 2 PDF documents as well as about setting fonts. Can someone help?
 
1. I have 3 PDF documents where I have set the form-field values in each of them. I want to combine the 3 PDF documents to create a single PDF document. I have tried the addPage option as well as importPage option but the issue is that the form fields of second and third PDF documents are not visible (or not set) in the combined document.
 
   try {
    PDDocument document = PDDocument.load("test.pdf");
    PDDocument doc = PDDocument.load("test1.pdf");
    List allPages = doc.getDocumentCatalog().getAllPages();
 
    PDPage page = (PDPage)allPages.get(0);
    PDPage page1 = doc.importPage(page);
    document.importPage(page1);
    document.save("parent_1.pdf");
    document.close();
    doc.close();
   } catch (Exception e) {
   }

2. When we set the value of a form field in a PDF document using the setValue option, can I specify the font type and size using which the value needs to be displayed (overriding the font type and size used while creating the control)?
 
This has been my third posting and unfortunately <|:-( there has been no response to the other two! Hope I am lucky with this one! <|:-)
 
Thanks & Regards
 
Venkatesh Prasad.B.K.