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

Maruan Sahyoun edited comment on PDFBOX-2849 at 7/1/15 1:15 PM:
----------------------------------------------------------------

There need to be some more changes to check boxes as the current implementation 
assumes that the On value is always COSName.Yes. As the spec has a 'should' for 
that we can't rely on that. I propose that we 
- change getValue/getDefaultValue to return the actual value as string
- allow setValue/setDefaultValue to use an (arbritary) string and throw an 
IllegalArgumentException if the value doesn't match the potential values
- adjust check/uncheck/isChecked accordingly
- add getSelectableValues() to return a list of possible options

In another step we need to deal with fields where there is no appearance 
defined (which shouldn't be the case for properly defined fields)

WDYT? 


was (Author: msahyoun):
There need to be some more changes to check boxes as the current implementation 
assumes that the On value is always COSName.Yes. As the spec has a 'should' for 
that we can't rely on that. I propose that we 
- change getValue/getDefaultValue to return the actual value
- allow setValue/setDefaultValue to use an (arbritary) string and throw an 
IllegalArgumentException if the value doesn't match the potential values
- adjust check/uncheck/isChecked accordingly
- add getSelectableValues() to return a list of possible options

In another step we need to deal with fields where there is no appearance 
defined (which shouldn't be the case for properly defined fields)

WDYT? 

> implement appearance generation for buttons
> -------------------------------------------
>
>                 Key: PDFBOX-2849
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-2849
>             Project: PDFBox
>          Issue Type: Sub-task
>          Components: AcroForm
>    Affects Versions: 2.0.0
>            Reporter: Tilman Hausherr
>             Fix For: 2.0.0
>
>         Attachments: TestTemplate.pdf
>
>
> This code
> {code}
> PDField newField = 
> tplDoc.getDocumentCatalog().getAcroForm().getField("01.20.Entry1");
> PDCheckbox newCheckBoxField = (PDCheckbox) newField;
> newCheckBoxField.check();
> {code}
> brings this exception:
> {code}
> Exception in thread "main" java.lang.UnsupportedOperationException: not 
> implemented
>       at 
> org.apache.pdfbox.pdmodel.interactive.form.PDButton.constructAppearances(PDButton.java:225)
>       at 
> org.apache.pdfbox.pdmodel.interactive.form.PDTerminalField.applyChange(PDTerminalField.java:220)
>       at 
> org.apache.pdfbox.pdmodel.interactive.form.PDCheckbox.setValue(PDCheckbox.java:128)
>       at 
> org.apache.pdfbox.pdmodel.interactive.form.PDCheckbox.check(PDCheckbox.java:71)
> {code}
> what did work is this:
> {code}
> newCheckBoxField.getCOSObject().setItem(COSName.V, vValue);
> newCheckBoxField.getCOSObject().setItem(COSName.AS, asValue);
> {code}



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

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

Reply via email to