You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Maruan Sahyoun (JIRA)" <ji...@apache.org> on 2016/06/21 09:45:58 UTC

[jira] [Commented] (PDFBOX-3391) PDButton.getOnValues seems to be using the wrong source for getting the allowed values

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

Maruan Sahyoun commented on PDFBOX-3391:
----------------------------------------

PDFBox behavior is to look up the name definition for the different button states where iText is looking up the Opt definition if that exists. So achieving something similar in PDFBox you'd have to look up the index of the value you are trying to set in the Opt array and use that index (starting with 0) to set the value. So that is not a bug in PDFBox but a different approach. But In order to make that easier to handle I'll change the behavior to do the lookup in the Opt array is that exists and take that as an accepted value. 

> PDButton.getOnValues seems to be using the wrong source for getting the allowed values
> --------------------------------------------------------------------------------------
>
>                 Key: PDFBOX-3391
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-3391
>             Project: PDFBox
>          Issue Type: Improvement
>          Components: AcroForm
>    Affects Versions: 2.0.1
>            Reporter: Scott Coldwell
>            Assignee: Maruan Sahyoun
>             Fix For: 2.0.3, 2.1.0
>
>         Attachments: SF2817.pdf
>
>
> We are in the process of migrating from itext to pdfbox and noticed that an exception was being thrown when trying to set a radio button with PDField.setValue().  The values returned from PDButton.getOnValues() which is used by PDButton.checkValue() called from PDButton.setValue() are only returning 0,1 instead of what we had been using with itext.  After investigating itext's source code and playing around with pdfbox I was able to get to what I believe are the appropriate allowed values by using the following code.
> {code}
>         if (field instanceof PDButton)
>         {
>             final COSBase item = field.getCOSObject().getItem(COSName.OPT);
>             if (item != null && item instanceof COSArray)
>             {
>                 final COSArray optArray = (COSArray)item;
>                 for (int i = 0 ; i < optArray.size() ; i++)
>                 {
>                     // Each item in this array is an allowed value
>                     // optArray.getString(i);
>                 }
>             }
>         }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

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