commit c41b914283dde2ea8db29d166218e7fa1876301e Author: Simon Date: Wed Dec 2 14:21:46 2020 +0100 Initial commit diff --git a/SheetCheckingTool/.gitignore b/SheetCheckingTool/.gitignore new file mode 100644 index 0000000..ae914c9 --- /dev/null +++ b/SheetCheckingTool/.gitignore @@ -0,0 +1,2 @@ +.idea +.directory \ No newline at end of file diff --git a/SheetCheckingTool/TaskSheetChecker.jar b/SheetCheckingTool/TaskSheetChecker.jar new file mode 100644 index 0000000..2886569 Binary files /dev/null and b/SheetCheckingTool/TaskSheetChecker.jar differ diff --git a/SheetCheckingTool/upload.html b/SheetCheckingTool/upload.html new file mode 100644 index 0000000..cd1c40f --- /dev/null +++ b/SheetCheckingTool/upload.html @@ -0,0 +1,16 @@ + + + + + Upload PDF + + + +
+ Select PDF file to upload: + + +
+ + + diff --git a/SheetCheckingTool/upload.php b/SheetCheckingTool/upload.php new file mode 100644 index 0000000..04e23d8 --- /dev/null +++ b/SheetCheckingTool/upload.php @@ -0,0 +1,85 @@ + 500000) { + echo "Sorry, your file is too large."; + $uploadOk = 0; +} + +// allow certain file formats +if ($imageFileType != "pdf") { + echo "Sorry, only PDF files are allowed."; + $uploadOk = 0; +} + +// check if $uploadOk is set to 0 by an error +if ($uploadOk == 0) { + echo "Sorry, your file was not uploaded."; + +// otherwise upload file +} else { + if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) { + echo "The file " . htmlspecialchars(basename($_FILES["fileToUpload"]["name"])) . " has been uploaded."; + } else { + echo "Sorry, there was an error uploading your file."; + } +} + +// process file +$output = shell_exec("java -jar TaskSheetChecker.jar " . $target_dir . htmlspecialchars(basename($_FILES["fileToUpload"]["name"]))); +$keySeparator = ','; +$delimiter = ';'; + +$key_array = array(); +$value_array = array(); + +$currentString = ""; + +for ($i = 0; $i < strlen($output); $i++) { + if ($output[$i] == ',') { + array_push($key_array, $currentString); + $currentString = ""; + } else if ($output[$i] == ';') { + array_push($value_array, $output[$i]); + $currentString = ""; + } else { + $currentString = $currentString . $output[$i]; + } +} + +echo count($key_array) . "
"; +echo count($value_array); + +foreach ($value_array as &$value) + echo $value . "
"; + + + + +?> + + + + + + Upload PDF + + + + + + + + diff --git a/SheetCheckingTool/uploads/BS_WS2021_Sheet1_328225735.pdf b/SheetCheckingTool/uploads/BS_WS2021_Sheet1_328225735.pdf new file mode 100644 index 0000000..aacfbfe Binary files /dev/null and b/SheetCheckingTool/uploads/BS_WS2021_Sheet1_328225735.pdf differ diff --git a/TaskSheetChecker/.gitignore b/TaskSheetChecker/.gitignore new file mode 100644 index 0000000..c55e216 --- /dev/null +++ b/TaskSheetChecker/.gitignore @@ -0,0 +1,7 @@ +.idea +.settings +bin +out +.classpath +.project +*.iml \ No newline at end of file diff --git a/TaskSheetChecker/commons-logging-1.2-javadoc.jar b/TaskSheetChecker/commons-logging-1.2-javadoc.jar new file mode 100644 index 0000000..05eb3ed Binary files /dev/null and b/TaskSheetChecker/commons-logging-1.2-javadoc.jar differ diff --git a/TaskSheetChecker/commons-logging-1.2.jar b/TaskSheetChecker/commons-logging-1.2.jar new file mode 100644 index 0000000..93a3b9f Binary files /dev/null and b/TaskSheetChecker/commons-logging-1.2.jar differ diff --git a/TaskSheetChecker/pdfbox-2.0.17.jar b/TaskSheetChecker/pdfbox-2.0.17.jar new file mode 100644 index 0000000..364bb94 Binary files /dev/null and b/TaskSheetChecker/pdfbox-2.0.17.jar differ diff --git a/TaskSheetChecker/src/META-INF/MANIFEST.MF b/TaskSheetChecker/src/META-INF/MANIFEST.MF new file mode 100644 index 0000000..fa1fc1e --- /dev/null +++ b/TaskSheetChecker/src/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Main-Class: Tsc + diff --git a/TaskSheetChecker/src/Tsc.java b/TaskSheetChecker/src/Tsc.java new file mode 100644 index 0000000..843a599 --- /dev/null +++ b/TaskSheetChecker/src/Tsc.java @@ -0,0 +1,61 @@ +import java.io.File; +import java.util.List; + +import org.apache.pdfbox.pdmodel.PDDocument; +import org.apache.pdfbox.pdmodel.PDDocumentCatalog; +import org.apache.pdfbox.pdmodel.interactive.form.PDAcroForm; +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 fields = form.getFields(); + + int numberOfFields = 0; + int filledNumberOfFields = 0; + + 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 { +// 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]); + 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); + + } + +}