Has anyone used iText to list all fields on a PDF AcroForm?
There are plenty of java examples to do it, but I do not know how to
translate that into ruby. I’m using Rjb.
The Java example I’ve found is:
AcroFields form = reader.getAcroFields();
HashMap fields = form.getFields();
String key;
for (Iterator i = fields.keySet().iterator(); i.hasNext(); ) {
key = (String) i.next();
System.out.print(key + ": ");
switch(form.getFieldType(key)) {
case AcroFields.FIELD_TYPE_CHECKBOX:
System.out.println(“Checkbox”);
break;
case… (other types)
}
}
Here is the complete code. The big hangup was the .to_string. I kept
trying to use .to_s thinking Rjb would translate for me. NOT!
Note that the output can be cut and pasted into a db migration file.
*------------------------------------------------------------------------
class ListfieldsController < ApplicationController