All: We are using the latest version of iTextSharp and have an issue that is perplexing us. We are generating an Acroform with some fields ... all kinds of fields. See attached example of one sample generated PDF.
The problem exists only in fields marked as "read only" and further the
problem only seems to occur when displayed in Adobe Reader (not other PDF
viewers). When displayed with Adobe Reader, these fields do not appear as
visible but the fields are there as confirmed if submitting the form
information to our server or examining the PDF.
The same code is used for regular textbox (works fine), password (works
fine). If default values exist, they are shown in the PDF. But when setting
a Field Flag of "PdfFormField.FF_READ_ONLY", the default value is not
visible in the form. We think the code works because:
A) it works for all other cases
B) totally works in other viewers (The same PDF when viewed in FoxIt shows
the field exactly as expected with the field contents as read only.)
A sample PDF is attached showing this behavior. There is a field in the
table marked as FF_READ_ONLY after the cell labeled "Simple Reader Only
Textbox". The field contains the text "Cannot change contents" and the field
exists and has this value (confirmed by submitting to our server -- will
work with XFDF submit only from Adobe Reader, not an FDF submit from other
products).
The question is:
a) Is this a "your code is all wrong" problem (likely :)
b) Is this an Adobe Reader bug? (we tried and can create read-only fields
with Acrobat)
c) Is this an iTextSharp bug?
Kevin Brown
Code sample:
If the following case statement is called with "f_readonly" as "true", then
the PDF contains the field but no default value is visible (in Adobe Reader
only). If it is called with f_readonly as "false" or "f_type" as password,
the field works perfectly in Adobe Reader.
case "password":
case "textbox":
tp = cb.CreateAppearance(urx - llx, ury - lly);
da = (PdfAppearance)tp.Duplicate;
field = PdfFormField.CreateTextField(writer, false, false, 0);
field.SetWidget(new iTextSharp.text.Rectangle(llx, lly, urx, ury),
PdfAnnotation.HIGHLIGHT_INVERT);
setBordersAndColors(field, f_borderstyle, f_bordersize, f_bordercolor,
f_backcolor);
field.FieldName = f_name;
da.SetFontAndSize(setFont(formfontfam, formfontstyle, formfontweight),
Convert.ToSingle(formfontsize));
if (formfontcolor.StartsWith("#"))
da.SetColorFill(new
iTextSharp.text.Color(HexToColor(formfontcolor)));
else
da.SetColorFill(new
iTextSharp.text.Color(System.Drawing.Color.FromName(formfontcolor)));
field.DefaultAppearanceString = da;
if (f_default.Length > 0)
field.ValueAsString = f_default;
if (f_type == "password")
field.SetFieldFlags(PdfFormField.FF_PASSWORD);
if (f_readonly == "true")
field.SetFieldFlags(PdfFormField.FF_READ_ONLY);
field.SetPage();
acroform.AddFormField(field);
break;
FormTest0001.xml.form.pdf
Description: Adobe PDF document
------------------------------------------------------------------------------ Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise -Strategies to boost innovation and cut costs with open source participation -Receive a $600 discount off the registration fee with the source code: SFAD http://p.sf.net/sfu/XcvMzF8H
_______________________________________________ iText-questions mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://www.1t3xt.com/docs/book.php
