diff options
author | Thomas <> | 2023-06-22 15:54:22 +0200 |
---|---|---|
committer | Thomas <> | 2023-06-22 15:54:22 +0200 |
commit | 56f651ae0343d8b905fd2ee4096a7bfe1216411d (patch) | |
tree | de5efa35548dea5d39e6ac599d86ba0966cffd9d | |
parent | 2c92c4fa76036eab52a5a3bf0971f97e779fcff3 (diff) | |
download | pdf-as-4-56f651ae0343d8b905fd2ee4096a7bfe1216411d.tar.gz pdf-as-4-56f651ae0343d8b905fd2ee4096a7bfe1216411d.tar.bz2 pdf-as-4-56f651ae0343d8b905fd2ee4096a7bfe1216411d.zip |
chore(siglbock): optimize signature-block calculation and positioning
2 files changed, 23 insertions, 14 deletions
diff --git a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/PDFAsVisualSignatureBuilder.java b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/PDFAsVisualSignatureBuilder.java index d30604d3..a148b3ec 100644 --- a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/PDFAsVisualSignatureBuilder.java +++ b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/PDFAsVisualSignatureBuilder.java @@ -30,17 +30,25 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.security.MessageDigest; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; -import at.gv.egiz.pdfas.common.settings.SignatureProfileSettings; import org.apache.commons.codec.binary.Hex; -import org.apache.commons.io.IOUtils; import org.apache.pdfbox.cos.COSArray; import org.apache.pdfbox.cos.COSDictionary; import org.apache.pdfbox.cos.COSName; -import org.apache.pdfbox.pdmodel.*; +import org.apache.pdfbox.pdmodel.PDDocument; +import org.apache.pdfbox.pdmodel.PDDocumentCatalog; +import org.apache.pdfbox.pdmodel.PDPage; +import org.apache.pdfbox.pdmodel.PDPageContentStream; +import org.apache.pdfbox.pdmodel.PDResources; import org.apache.pdfbox.pdmodel.common.PDRectangle; import org.apache.pdfbox.pdmodel.common.PDStream; +import org.apache.pdfbox.pdmodel.font.PDFont; +import org.apache.pdfbox.pdmodel.font.PDType0Font; import org.apache.pdfbox.pdmodel.graphics.form.PDFormXObject; import org.apache.pdfbox.pdmodel.graphics.image.JPEGFactory; import org.apache.pdfbox.pdmodel.graphics.image.LosslessFactory; @@ -52,12 +60,12 @@ import org.apache.pdfbox.pdmodel.interactive.digitalsignature.visible.PDVisibleS 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 org.apache.pdfbox.pdmodel.font.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import at.gv.egiz.pdfas.common.exceptions.PdfAsException; import at.gv.egiz.pdfas.common.settings.ISettings; +import at.gv.egiz.pdfas.common.settings.SignatureProfileSettings; import at.gv.egiz.pdfas.common.utils.ImageUtils; import at.knowcenter.wag.egov.egiz.table.Entry; @@ -260,7 +268,7 @@ public class PDFAsVisualSignatureBuilder extends PDVisibleSigBuilder implements PDPageContentStream stream = new PDPageContentStream(template, getStructure().getPage()); // stream.setFont(PDType1Font.COURIER, 5); - TableDrawUtils.drawTable(getStructure().getPage(), stream, 1, 1, + TableDrawUtils.drawTable(getStructure().getPage(), stream, 0, 1, designer.getWidth(), designer.getHeight(), properties.getMainTable(), template, false, innerFormResources, images, settings, this, properties); diff --git a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/PDFAsVisualSignatureProperties.java b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/PDFAsVisualSignatureProperties.java index f482f49f..8a030927 100644 --- a/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/PDFAsVisualSignatureProperties.java +++ b/pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/stamping/pdfbox2/PDFAsVisualSignatureProperties.java @@ -23,12 +23,8 @@ ******************************************************************************/ package at.gv.egiz.pdfas.lib.impl.stamping.pdfbox2; -import at.gv.egiz.pdfas.common.exceptions.PdfAsException; -import at.gv.egiz.pdfas.common.exceptions.PdfAsWrappedIOException; -import at.gv.egiz.pdfas.common.settings.ISettings; -import at.gv.egiz.pdfas.common.settings.SignatureProfileSettings; -import at.gv.egiz.pdfas.lib.impl.pdfbox2.PDFBOXObject; -import at.knowcenter.wag.egov.egiz.pdf.PositioningInstruction; +import java.io.IOException; + import org.apache.pdfbox.pdmodel.PDDocument; import org.apache.pdfbox.pdmodel.PDPage; import org.apache.pdfbox.pdmodel.PDPageTree; @@ -36,7 +32,12 @@ import org.apache.pdfbox.pdmodel.interactive.digitalsignature.visible.PDVisibleS import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.IOException; +import at.gv.egiz.pdfas.common.exceptions.PdfAsException; +import at.gv.egiz.pdfas.common.exceptions.PdfAsWrappedIOException; +import at.gv.egiz.pdfas.common.settings.ISettings; +import at.gv.egiz.pdfas.common.settings.SignatureProfileSettings; +import at.gv.egiz.pdfas.lib.impl.pdfbox2.PDFBOXObject; +import at.knowcenter.wag.egov.egiz.pdf.PositioningInstruction; public class PDFAsVisualSignatureProperties extends PDVisibleSigProperties { @@ -99,7 +100,7 @@ public class PDFAsVisualSignatureProperties extends PDVisibleSigProperties { logger.debug("ROT {}", rot); logger.debug("COORD X {} Y {}", posx, posy); designer.coordinates(posx, posy); - float[] form_rect = new float[] {0,0, main.getWidth() + 2, main.getHeight() + 2}; + float[] form_rect = new float[] {0,0, main.getWidth() + 1, main.getHeight() + 1}; logger.debug("AP Rect: {} {} {} {}", form_rect[0], form_rect[1], form_rect[2], form_rect[3]); designer.formaterRectangleParams(form_rect); //this.setPdVisibleSignature(designer); |