hi,
i get pdf-forms from an external source and have to transform the
forms to a xml format (fieldname -> value) which up to now was no problem.
but the crators of the pdf-forms do an inconsistent job with assigning
string values to pdf-
checkboxes...
often getAppearanceStates is [0] -> "Ja", [1] -> "Off" but sometimes its
[0] -> "", [1] -> "Off" so
every type of questionaire pdf would have to be checked for irregulatitys
on all checkbox states before
converting into xml.... :/
question is: can i ignore the creators string assignments by simply
checking if the checkbox
is *checked* so i can assign my own values like "true" and "false"?
# little code to see if a field is a checkbox and
# the creators assigned values for checked and undchecked
public boolean ParsePDF() {
fieldsHashMapStrings = new HashMap();
AcroFields acroFields = pdfReader.getAcroFields();
HashMap<String, Item> fieldsHashMap = acroFields.getFields();
for (Iterator i = fieldsHashMap.keySet().iterator(); i.hasNext();)
{
String key = i.next().toString();
String value = "";
if (acroFields.getField(key) != null) {
if (acroFields.getFieldType(key) ==
AcroFields.FIELD_TYPE_CHECKBOX) {
System.out.println(key + " is checkbox");
String[] appearanceStates =
acroFields.getAppearanceStates(key);
for (int j = 0; j < appearanceStates.length; j++) {
String string = appearanceStates[j];
System.out.println(j+"->"+string);
}
} else {
value = acroFields.getField(key).toString();
}
}
fieldsHashMapStrings.put(key, value);
}
return true;
}
# sample output
...
GefB_ang is checkbox
0->Ja
1->Off
AnfProfil_Z_nein is checkbox
0->Ja
1->Off
Sibe_intern is checkbox
0-> ############ HERE the ARGH!
1->Off
PSA_nein is checkbox
0->Ja
1->Off
....
Mit freundlichen Grüßen
Christoph Mikusch
Berufsgenossenschaft Nahrungsmittel und Gaststätten
Dynamostraße 7 - 11
68165 Mannheim
Telefon: +49 (0) 621 4456-3127
Mail: [email protected]
Internet: www.bgn.de
------------------------------------------------------------------------------
Centralized Desktop Delivery: Dell and VMware Reference Architecture
Simplifying enterprise desktop deployment and management using
Dell EqualLogic storage and VMware View: A highly scalable, end-to-end
client virtualization framework. Read more!
http://p.sf.net/sfu/dell-eql-dev2dev
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Many questions posted to this list can (and will) be answered with a reference
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples:
http://itextpdf.com/themes/keywords.php