[ 
https://issues.apache.org/jira/browse/PDFBOX-5797?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17833569#comment-17833569
 ] 

Maruan Sahyoun commented on PDFBOX-5797:
----------------------------------------

I'd need to look into that i.e. if it's correct that we treat that field as a 
PDTerminalField where it should be a PDNonTerminalField. But a kid can be a 
widget and field

> 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

Reply via email to