[ https://issues.apache.org/jira/browse/PDFBOX-5797?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17833559#comment-17833559 ]
Maruan Sahyoun commented on PDFBOX-5797: ---------------------------------------- If I'm not mistaken a /DA entry is specific to a field dictionary and not a widget dictionary (with both dictionaries optionally being merged into a single dictionary). This means that the kid is not only a widget but also a field. The proposed change would overwrite that maybe as intended in that case but maybe not in others. > Kid Widget /DA is ignored in setDefaultAppearance() call > -------------------------------------------------------- > > Key: PDFBOX-5797 > URL: https://issues.apache.org/jira/browse/PDFBOX-5797 > Project: PDFBox > Issue Type: Bug > Components: AcroForm > Affects Versions: 2.0.31, 3.0.2 PDFBox > Reporter: Tilman Hausherr > Priority: Major > Attachments: seija.pdf > > > See attached SO question, the field has one widget as kid with its own /DA > entry. PDFBox only sets the field /DA entry but AppearanceGeneratorHelper > will consider widget /DA entries too, which can result in the problem > described in the SO question when only the field /DA entry gets changed. > Test code: > {code:java} > PDDocument doc = Loader.loadPDF(new File("seija.pdf")); > PDAcroForm acroForm = doc.getDocumentCatalog().getAcroForm(); > PDFont font = PDType0Font.load(doc, new > FileInputStream("c:/windows/fonts/arial.ttf"), false); > PDResources resources = acroForm.getDefaultResources(); > String fontName = resources.add(font).getName(); > PDVariableText field = (PDVariableText) acroForm.getField("main_text"); > field.setDefaultAppearance(field.getDefaultAppearance() > .replaceAll("/\\w+", "/" > + fontName)); > field.setValue("Ahoj světe"); > {code} > Proposed solution in PDVariableText: > {code:java} > public void setDefaultAppearance(String daValue) > { > getCOSObject().setString(COSName.DA, daValue); > if (getCOSObject().containsKey(COSName.KIDS)) > { > for (PDAnnotationWidget widget : getWidgets()) > { > COSDictionary widgetDict = widget.getCOSObject(); > if (widgetDict.containsKey(COSName.DA)) > { > widgetDict.setString(COSName.DA, daValue); > } > } > } > } > {code} -- This message was sent by Atlassian Jira (v8.20.10#820010) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@pdfbox.apache.org For additional commands, e-mail: dev-h...@pdfbox.apache.org