[
https://issues.apache.org/jira/browse/PDFBOX-3752?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Maruan Sahyoun resolved PDFBOX-3752.
------------------------------------
Resolution: Fixed
setting to resolved [~leo.herbie] if there are still issues please reopen
> PDVariableText text color changes to be the same as the background color
> after flattening
> -----------------------------------------------------------------------------------------
>
> Key: PDFBOX-3752
> URL: https://issues.apache.org/jira/browse/PDFBOX-3752
> Project: PDFBox
> Issue Type: Bug
> Components: AcroForm
> Affects Versions: 2.0.5
> Reporter: Travis Schneeberger
> Assignee: Maruan Sahyoun
> Fix For: 2.0.6, 3.0.0
>
> Attachments: fdpAttachment2-example-flattened.pdf,
> fdpAttachment2-example-not-flattened.pdf, fdpAttachment2.pdf
>
>
> PDVariableText text color changes to be the same as the background color
> after flattening. This effectively makes the text hidden and appear to be
> lost.
> This includes field types such as ListBox and TextField. I don't believe I
> have tested a combo box.
> For example:
> {code}
> try(PDDocument pdfDocument = PDDocument.load(new
> File("/Users/travis/Desktop/fdpAttachment2.pdf"))) {
> final PDDocumentCatalog docCatalog =
> pdfDocument.getDocumentCatalog();
> final PDAcroForm acroForm = docCatalog.getAcroForm();
> final PDField textField = acroForm.getField("Subaward Number");
> textField.setValue("12345");
> final PDField listBoxField = acroForm.getField("Contact for
> carryforward");
> listBoxField.setValue("Administrative Contact");
> //when flattening with refreshAppearances, a NPE will occur if
> each widget doesn't have a
> //PDAppearanceDictionary instance with a normal PDAppearanceEntry
> instance set PDFBOX-3751
> pdfDocument.getDocumentCatalog().getAcroForm().getFields()
> .stream()
> .flatMap(f -> f.getWidgets().stream())
> .filter(w -> w.getAppearance() == null)
> .forEach(w -> {
> final PDAppearanceDictionary appearance = new
> PDAppearanceDictionary(new COSDictionary());
> appearance.setNormalAppearance(new
> PDAppearanceEntry(new COSDictionary()));
> w.setAppearance(appearance);
> });
> pdfDocument.getDocumentCatalog().getAcroForm().flatten(pdfDocument.getDocumentCatalog().getAcroForm().getFields(),
> true);
>
> pdfDocument.save("/Users/travis/Desktop/fdpAttachment2-example-flattened.pdf");
> }
> {code}
> Notice in the attached fdpAttachment2-example-flattened.pdf, the fields are
> correctly set but the text is not visible.
> If I execute the same code but do not flatten, the text is visible for
> certain field types in certain pdf viewers. See attached
> fdpAttachment2-example-not-flattened.pdf
> In Adobe Acrobat Reader DC build 15.23.20056.213124 the "Subaward Number"
> field shows up but only when clicking on the field. When using the Preview
> app in MacOS Sierra, it is visible. In both apps the "Contact for
> carryforward" list box shows the text "Administrative Contact"
> As a side note I wonder if the behavior of the "Subaward Number" in relation
> to different pdf views may be related to a difference problem. I think the
> real issue here is the text color.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]