You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Pete Nygaard <pn...@ritehite.com> on 2014/10/24 16:52:26 UTC

Help, values I load in from an FDF file into a PDF are not appearing using PDFbox inportFDF

I am trying to load field values into a PDF template using an FDF file. 
however the values do not appear in the PDF that is saved to the file 
system.
I can open the PDF and manually import the FDF file and the field values 
populate so that tell me the FDF file is formatted correctly. 

The code is not generating any errors.  The PDF fields are empty when I 
open the PDF document.



                                File input = new File(flds[1]);
                                fdf = FDFDocument.load(input); 
                                System.out.println("FDF file loaded");
 
                                PDDocumentCatalog docCatalog = pd
.getDocumentCatalog(); 
                                PDAcroForm acroForm = 
docCatalog.getAcroForm(); 
                                acroForm.setCacheFields( true ); 
                                acroForm.importFDF( fdf );
                                System.out.println("   FDF form imported"
); 
 
                                try { 
                                  pd.save(PDFname);  
                                  System.out.println("Saved file as: " + 
PDFname);
                                  pd.close();
                                  System.out.println(
"--------------------------------");
                                } catch (COSVisitorException e) {  
                                  e.printStackTrace();
                                } 


Pete Nygaard
Sr, Programmer/Analyst
e-mail: pnygaard@ritehite.com



CONFIDENTIALITY NOTICE: This message is from Rite-Hite Holding Corporation and may contain confidential and proprietary information that is intended only for the individual(s) or entities named. If you have received this message in error, please let us know immediately by e-mail reply and delete it from your system. You may not copy this message or disclose its contents to anyone. Rite-Hite reserves the right to monitor messages by authorized Rite-Hite employees at anytime and without further consent.

Re: Help, values I load in from an FDF file into a PDF are not appearing using PDFbox inportFDF

Posted by Maruan Sahyoun <sa...@fileaffairs.de>.
Hi Rajeev,

that won’t help as the issue is with the appearance generation regardless of the way the form data has been loaded. If you populate the form with PDFBox but always view it with Adobe Reader or Acrobat you can set the forms NeedApperances Flag. This will make Reader/Acrobat generate the appearance when the form is loaded.

The font name can be resolved by reading the fields /DA (Default Appearance) value together with the fields resource. 

BR

Maruan

Am 24.10.2014 um 18:48 schrieb Rajeev Menon <ra...@gmail.com>:

> Hi Maruan,
> 
> If we import the FDF file using the method that Pete mentioned above, can
> we get around the long text not auto wrapping issue?
> 
> Is there any way to get the font name from the PDField?
> 
> I can see the fonts used in the PDF using the following code, but not able
> to find what font each field is set to.
> 
>                Map<String,PDFont> pageFonts=page.getResources().getFonts();
>                System.out.println("font
> name:"+pageFonts.get("TT0").getFontDescriptor().getFontName());
> 
> Thanks,
> Rajeev.
> 
> On Fri, Oct 24, 2014 at 12:26 PM, Maruan Sahyoun <sa...@fileaffairs.de>
> wrote:
> 
>> when you click into the field are the values you set via the FDF file
>> visible?
>> 
>> BR
>> Maruan
>> 
>> Am 24.10.2014 um 16:52 schrieb Pete Nygaard <pn...@ritehite.com>:
>> 
>>> I am trying to load field values into a PDF template using an FDF file.
>>> however the values do not appear in the PDF that is saved to the file
>>> system.
>>> I can open the PDF and manually import the FDF file and the field values
>>> populate so that tell me the FDF file is formatted correctly.
>>> 
>>> The code is not generating any errors.  The PDF fields are empty when I
>>> open the PDF document.
>>> 
>>> 
>>> 
>>>                               File input = new File(flds[1]);
>>>                               fdf = FDFDocument.load(input);
>>>                               System.out.println("FDF file loaded");
>>> 
>>>                               PDDocumentCatalog docCatalog = pd
>>> .getDocumentCatalog();
>>>                               PDAcroForm acroForm =
>>> docCatalog.getAcroForm();
>>>                               acroForm.setCacheFields( true );
>>>                               acroForm.importFDF( fdf );
>>>                               System.out.println("   FDF form imported"
>>> );
>>> 
>>>                               try {
>>>                                 pd.save(PDFname);
>>>                                 System.out.println("Saved file as: " +
>>> PDFname);
>>>                                 pd.close();
>>>                                 System.out.println(
>>> "--------------------------------");
>>>                               } catch (COSVisitorException e) {
>>>                                 e.printStackTrace();
>>>                               }
>>> 
>>> 
>>> Pete Nygaard
>>> Sr, Programmer/Analyst
>>> e-mail: pnygaard@ritehite.com
>>> 
>>> 
>>> 
>>> CONFIDENTIALITY NOTICE: This message is from Rite-Hite Holding
>> Corporation and may contain confidential and proprietary information that
>> is intended only for the individual(s) or entities named. If you have
>> received this message in error, please let us know immediately by e-mail
>> reply and delete it from your system. You may not copy this message or
>> disclose its contents to anyone. Rite-Hite reserves the right to monitor
>> messages by authorized Rite-Hite employees at anytime and without further
>> consent.
>> 
>> 


Re: Help, values I load in from an FDF file into a PDF are not appearing using PDFbox inportFDF

Posted by Rajeev Menon <ra...@gmail.com>.
Hi Maruan,

If we import the FDF file using the method that Pete mentioned above, can
we get around the long text not auto wrapping issue?

Is there any way to get the font name from the PDField?

I can see the fonts used in the PDF using the following code, but not able
to find what font each field is set to.

                Map<String,PDFont> pageFonts=page.getResources().getFonts();
                System.out.println("font
name:"+pageFonts.get("TT0").getFontDescriptor().getFontName());

Thanks,
Rajeev.

On Fri, Oct 24, 2014 at 12:26 PM, Maruan Sahyoun <sa...@fileaffairs.de>
wrote:

> when you click into the field are the values you set via the FDF file
> visible?
>
> BR
> Maruan
>
> Am 24.10.2014 um 16:52 schrieb Pete Nygaard <pn...@ritehite.com>:
>
> > I am trying to load field values into a PDF template using an FDF file.
> > however the values do not appear in the PDF that is saved to the file
> > system.
> > I can open the PDF and manually import the FDF file and the field values
> > populate so that tell me the FDF file is formatted correctly.
> >
> > The code is not generating any errors.  The PDF fields are empty when I
> > open the PDF document.
> >
> >
> >
> >                                File input = new File(flds[1]);
> >                                fdf = FDFDocument.load(input);
> >                                System.out.println("FDF file loaded");
> >
> >                                PDDocumentCatalog docCatalog = pd
> > .getDocumentCatalog();
> >                                PDAcroForm acroForm =
> > docCatalog.getAcroForm();
> >                                acroForm.setCacheFields( true );
> >                                acroForm.importFDF( fdf );
> >                                System.out.println("   FDF form imported"
> > );
> >
> >                                try {
> >                                  pd.save(PDFname);
> >                                  System.out.println("Saved file as: " +
> > PDFname);
> >                                  pd.close();
> >                                  System.out.println(
> > "--------------------------------");
> >                                } catch (COSVisitorException e) {
> >                                  e.printStackTrace();
> >                                }
> >
> >
> > Pete Nygaard
> > Sr, Programmer/Analyst
> > e-mail: pnygaard@ritehite.com
> >
> >
> >
> > CONFIDENTIALITY NOTICE: This message is from Rite-Hite Holding
> Corporation and may contain confidential and proprietary information that
> is intended only for the individual(s) or entities named. If you have
> received this message in error, please let us know immediately by e-mail
> reply and delete it from your system. You may not copy this message or
> disclose its contents to anyone. Rite-Hite reserves the right to monitor
> messages by authorized Rite-Hite employees at anytime and without further
> consent.
>
>

Re: Help, values I load in from an FDF file into a PDF are not appearing using PDFbox inportFDF

Posted by Maruan Sahyoun <sa...@fileaffairs.de>.
when you click into the field are the values you set via the FDF file visible?

BR
Maruan

Am 24.10.2014 um 16:52 schrieb Pete Nygaard <pn...@ritehite.com>:

> I am trying to load field values into a PDF template using an FDF file. 
> however the values do not appear in the PDF that is saved to the file 
> system.
> I can open the PDF and manually import the FDF file and the field values 
> populate so that tell me the FDF file is formatted correctly. 
> 
> The code is not generating any errors.  The PDF fields are empty when I 
> open the PDF document.
> 
> 
> 
>                                File input = new File(flds[1]);
>                                fdf = FDFDocument.load(input); 
>                                System.out.println("FDF file loaded");
> 
>                                PDDocumentCatalog docCatalog = pd
> .getDocumentCatalog(); 
>                                PDAcroForm acroForm = 
> docCatalog.getAcroForm(); 
>                                acroForm.setCacheFields( true ); 
>                                acroForm.importFDF( fdf );
>                                System.out.println("   FDF form imported"
> ); 
> 
>                                try { 
>                                  pd.save(PDFname);  
>                                  System.out.println("Saved file as: " + 
> PDFname);
>                                  pd.close();
>                                  System.out.println(
> "--------------------------------");
>                                } catch (COSVisitorException e) {  
>                                  e.printStackTrace();
>                                } 
> 
> 
> Pete Nygaard
> Sr, Programmer/Analyst
> e-mail: pnygaard@ritehite.com
> 
> 
> 
> CONFIDENTIALITY NOTICE: This message is from Rite-Hite Holding Corporation and may contain confidential and proprietary information that is intended only for the individual(s) or entities named. If you have received this message in error, please let us know immediately by e-mail reply and delete it from your system. You may not copy this message or disclose its contents to anyone. Rite-Hite reserves the right to monitor messages by authorized Rite-Hite employees at anytime and without further consent.