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

Maruan Sahyoun commented on PDFBOX-1750:
----------------------------------------

For the two issues described:

- as the field type is an inheritable attribute it’s not necessary to set it 
with the field if one of the ancestors has the value set
- if the field represents a non terminal field, for which we don’t have a 
special type in PDFBox 1.x, is might not have a widget associated

As there is an easy workaround, which is to add the information specifically, 
I’d propose that we don’t address this in 1.8.x.

For 2.x I’d suggest that we make it easier to create form fields so it’s 
possible to generate a new field quickly. Something like

{code}
PDTextbox = new PDTextbox(String fieldName, PDRectangle fieldBox)
{code}

WDYT?

> PDTextbox and PDAnnotationWidget are not correct initialized from it's own 
> constructor .
> ----------------------------------------------------------------------------------------
>
>                 Key: PDFBOX-1750
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-1750
>             Project: PDFBox
>          Issue Type: Bug
>          Components: AcroForm
>    Affects Versions: 1.8.2
>            Reporter: chen zhenyu
>              Labels: AcroForm, Widget
>
> I find 2 Bugs in interactive.form, And I have resolved this 2 Bug. Here are 
> the Code
> 1.     I want make new Textbox in pdf. It always failed because the type flag 
>  “COSName.FT,="Tx"” never be set in the constructor. 
> The PDTextbox can only be correct initialized from COSDictionary.( That is 
> only initialized from exist pdf file) .
> I fixed this by add “getDictionary().setName(COSName.FT, "Tx");” in the 
> constructor of PDTextbox. 
> Maybe it’s not right place, but works in my project. 
> public PDTextbox( PDAcroForm theAcroForm )
>     {
>         super( theAcroForm );
>         getDictionary().setName(COSName.FT, "Tx");
> }
> public PDTextbox( PDAcroForm theAcroForm, COSDictionary field)
>   {
>         super( theAcroForm, field);
>         getDictionary().setName(COSName.FT, "Tx");
>   }
> 2.    Same Bug in PDAnnotationWidget. Only the default constructor initialize 
> the type flag  “COSName.SUBTYPE,= "Widget"”. 
> But the default constructor were never be used. So I must use the 
> PDAnnotationWidget to initialize the new PDTextbox, like blow.
> PDAnnotationWidget Widget = new PDAnnotationWidget();
> PDTextbox textBox = new PDTextbox(acroForm,Widget.getDictionary());
> Otherwise I got an empty  PDAnnotationWidget from PDTextbox .getWidget().
> Something not correct in PDField .getWidget(). 
> If the the PDField create from user(not read from exist pdf file), the 
> getWidget cannot get an correct initialized PDAnnotationWidget. The 
> COSName.SUBTYPE will never be set.
> Maybe the similar Bug in the whole 
> org.apache.pdfbox.pdmodel.interactive.form: the COSDictionary  of element are 
> not initialized when user create it manually (Typical to insert new acroform  
> element).
> I hope  that I can give  something help  to this opensource Project.
> Could you check this and fix in next Version?



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to