It's everything working correctly. I found no problems with the radio and check buttons. About the list and combo boxes some explanations are needed. If you have export values those values are in AcroFields.getListOptionDisplay() and AcroFields.getListOptionExport(). Now some examples (the set value is what you get in /V or in getField()).
Combo A-display B-export C-some other value Set A -> show A and the set value will be A Set B -> show A and the set value will be B Set C -> show C and the set value will be C List A-display B-export C-some other value Set A -> show first item in list and the set value will be A Set B -> show A and the set value will be B Set C -> show first item in list and the set value will be C Multi-selection is not supported. Mark Storer contributed code for this but it was done for an old version and TextField changed so much with the Unicode fields that it will have to be all rewriten. Paulo ----- Original Message ----- From: "Roger Misteli" <[EMAIL PROTECTED]> To: "Post all your questions about iText here" <[email protected]> Sent: Tuesday, August 22, 2006 4:22 PM Subject: Re: [iText-questions] FormFields >> Post a small PDF so that the problem can be reproduced. > > File is attached. I have a virtual data structure that basically contains > the name and the value I want to write. The > code basically looks like this: > > class PdfFormField { > String name; > String value; > } > > the data I write is this: > > Writing: Checkbox 2 with value: Wert4 (Off,Wert4,) > Writing: Checkbox with value: Wert2 (Wert3,Off,Wert1,Wert2,Wert4,) > Writing: Text Normal with value: Just some fucking text yup () > Writing: ComboBox with value: Gurken () > Writing: Text RTF with value: Just some fucking text RTF yippieh () > Writing: ListBox single Selection with value: Wert4 () > Writing: ListBox Multi Selection with value: Wert1 () > > (the output is Name, Value (AppearanceStates)) > > and the code I use to write the fields is: > > public static final void saveReport(String serverFileName, File > outputFile, Map<String, PdfFormField> fieldValues, boolean flattenFile) > throws IOException, DocumentException { > PdfReader reader = new PdfReader(serverFileName); > try { > FileOutputStream fos = new FileOutputStream(outputFile); > try { > AcroFields acroFields = reader.getAcroFields(); > boolean hasSignature = (acroFields.getSignatureNames().size() + > acroFields.getBlankSignatureNames().size()) > 0; > PdfStamper stamp = new PdfStamper(reader, fos, '\0', hasSignature); > stamp.setFormFlattening(flattenFile); > try { > AcroFields form = stamp.getAcroFields(); > for (PdfFormField field : fieldValues.values()) { > AcroFields.Item item = form.getFieldItem(field.getName()); > String[] allowed = form.getAppearanceStates(field.getName()); > String appearance = ""; > if (allowed != null) > for (String s: allowed) > appearance += s + ","; > System.out.println("Writing: " + field.getName() + " with > value: " + field.getValue() + " (" + appearance + ")"); > if (item == null) { > System.out.println("Field: " + field.getName() + " cannot be > found!"); > continue; > } > switch (field.getComponentType()) { > case None: > break; > case CheckBox: > case RadioButton: > form.setField(field.getName(), field.getValue()); > break; > case ComboBox: > case List: // How can we treat multiple selections? > form.setField(field.getName(), field.getValue()); > break; > case PushButton: > case Signature: > break; > case Text: > form.setField(field.getName(), field.getValue()); > ArrayList objArrayList = item.widgets; > PdfDictionary dic = (PdfDictionary) objArrayList.get(0); > PdfDictionary action = (PdfDictionary) > PdfReader.getPdfObject(dic.get(PdfName.MK)); > > Color color = field.getColor(); > if (action == null && color != null) { > PdfDictionary d = new PdfDictionary(PdfName.MK); > dic.put(PdfName.MK, d); > > PdfArray f = new PdfArray(new int[] { color.getRed(), > color.getGreen(), color.getBlue() }); > d.put(PdfName.BG, f); > } > } > } > } > finally { > stamp.close(); > } > } > finally { > fos.close(); > } > } > finally { > reader.close(); > } > } > > Best regards and thanks > Rog > > > > /* > * Roger Misteli - ABACUS Research AG > * Just because the system gives you a cliff doesn't mean you have to jump > off it! > */ > > -------------------------------------------------------------------------------- > ------------------------------------------------------------------------- > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job > easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 -------------------------------------------------------------------------------- > _______________________________________________ > iText-questions mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/itext-questions > ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ iText-questions mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/itext-questions
