Get the flags value from the merged array and set it in the widget.
Best Regards,
Paulo Soares
-----Original Message-----
From: [EMAIL PROTECTED] [SMTP:[EMAIL PROTECTED] On Behalf Of Martin Abrahamsson
Sent: Monday, December 08, 2003 16:58
To: [EMAIL PROTECTED] Sourceforge. Net
Subject: [iText-questions] AroFields
Hi
�
I'm having trouble with setting Formfields as non scrollable and/or read only. I have an existing pdf with some formfields (multiline and singleline) that I want to set as non scrolable and if the pdf is marked as signed as read only as well. In the pdf (attached) the first multiline-field on the top left, with no borders around it (field-name=501),�is treated correctly but the second one on the top right (field-name=5)�is not. There are two more multilinefields further down the doc�(field-names=6 and 10) are that's�not working correctly either.�Does anyone have a clue?. Is the original pdf corrupt or am I doing something wrong here? (code below)
thanks for any help
/Martin Abrahamsson
�
�
public void generateDemo (OutputStream stream,String formName, boolean isSigned) throws Exception {
�
// formName = 7265p1_2.pdf
������
��� PdfReader reader = new PdfReader (formName);
�
��� PdfStamper stamper = new PdfStamper (reader,stream);
��� PdfContentByte cb = stamper.getOverContent(1);
��� AcroFields form = stamper.getAcroFields();
���
��� HashMap fieldsMap = form.getFields ();
��� Collection col = fieldsMap.values();
��� Object[] objArr = col.toArray();
�
��� for (int i = 0; i< objArr.length; i++) {
������� com.lowagie.text.pdf.AcroFields.Item field = (com.lowagie.text.pdf.AcroFields.Item)objArr[i];
������� ArrayList liste = field.widgets;
�
������� for (int j = 0; j < liste.size(); j++) {
����������� com.lowagie.text.pdf.PdfDictionary dic = (com.lowagie.text.pdf.PdfDictionary)liste.get(j);
����������� int ff = 0;
����������� PdfObject pdfobj = dic.get(PdfName.FF);
����������� if (pdfobj !=null && pdfobj.type() == PdfObject.NUMBER) {
��������������� ff = new Integer (pdfobj.toString()).intValue();
��������������� System.out.println ("Value: " + ff);
����������� }
�
����������� if (ff == PdfFormField.FF_MULTILINE) {
��������������� ff += new PdfNumber(PdfFormField.FF_DONOTSCROLL).intValue();
����������� }
�����������
����������� if (isSigned) {
��������������� ff += new PdfNumber(PdfFormField.FF_READ_ONLY).intValue();���
����������� }
����������� dic.put(PdfName.FF,new PdfNumber(ff));�����������
������� }
��� }
�
��� stamper.close();
}
--------------------------------------------
Martin Abrahamsson
Sigma Kommun & Landsting AB
Dockplatsen 1
211 19 Malm�
+46-703-791393
[EMAIL PROTECTED]
www.sigma.se
--------------------------------------------
�
<< File: 7265p1_2.pdf >>
