aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-pdfbox-2/src
diff options
context:
space:
mode:
authorEmina Ahmetovic <emina.ahmetovic@egiz.gv.at>2021-01-18 16:07:28 +0100
committerEmina Ahmetovic <emina.ahmetovic@egiz.gv.at>2021-01-18 16:07:28 +0100
commita3bef06e6b3f2e465703aa8b64ab36f6e3d76de7 (patch)
treef7cf0bc30c40598b6420283d7c51da11a9f41703 /pdf-as-pdfbox-2/src
parent78a01744e1fc3e8d45348b623a3a80906d31e373 (diff)
downloadpdf-as-4-a3bef06e6b3f2e465703aa8b64ab36f6e3d76de7.tar.gz
pdf-as-4-a3bef06e6b3f2e465703aa8b64ab36f6e3d76de7.tar.bz2
pdf-as-4-a3bef06e6b3f2e465703aa8b64ab36f6e3d76de7.zip
update placeholder search
Diffstat (limited to 'pdf-as-pdfbox-2/src')
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/pdfbox2/placeholder/SignaturePlaceholderExtractor.java11
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox2/PADESPDFBOXSigner.java15
2 files changed, 16 insertions, 10 deletions
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 9043aae7..0998a2eb 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
@@ -106,8 +106,6 @@ public class SignaturePlaceholderExtractor extends PDFStreamEngine implements Pl
private static List<SignaturePlaceholderData> placeholders = new ArrayList<>();
private int currentPage = 0;
private PDDocument doc;
-
-
private SignaturePlaceholderExtractor(String placeholderId,
int placeholderMatchMode, PDDocument doc) throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException {
@@ -128,13 +126,18 @@ public class SignaturePlaceholderExtractor extends PDFStreamEngine implements Pl
this.doc = doc;
}
- public static List<SignaturePlaceholderData> listPlaceholders() {
+ public static List<SignaturePlaceholderData> getPlaceholders() {
return placeholders;
}
- public static void clearPlaceholders(){
+ public void setPlaceholders(List<SignaturePlaceholderData> placeholders) {
+ this.placeholders = placeholders;
+ }
+
+ public static void clearPlaceholders() {
placeholders.clear();
}
+
/**
* Search the document for placeholder images and possibly included
* additional info.<br/>
diff --git a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox2/PADESPDFBOXSigner.java b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox2/PADESPDFBOXSigner.java
index 82c48d96..cff5fc7f 100644
--- a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox2/PADESPDFBOXSigner.java
+++ b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox2/PADESPDFBOXSigner.java
@@ -107,6 +107,7 @@ public class PADESPDFBOXSigner implements IPdfSigner, IConfigurationConstants {
PDFASSignatureInterface genericSigner) throws PdfAsException {
PDFAsVisualSignatureProperties properties = null;
+ List<SignaturePlaceholderData> placeholders;
String placeholder_id = "";
if(PlaceholderWebConfiguration.getValue(PLACEHOLDER_WEB_ID) != null && !PlaceholderWebConfiguration.getValue(PLACEHOLDER_WEB_ID).equalsIgnoreCase("")){
@@ -155,11 +156,9 @@ public class PADESPDFBOXSigner implements IPdfSigner, IConfigurationConstants {
signature.setSubFilter(COSName.getPDFName(signer.getPDFSubFilter()));
SignaturePlaceholderData signaturePlaceholderDataInit = PlaceholderFilter.checkPlaceholderSignatureLocation(pdfObject.getStatus(), pdfObject.getStatus().getSettings(), placeholder_id);
- //gives a list of all placeholders
- List<SignaturePlaceholderData> placeholders = SignaturePlaceholderExtractor.listPlaceholders();
- if(placeholders!=null){
- SignaturePlaceholderExtractor.clearPlaceholders();
- }
+ placeholders = SignaturePlaceholderExtractor.getPlaceholders();
+
+
if(placeholder_id.equalsIgnoreCase("")){
if(checkAvailablePlaceholders(placeholders,existingSignatureLocations(doc))!=null)
{
@@ -177,7 +176,8 @@ public class PADESPDFBOXSigner implements IPdfSigner, IConfigurationConstants {
if (signaturePlaceholderData != null) {
// Placeholder found!
- logger.info("Placeholder data found.");
+ placeholders.clear();
+ logger.info("Placeholder data found.");
if (signaturePlaceholderData.getProfile() != null) {
logger.debug("Placeholder Profile set to: " + signaturePlaceholderData.getProfile());
requestedSignature.setSignatureProfileID(signaturePlaceholderData.getProfile());
@@ -900,12 +900,15 @@ public class PADESPDFBOXSigner implements IPdfSigner, IConfigurationConstants {
//find first available placeholder
public SignaturePlaceholderData checkAvailablePlaceholders(List<SignaturePlaceholderData> placeholders, List<String> existingPlaceholders) {
SignaturePlaceholderData result = null;
+
+ if(placeholders!=null){
for(int i = 0; i < placeholders.size(); ++i) {
if(!existingPlaceholders.contains(placeholders.get(i).getPlaceholderName())) {
result = placeholders.get(i);
break;
}
}
+ }
return result;
}
} \ No newline at end of file