aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas
diff options
context:
space:
mode:
authorEmina Ahmetovic <emina.ahmetovic@egiz.gv.at>2021-02-05 14:32:37 +0100
committerEmina Ahmetovic <emina.ahmetovic@egiz.gv.at>2021-02-05 14:32:37 +0100
commitc168a1f30d39eddec8cdcdfbe9700e83a8b67746 (patch)
tree1a4e89a7cf3400c90eee3a99fa6de8f38ac7eaf8 /pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas
parent60f787b55d2798cfd70370a66ecda09fc4445df5 (diff)
downloadpdf-as-4-c168a1f30d39eddec8cdcdfbe9700e83a8b67746.tar.gz
pdf-as-4-c168a1f30d39eddec8cdcdfbe9700e83a8b67746.tar.bz2
pdf-as-4-c168a1f30d39eddec8cdcdfbe9700e83a8b67746.zip
fix placeholder overwritting issue
Diffstat (limited to 'pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas')
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox2/PADESPDFBOXSigner.java31
1 files changed, 29 insertions, 2 deletions
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 eec9b6c1..0a32d7a5 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
@@ -108,6 +108,9 @@ public class PADESPDFBOXSigner implements IPdfSigner, IConfigurationConstants {
PDFAsVisualSignatureProperties properties = null;
List<SignaturePlaceholderData> placeholders;
+ List<SignaturePlaceholderData> availablePlaceholders;
+ SignaturePlaceholderData signaturePlaceholderData = null;
+
String placeholder_id = "";
if(PlaceholderWebConfiguration.getValue(PLACEHOLDER_WEB_ID) != null && !PlaceholderWebConfiguration.getValue(PLACEHOLDER_WEB_ID).equalsIgnoreCase("")){
@@ -157,6 +160,8 @@ public class PADESPDFBOXSigner implements IPdfSigner, IConfigurationConstants {
SignaturePlaceholderData signaturePlaceholderDataInit = PlaceholderFilter.checkPlaceholderSignatureLocation(pdfObject.getStatus(), pdfObject.getStatus().getSettings(), placeholder_id);
placeholders = SignaturePlaceholderExtractor.getPlaceholders();
+ availablePlaceholders = listAvailablePlaceholders(placeholders, existingSignatureLocations(doc));
+
if(placeholder_id.equalsIgnoreCase("")){
if(checkAvailablePlaceholders(placeholders,existingSignatureLocations(doc))!=null)
@@ -165,8 +170,13 @@ public class PADESPDFBOXSigner implements IPdfSigner, IConfigurationConstants {
};
}
- SignaturePlaceholderData signaturePlaceholderData = PlaceholderFilter
- .checkPlaceholderSignatureLocation(pdfObject.getStatus(), pdfObject.getStatus().getSettings(),placeholder_id);
+ if(availablePlaceholders!=null) {
+ signaturePlaceholderData = PlaceholderFilter
+ .checkPlaceholderSignatureLocation(pdfObject.getStatus(), pdfObject.getStatus().getSettings(),placeholder_id);
+ }
+
+
+
TablePos tablePos = null;
@@ -643,6 +653,7 @@ public class PADESPDFBOXSigner implements IPdfSigner, IConfigurationConstants {
if (doc != null) {
try {
doc.close();
+ SignaturePlaceholderExtractor.getPlaceholders().clear();
} catch (IOException e) {
logger.debug("Failed to close COS Doc!", e);
// Ignore
@@ -921,4 +932,20 @@ public class PADESPDFBOXSigner implements IPdfSigner, IConfigurationConstants {
}
return result;
}
+
+
+ //find first placeholder_id
+ public List<SignaturePlaceholderData> listAvailablePlaceholders(List<SignaturePlaceholderData> placeholders, List<String> existingPlaceholders) {
+ List<SignaturePlaceholderData> result = null;
+
+ if(placeholders!=null) {
+ for(int i = 0; i < placeholders.size(); ++i) {
+ //take smallest id
+ if(!existingPlaceholders.contains(placeholders.get(i).getPlaceholderName())) {
+ result.add(placeholders.get(i));
+ }
+ }
+ }
+ return result;
+ }
} \ No newline at end of file