The PDF is correct. A field may have several dictionaries with a parent-child relationship. The merged dictionary has all the fields that are valid for that particular widget. This dictionary is read-only, changes made to it won't go into the document. The flags can and should be put in the widget dictionary.
If it doesn't work, provide a small field example with this pdf.
Best Regards,
Paulo Soares
-----Original Message-----
From: Martin Abrahamsson [SMTP:[EMAIL PROTECTED]
Sent: Tuesday, December 16, 2003 19:06
To: Paulo Soares; [EMAIL PROTECTED] Sourceforge. Net
Subject: SV: [iText-questions] AroFields
Thanks for the reply Paulo.
I have one more question. When I try and compare�merged and widget (see code below) they dont seem to match. (see Output below). A lot of the fields does not apperar in the widget and when i try and set the pdf as read-only the fields that doesn't appear in widget aren't set to read-only. I'm attatching the pdf if you want to look at it. Is it corrupt or not up to the PDFReference? I understand that just because a pdf is shown properly in acrobat doesn't mean it is as it should be... We get the pdfs from a third party so i can't have any influence on them more than delete and remake the problemfields ;-(
�
thanks for any help. The project is supposed to be finished tomorrow.....
Best regards
/Martin
�
---- snip
�
(��form is AcroFielsds� and isSigned ia a boolean for setting the fields as read-only)
�
������� 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;
����������� ArrayList listeM = field.merged;
����������� for (int j = 0; j < listeM.size(); j++) {
��������������� com.lowagie.text.pdf.PdfDictionary dic = (com.lowagie.text.pdf.PdfDictionary)listeM.get(j);
��������������� com.lowagie.text.pdf.PdfDictionary dicSet = (com.lowagie.text.pdf.PdfDictionary)liste.get(j);
��������������� int ff = 0;
��������������� PdfObject pdfobj = dic.get(PdfName.FF);
��������������� PdfObject nameObj = dic.get(PdfName.T);
��������������� PdfObject nameObjSet = dicSet.get(PdfName.T);
��������������� if (nameObj !=null) {
������������������� System.out.println ("Name M: " + nameObj.toString());
��������������� }
��������������� if (nameObjSet !=null) {
������������������� System.out.println ("Name W: " + nameObjSet.toString());
��������������� }
��������������� 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();���
��������������� }
��������������� dicSet.put (PdfName.FF,new PdfNumber(ff));�����������
--- snip
�
---- Output (names of the formFields)
�
Name M: formid
Name W: formid
Name M: 22
Name W: 22
Name M: 21
Name M: 20
Name M: objid
Name W: objid
Name M: boknr
Name W: boknr
Name M: 5_5
Name W: 5_5
Name M: 5_4
Name W: 5_4
Name M: 5_3
Name W: 5_3
Name M: db
Name W: db
Name M: 5_2
Name W: 5_2
Name M: 5_1
Name W: 5_1
Name M: 9
Name M: 8
Name W: 8
Name M: 19
Name W: 19
Value: 4096
Name M: 7
Name M: 18
Name W: 18
Name M: 6
Name W: 6
Value: 4096
Name M: 17
Name M: 702
Name W: 702
Name M: 16
Name W: 16
Name M: 4
Name W: 4
Name M: 701
Name W: 701
Value: 4096
Name M: 15
Name W: 15
Name M: 3
Name M: 14
Name M: 2
Name M: 13
Name M: 1
Name M: 12
Name M: 11
Name W: 11
Name M: 10
Name W: 10
Value: 4096
Name M: 501
Name W: 501
Value: 4096
Name M: boksek
Name W: boksek
Name M: Spara
Name W: Spara
Value: 65536
Name M: personid
Name W: personid
�
�
�
-----Ursprungligt meddelande-----
Fr�n: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]F�r Paulo Soares
Skickat: den 9 december 2003 18:52
Till: Martin Abrahamsson; [EMAIL PROTECTED] Sourceforge. Net
�mne: RE: [iText-questions] AroFields
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 >>
<< File: 7265p1_2.pdf >>
