----- Original Message -----
From: "Finn Bock" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, October 07, 2003 21:46
Subject: [iText-questions] Problems with hidden fields.


> Hi,
>
> I've found that adding a long (>127) value as a hidden field, will throw
>
> a NullPointerException from within PdfName.
>
> Exception in thread "main" java.lang.NullPointerException
>          at com.lowagie.text.pdf.PdfName.<init>(PdfName.java:782)
>          at com.lowagie.text.pdf.PdfFormField.setValueAsName()
>          at com.lowagie.text.pdf.PdfAcroForm.addHiddenField()
>          at tst03.main(tst03.java:18)
>
> I think this is due to a typo in the PdfName constructor where the
> message string for the IllegalArgumentException is created.
>
> Attached is a small testcase tst03.java and an even smaller patch that
> fixes the NPE (and throws the correct exception).
>
>

Thanks for the fix.

>
> At a higher level, I wonder why hidden field values are added as a
> PdfName instead of a PdfString? I realize that I can added the value as
> a string myself:
>
>          PdfFormField f = PdfFormField.createEmpty(writer);
>          f.setFieldName("hidden");
>          f.setValueAsString("...");
>          acroForm.addFormField(f);
>
> but perhaps using a Name is a deliberate choice?
>
>

This is not really an hidden field, it's more like an empty field. It
doesn't have a box or field type. The value can be anything as there's no
type.

>
> Either way, if my document contains a single hidden field and no other
> fields, it appears that iText does not write the AcroForm dict into the
> document. The attached program tst05.java shows this problem.
>
> I'm guessing that the PdfAcroForm.isValue() should return true even when
>
> there is no fieldTemplates. In that case the /DR and /DA entries should
> not be added to the AcroForm object.
>

You're right. Fields without appearances should also be output.

Best Regards,
Paulo Soares

> regards,
> finn
>
>



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to