modified output so it can be used properly by shell_exec()
This commit is contained in:
@@ -8,54 +8,31 @@ import org.apache.pdfbox.pdmodel.interactive.form.PDField;
|
||||
|
||||
public class Tsc {
|
||||
|
||||
public static void listFields(PDDocument doc) throws Exception {
|
||||
PDDocumentCatalog catalog = doc.getDocumentCatalog();
|
||||
PDAcroForm form = catalog.getAcroForm();
|
||||
List<PDField> fields = form.getFields();
|
||||
public static void listFields(PDDocument doc) {
|
||||
PDDocumentCatalog catalog = doc.getDocumentCatalog();
|
||||
PDAcroForm form = catalog.getAcroForm();
|
||||
List<PDField> fields = form.getFields();
|
||||
|
||||
int numberOfFields = 0;
|
||||
int filledNumberOfFields = 0;
|
||||
for (PDField field : fields) {
|
||||
String value = field.getValueAsString().trim();
|
||||
String key = field.getPartialName();
|
||||
System.out.print(key + "," + value + ";");
|
||||
}
|
||||
}
|
||||
|
||||
for (PDField field : fields) {
|
||||
String value = field.getValueAsString().trim();
|
||||
String key = field.getPartialName();
|
||||
// System.out.println("\"" + key + "\" = \"" + value + "\"");
|
||||
System.out.print(key + "," + value + ";");
|
||||
numberOfFields++;
|
||||
if (value.length() > 0)
|
||||
filledNumberOfFields++;
|
||||
}
|
||||
|
||||
|
||||
// System.out.println("Anzahl ausfuellbarer Felder: \t" + numberOfFields);
|
||||
// System.out.println("Ausgefuellte Felder: \t\t" + filledNumberOfFields);
|
||||
// System.out.println("----------------------------------");
|
||||
if(filledNumberOfFields==numberOfFields) {
|
||||
// System.out.println("OK! Alle Felder sind ausgefuellt.");
|
||||
System.out.println("OK");
|
||||
}else {
|
||||
// System.out.println("Nicht OK!!! Einige Felder sind nicht ausgefuellt!");
|
||||
System.out.println("NOT_OK");
|
||||
}
|
||||
}
|
||||
public static void main(String[] args) throws Exception {
|
||||
if (args.length != 1) {
|
||||
System.err.println("Uebergeben Sie den absoluten Pfad von genau einer pdf Datei als Parameter");
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
// System.out.println(args[0]);
|
||||
if (args.length != 1) {
|
||||
System.err.println("Uebergeben Sie den absoluten Pfad von genau einer pdf Datei als Parameter");
|
||||
System.exit(-1);
|
||||
}
|
||||
File file = new File(args[0]);
|
||||
|
||||
File file = new File(args[0]);
|
||||
if (!file.isFile()) {
|
||||
// System.out.println("Datei \"" + file.getAbsolutePath() + "\" existiert nicht.");
|
||||
System.exit(-1);
|
||||
}
|
||||
// System.out.println("Ueberpruefe Datei: \"" + file.getAbsolutePath()+"\"");
|
||||
// System.out.println("----------------------------------");
|
||||
PDDocument doc = PDDocument.load(file);
|
||||
listFields(doc);
|
||||
|
||||
}
|
||||
if (!file.isFile()) {
|
||||
System.exit(-1);
|
||||
}
|
||||
|
||||
PDDocument doc = PDDocument.load(file);
|
||||
listFields(doc);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user