aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-pdfbox/src/main/java/at/gv/egiz
diff options
context:
space:
mode:
authorAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2016-02-15 13:55:12 +0100
committerAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2016-02-15 13:55:12 +0100
commitaa99f5b7512a5019b71616f9589a7a5bbfc403da (patch)
tree5fad8be42ae22f433beb61ae31d08b24ff8112d9 /pdf-as-pdfbox/src/main/java/at/gv/egiz
parentdfde0e5bcde5ab48940ee91b72c8251492ffdc21 (diff)
downloadpdf-as-4-aa99f5b7512a5019b71616f9589a7a5bbfc403da.tar.gz
pdf-as-4-aa99f5b7512a5019b71616f9589a7a5bbfc403da.tar.bz2
pdf-as-4-aa99f5b7512a5019b71616f9589a7a5bbfc403da.zip
placeholder sorted mode
Diffstat (limited to 'pdf-as-pdfbox/src/main/java/at/gv/egiz')
-rw-r--r--pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox/placeholder/SignaturePlaceholderExtractor.java36
1 files changed, 36 insertions, 0 deletions
diff --git a/pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox/placeholder/SignaturePlaceholderExtractor.java b/pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox/placeholder/SignaturePlaceholderExtractor.java
index db16d212..54922864 100644
--- a/pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox/placeholder/SignaturePlaceholderExtractor.java
+++ b/pdf-as-pdfbox/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox/placeholder/SignaturePlaceholderExtractor.java
@@ -192,6 +192,38 @@ public class SignaturePlaceholderExtractor extends PDFStreamEngine implements Pl
if (placeholders.size() == 0)
return null;
+ if (matchMode == PLACEHOLDER_MATCH_MODE_SORTED) {
+ // sort all placeholders by the id string if all ids are null do nothing
+ SignaturePlaceholderData currentFirstSpd = null;
+ for (int i = 0; i < placeholders.size(); i++) {
+ SignaturePlaceholderData spd = placeholders.get(i);
+ if (spd.getId() != null) {
+ if(currentFirstSpd == null) {
+ currentFirstSpd = spd;
+ logger.debug("Setting new current ID: {}",
+ currentFirstSpd.getId());
+ } else {
+ String currentID = currentFirstSpd.getId();
+ String testID = spd.getId();
+ logger.debug("Testing placeholder current: {} compare to {}",
+ currentID, testID);
+ if(testID.compareToIgnoreCase(currentID) < 0) {
+ currentFirstSpd = spd;
+ logger.debug("Setting new current ID: {}",
+ testID);
+ }
+ }
+ }
+ }
+
+ if(currentFirstSpd != null) {
+ logger.info("Running Placeholder sorted mode: using id: {}", currentFirstSpd.getId());
+ return currentFirstSpd;
+ } else {
+ logger.info("Running Placeholder sorted mode: no placeholder with id found, fallback to first placeholder");
+ }
+ }
+
for (int i = 0; i < placeholders.size(); i++) {
SignaturePlaceholderData spd = placeholders.get(i);
if (spd.getId() == null)
@@ -207,6 +239,10 @@ public class SignaturePlaceholderExtractor extends PDFStreamEngine implements Pl
private static SignaturePlaceholderData matchPlaceholderPage(
List<SignaturePlaceholderData> placeholders, String placeholderId,
int matchMode) {
+
+ if(matchMode == PLACEHOLDER_MATCH_MODE_SORTED)
+ return null;
+
if (placeholders.size() == 0)
return null;
for (int i = 0; i < placeholders.size(); i++) {