aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-pdfbox-2/src/main/java
diff options
context:
space:
mode:
authorAlexander Marsalek <amarsalek@iaik.tugraz.at>2021-07-12 13:10:13 +0200
committerAlexander Marsalek <amarsalek@iaik.tugraz.at>2021-07-12 13:12:01 +0200
commit10b659782e65a4c337f591acb1210f547a58a298 (patch)
treed8fbfeb0f3e367264b8c7c69e0e6dbd0a2151cc5 /pdf-as-pdfbox-2/src/main/java
parent7713e14c11d1952f2b572c22e9c976be891815fb (diff)
downloadpdf-as-4-10b659782e65a4c337f591acb1210f547a58a298.tar.gz
pdf-as-4-10b659782e65a4c337f591acb1210f547a58a298.tar.bz2
pdf-as-4-10b659782e65a4c337f591acb1210f547a58a298.zip
v4.2.0-pdfOver API for PDF-OVER issue #52
Diffstat (limited to 'pdf-as-pdfbox-2/src/main/java')
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/placeholder/SignatureFieldsExtractor.java39
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/placeholder/SignaturePlaceholderExtractor.java9
2 files changed, 39 insertions, 9 deletions
diff --git a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/placeholder/SignatureFieldsExtractor.java b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/placeholder/SignatureFieldsExtractor.java
index a8473858..0ccce1f8 100644
--- a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/placeholder/SignatureFieldsExtractor.java
+++ b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/placeholder/SignatureFieldsExtractor.java
@@ -1,5 +1,7 @@
package at.gv.egiz.pdfas.lib.impl.pdfbox2.placeholder;
+import at.gv.egiz.pdfas.lib.impl.placeholder.PlaceholderExtractorConstants;
+import at.gv.egiz.pdfas.lib.impl.placeholder.SignaturePlaceholderData;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature;
import org.apache.pdfbox.pdmodel.interactive.form.PDAcroForm;
@@ -30,4 +32,41 @@ public class SignatureFieldsExtractor {
}
return signatureFieldNames;
}
+ /*
+ Needed by PDF-OVER
+ */
+ public static SignaturePlaceholderData getNextSignaturePlaceHolder(PDDocument doc) {
+ try {
+ SignaturePlaceholderExtractor signaturePlaceholderExtractor = new SignaturePlaceholderExtractor("1",
+ PlaceholderExtractorConstants.PLACEHOLDER_MATCH_MODE_SORTED, doc);
+ return signaturePlaceholderExtractor.extract(doc, "1",
+ PlaceholderExtractorConstants.PLACEHOLDER_MATCH_MODE_SORTED);
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ public static SignaturePlaceholderData getSignaturePlaceHolder(PDDocument doc, String placeholderId,
+ int mode) {
+ try {
+ SignaturePlaceholderExtractor signaturePlaceholderExtractor = new SignaturePlaceholderExtractor( placeholderId,
+ mode, doc);
+ return signaturePlaceholderExtractor.extract(doc, placeholderId, mode);
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ public static List<SignaturePlaceholderData> getSignaturePlaceHolderList(PDDocument doc, String placeholderId, int mode) {
+ try {
+ SignaturePlaceholderExtractor signaturePlaceholderExtractor = new SignaturePlaceholderExtractor( placeholderId,
+ mode, doc);
+ return signaturePlaceholderExtractor.extractList(doc, placeholderId, mode);
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
}
diff --git a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/placeholder/SignaturePlaceholderExtractor.java b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/placeholder/SignaturePlaceholderExtractor.java
index 4031d07f..71eef856 100644
--- a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/placeholder/SignaturePlaceholderExtractor.java
+++ b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/placeholder/SignaturePlaceholderExtractor.java
@@ -194,14 +194,6 @@ public class SignaturePlaceholderExtractor extends PDFStreamEngine implements Pl
public List<SignaturePlaceholderData> extractList(PDDocument doc,
String placeholderId, int matchMode) throws PdfAsException {
SignaturePlaceholderContext.setSignaturePlaceholderData(null);
-// List<SignaturePlaceholderData> placeholders = new ArrayList<>();
-// SignaturePlaceholderExtractor extractor;
-// try {
-// extractor = new SignaturePlaceholderExtractor(placeholderId,
-// matchMode, doc);
-// } catch (IOException | ClassNotFoundException | InstantiationException | IllegalAccessException e2) {
-// throw new PDFIOException("error.pdf.io.04", e2);
-// }
int pageNr = 0;
for(PDPage page : doc.getPages()){
@@ -236,7 +228,6 @@ public class SignaturePlaceholderExtractor extends PDFStreamEngine implements Pl
if (matchMode == PLACEHOLDER_MATCH_MODE_STRICT) {
throw new PlaceholderExtractionException("error.pdf.stamp.09");
}
-
return null;
}