Hi,

<snip>
….
</snip>

> 
> This is highly confusing. Why can Acrobat deal with those checkboxes when
> their value is null and why can't PDFBox set Checkbox values?
> 
> How can I simply clone all static PDF form entries of a PDF into a new PDF?
> Is PDF really that complex that such a simple thing is not possible? Right
> now, only text form entries are copied, the rest shows null for getValue().

the reason that getValue() returns null is that there is no value entry set for 
the filled out form field (this is held in the field dictionaries /V entry). 
But isChecked() returns true as the checkbox has been checked. This is bases on 
the appearance state of the checkbox.

To give you a quick explanation of that. When a form field is filled out the 
value of the form field has to be filled. But that won't give you any visual 
information. To add the visual information the form field has a annotation 
assigned to it which will have whats's called an appearance. The appearance is 
what's visible on screen or when the pdf is being printed.

Normally an application set the value AND the appearance when the form field is 
filled. In you case the form filling application hasn't set the field value 
(that's why getValue() return null) and ONLY updated the appearance.

So to transfer the value from you original form to the new template you have to 

a) see if getValue() return anything but null. If that is the case use 
setValue() with the value provided by getValue() to fill out the corresponding 
field in your template
b) if getValue() is null check using isChecked() if the checkbox has been 
checked. If this is the case use check() to check the checkbox

We have done some changes to how checkboxes and radio buttons are handled in 
PDFBox 2.0 within the last dates (to make it easier to work with them) so 
please use the latests snapshot version of PDFBox.

There will be an issue with the test template when you set the Name and Prename 
field as the field definition is incomplete (the font resource is missing) 
which will lead to an exception

java.io.IOException: Could not find font: /Courier

The easiest would be to correct the template. If that's not possible we could 
help you building a short workaround. But as the template you provided was only 
a quick mock up and not the real one the final template might not have the 
issue.

If you need further assistance please let us know.

BR
Maruan



> 
> Cheers
> Roberto


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to