From e1f63b5fa88dfa2a5ca3fe91d8b065753ce63a68 Mon Sep 17 00:00:00 2001 From: Alexander Marsalek Date: Mon, 12 Jul 2021 13:16:17 +0200 Subject: renamed class --- .../SignatureFieldsAndPlaceHolderExtractor.java | 72 ++++++++++++++++++++++ .../placeholder/SignatureFieldsExtractor.java | 72 ---------------------- 2 files changed, 72 insertions(+), 72 deletions(-) create mode 100644 pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/placeholder/SignatureFieldsAndPlaceHolderExtractor.java delete mode 100644 pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/placeholder/SignatureFieldsExtractor.java (limited to 'pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas') diff --git a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/placeholder/SignatureFieldsAndPlaceHolderExtractor.java b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/placeholder/SignatureFieldsAndPlaceHolderExtractor.java new file mode 100644 index 00000000..ca620aec --- /dev/null +++ b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/placeholder/SignatureFieldsAndPlaceHolderExtractor.java @@ -0,0 +1,72 @@ +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; +import org.apache.pdfbox.pdmodel.interactive.form.PDField; +import org.apache.pdfbox.pdmodel.interactive.form.PDSignatureField; + +import java.util.ArrayList; +import java.util.List; + +public class SignatureFieldsAndPlaceHolderExtractor { + + //Search for empty signature fields + public static List findEmptySignatureFields(PDDocument doc) + { + PDSignature signature; + List signatureField; + List signatureFieldNames = new ArrayList<>(); + PDAcroForm acroForm = doc.getDocumentCatalog().getAcroForm(); + if (acroForm != null) { + signatureField = acroForm.getFields(); + for (PDField pdField : signatureField) { + if(pdField instanceof PDSignatureField && pdField.getPartialName()!=null) + { + signature = ((PDSignatureField) pdField).getSignature(); + if(signature == null) signatureFieldNames.add(pdField.getPartialName()); + } + } + } + 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 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/SignatureFieldsExtractor.java b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/placeholder/SignatureFieldsExtractor.java deleted file mode 100644 index 0ccce1f8..00000000 --- a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/placeholder/SignatureFieldsExtractor.java +++ /dev/null @@ -1,72 +0,0 @@ -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; -import org.apache.pdfbox.pdmodel.interactive.form.PDField; -import org.apache.pdfbox.pdmodel.interactive.form.PDSignatureField; - -import java.util.ArrayList; -import java.util.List; - -public class SignatureFieldsExtractor { - - //Search for empty signature fields - public static List findEmptySignatureFields(PDDocument doc) - { - PDSignature signature; - List signatureField; - List signatureFieldNames = new ArrayList<>(); - PDAcroForm acroForm = doc.getDocumentCatalog().getAcroForm(); - if (acroForm != null) { - signatureField = acroForm.getFields(); - for (PDField pdField : signatureField) { - if(pdField instanceof PDSignatureField && pdField.getPartialName()!=null) - { - signature = ((PDSignatureField) pdField).getSignature(); - if(signature == null) signatureFieldNames.add(pdField.getPartialName()); - } - } - } - 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 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; - } - } -} -- cgit v1.2.3