aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-lib/src/main/java/at
diff options
context:
space:
mode:
Diffstat (limited to 'pdf-as-lib/src/main/java/at')
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox/PADESPDFBOXSigner.java34
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFBoxTable.java5
2 files changed, 35 insertions, 4 deletions
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox/PADESPDFBOXSigner.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox/PADESPDFBOXSigner.java
index 44919b1c..8694017f 100644
--- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox/PADESPDFBOXSigner.java
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox/PADESPDFBOXSigner.java
@@ -128,7 +128,7 @@ public class PADESPDFBOXSigner implements IPdfSigner, IConfigurationConstants {
if (signerReason == null) {
signerReason = "PAdES Signature";
}
-
+
signature.setReason(signerReason);
logger.debug("Signing reason: " + signerReason);
@@ -139,7 +139,7 @@ public class PADESPDFBOXSigner implements IPdfSigner, IConfigurationConstants {
signer.setPDSignature(signature);
SignatureOptions options = new SignatureOptions();
-
+
// Is visible Signature
if (requestedSignature.isVisual()) {
logger.info("Creating visual siganture block");
@@ -321,6 +321,36 @@ public class PADESPDFBOXSigner implements IPdfSigner, IConfigurationConstants {
doc.addSignature(signature, signer, options);
+ String sigFieldName = signatureProfileSettings.getSignFieldValue();
+
+ if(sigFieldName != null) {
+ PDAcroForm acroForm = doc.getDocumentCatalog().getAcroForm();
+ if (acroForm != null) {
+ @SuppressWarnings("unchecked")
+ List<PDField> fields = acroForm.getFields();
+ PDSignatureField signatureField = null;
+
+ if (fields != null) {
+ for (PDField pdField : fields) {
+ if (pdField instanceof PDSignatureField) {
+ if (((PDSignatureField) pdField).getSignature().getDictionary()
+ .equals(signature.getDictionary())) {
+ signatureField = (PDSignatureField) pdField;
+ }
+ }
+ }
+ } else {
+ logger.warn("Failed to name Signature Field! [Cannot find Field list in acroForm!]");
+ }
+
+ if(signatureField != null) {
+ signatureField.setPartialName(sigFieldName);
+ }
+ } else {
+ logger.warn("Failed to name Signature Field! [Cannot find acroForm!]");
+ }
+ }
+
if (requestedSignature.isVisual()) {
// if(requestedSignature.getSignaturePosition().)
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFBoxTable.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFBoxTable.java
index 1d8928aa..c6d515f9 100644
--- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFBoxTable.java
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox/PDFBoxTable.java
@@ -374,9 +374,10 @@ public class PDFBoxTable {
float fwidth;
if (c instanceof PDType1Font) {
fwidth = c.getFontDescriptor().getFontBoundingBox().getWidth()
- / 1000 * fontSize;
+ / 1000.0f * fontSize;
} else {
- fwidth = c.getFontDescriptor().getMaxWidth();
+ fwidth = c.getStringWidth("abcdefghijklmnopqrstuvwxyz ") / 1000.0f * fontSize;
+ fwidth = fwidth / (float)"abcdefghijklmnopqrstuvwxyz".length();
}
logger.debug("Font Width: {}", fwidth);