From 2c92c4fa76036eab52a5a3bf0971f97e779fcff3 Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Thu, 22 Jun 2023 15:15:51 +0200 Subject: feat(placeholder): optimize possitioning by using QR-placeholder --- .../placeholder/SignaturePlaceholderExtractor.java | 36 ++++++++++++++-------- 1 file changed, 23 insertions(+), 13 deletions(-) (limited to 'pdf-as-pdfbox-2/src/main/java/at/gv/egiz') 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 6df4f0b1..b62b660a 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 @@ -50,10 +50,15 @@ import java.awt.geom.AffineTransform; import java.awt.geom.NoninvertibleTransformException; import java.awt.image.BufferedImage; import java.io.IOException; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Hashtable; +import java.util.List; +import java.util.Map; import java.util.Map.Entry; - -import javassist.bytecode.stackmap.TypeData.ClassName; +import java.util.Properties; +import java.util.Set; +import java.util.Vector; import org.apache.pdfbox.contentstream.PDFStreamEngine; import org.apache.pdfbox.contentstream.operator.Operator; @@ -71,14 +76,6 @@ import org.apache.pdfbox.util.Matrix; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import at.gv.egiz.pdfas.common.exceptions.PDFIOException; -import at.gv.egiz.pdfas.common.exceptions.PdfAsException; -import at.gv.egiz.pdfas.common.exceptions.PlaceholderExtractionException; -import at.gv.egiz.pdfas.lib.impl.placeholder.PlaceholderExtractorConstants; -import at.gv.egiz.pdfas.lib.impl.placeholder.SignaturePlaceholderContext; -import at.gv.egiz.pdfas.lib.impl.placeholder.SignaturePlaceholderData; -import at.knowcenter.wag.egov.egiz.pdf.TablePos; - import com.google.zxing.BarcodeFormat; import com.google.zxing.BinaryBitmap; import com.google.zxing.DecodeHintType; @@ -90,6 +87,15 @@ import com.google.zxing.Result; import com.google.zxing.client.j2se.BufferedImageLuminanceSource; import com.google.zxing.common.HybridBinarizer; +import at.gv.egiz.pdfas.common.exceptions.PDFIOException; +import at.gv.egiz.pdfas.common.exceptions.PdfAsException; +import at.gv.egiz.pdfas.common.exceptions.PlaceholderExtractionException; +import at.gv.egiz.pdfas.lib.impl.placeholder.PlaceholderExtractorConstants; +import at.gv.egiz.pdfas.lib.impl.placeholder.SignaturePlaceholderContext; +import at.gv.egiz.pdfas.lib.impl.placeholder.SignaturePlaceholderData; +import at.knowcenter.wag.egov.egiz.pdf.TablePos; +import javassist.bytecode.stackmap.TypeData.ClassName; + /** * Extract all relevant information from a placeholder image. * @@ -355,8 +361,12 @@ public class SignaturePlaceholderExtractor extends PDFStreamEngine implements Pl x = page.getCropBox().getHeight() + x; } - String posString = "p:" + currentPage + ";x:" + x - + ";y:" + y + ";w:" + w; + + + + + String posString = "p:" + currentPage + ";x:" + Math.floor(x) + + ";y:" + Math.ceil(y) + ";w:" + Math.ceil(w); logger.debug("Found Placeholder at: {}", posString); try { -- cgit v1.2.3