You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Shadrack (JIRA)" <ji...@apache.org> on 2017/06/22 08:59:00 UTC

[jira] [Updated] (PDFBOX-3837) PDFBox does not maintain the font appearence of a field if it appears severraly in a PDF Form

     [ https://issues.apache.org/jira/browse/PDFBOX-3837?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Shadrack updated PDFBOX-3837:
-----------------------------
    Description: 
I have 5 fields with same name(lets say 'wcode') in different places on a one page pdf form. This fields have different fonts. Normally when you fill out one field manually the other fields automatically pick the sames value, the same this happens when I fill it using PDFbox except that PDFBox changes all my 5 fields to have same font as the first field to appear in the pdf form.

Here is the code used to fill the field.

{code:java}
PDDocument _pdfDocument = PDDocument.load(new File(originalPdf))
PDAcroForm acroForm = _pdfDocument.getDocumentCatalog().getAcroForm();    
PDTextField myCodeField = (PDTextField) acroForm.getField("wcode");
       if (myCodeField != null) {
          myCodeField .setValue(my.getCode());
       }
//Refresh layout && Flatten the document                
       acroForm.refreshAppearances();
       acroForm.flatten();
 _pdfDocument.save(outputFile);

{code}

I added
    acroForm.refreshAppearances();
after some research but that did not change anything.

So if the first 'wcode' field to appear on the pdf form is 6pt all the other 'wcode' fields in the rest the pdf will be 6pt even if I had set them in appearance properties to 12pt.

On the attached pdf the affected field is called CountyCode

  was:
I have 5 fields with same name(lets say 'wcode') in different places on a one page pdf form. This fields have different fonts. Normally when you fill out one field manually the other fields automatically pick the sames value, the same this happens when I fill it using PDFbox except that PDFBox changes all my 5 fields to have same font as the first field to appear in the pdf form.

Here is the code used to fill the field.

PDDocument _pdfDocument = PDDocument.load(new File(originalPdf))
PDAcroForm acroForm = _pdfDocument.getDocumentCatalog().getAcroForm();    
PDTextField myCodeField = (PDTextField) acroForm.getField("wcode");
       if (myCodeField != null) {
          myCodeField .setValue(my.getCode());
       }
//Refresh layout && Flatten the document                
       acroForm.refreshAppearances();
       acroForm.flatten();
 _pdfDocument.save(outputFile);


I added
    acroForm.refreshAppearances();
after some research but that did not change anything.

So if the first 'wcode' field to appear on the pdf form is 6pt all the other 'wcode' fields in the rest the pdf will be 6pt even if I had set them in appearance properties to 12pt.

On the attached pdf the affected field is called CountyCode


> PDFBox does not maintain the font appearence of a field if it appears severraly in a PDF Form
> ---------------------------------------------------------------------------------------------
>
>                 Key: PDFBOX-3837
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-3837
>             Project: PDFBox
>          Issue Type: Bug
>          Components: AcroForm
>    Affects Versions: 2.0.5
>         Environment: java web application running on ubutnu 14 and windows 10.
>            Reporter: Shadrack
>         Attachments: countycode.pdf
>
>
> I have 5 fields with same name(lets say 'wcode') in different places on a one page pdf form. This fields have different fonts. Normally when you fill out one field manually the other fields automatically pick the sames value, the same this happens when I fill it using PDFbox except that PDFBox changes all my 5 fields to have same font as the first field to appear in the pdf form.
> Here is the code used to fill the field.
> {code:java}
> PDDocument _pdfDocument = PDDocument.load(new File(originalPdf))
> PDAcroForm acroForm = _pdfDocument.getDocumentCatalog().getAcroForm();    
> PDTextField myCodeField = (PDTextField) acroForm.getField("wcode");
>        if (myCodeField != null) {
>           myCodeField .setValue(my.getCode());
>        }
> //Refresh layout && Flatten the document                
>        acroForm.refreshAppearances();
>        acroForm.flatten();
>  _pdfDocument.save(outputFile);
> {code}
> I added
>     acroForm.refreshAppearances();
> after some research but that did not change anything.
> So if the first 'wcode' field to appear on the pdf form is 6pt all the other 'wcode' fields in the rest the pdf will be 6pt even if I had set them in appearance properties to 12pt.
> On the attached pdf the affected field is called CountyCode



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org