From b03842ccbef974873bb69d42c9e6cbc66403b432 Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Thu, 12 Jan 2023 16:07:30 +0100 Subject: fix(sigblock): optimize image rendering of signature blocks Issue: #65 --- .../lib/impl/signing/pdfbox2/PADESPDFBOXSigner.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'pdf-as-pdfbox-2') 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 d780aeec..c6499bc9 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 @@ -844,9 +844,7 @@ public class PADESPDFBOXSigner implements IPdfSigner, IConfigurationConstants { synchronized (PDDocument.class) { visualDoc = PDDocument.load(properties.getVisibleSignature()); } - // PDPageable pageable = new PDPageable(visualDoc); - final PDPage firstPage = visualDoc.getDocumentCatalog().getPages().get(0); final float stdRes = 72; final float targetRes = resolution; @@ -860,17 +858,21 @@ public class PADESPDFBOXSigner implements IPdfSigner, IConfigurationConstants { visualDoc.close(); pdfRenderer = null; - final BufferedImage cutOut = new BufferedImage((int) (position.getWidth() * factor), - (int) (position.getHeight() * factor), BufferedImage.TYPE_4BYTE_ABGR); + final BufferedImage cutOut = new BufferedImage( + (int) (position.getWidth() * factor), + (int) (position.getHeight() * factor), + BufferedImage.TYPE_4BYTE_ABGR); final Graphics2D graphics = (Graphics2D) cutOut.getGraphics(); - graphics.drawImage(outputImage, 0, 0, cutOut.getWidth(), cutOut.getHeight(), (int) (1 * factor), + graphics.drawImage(outputImage, 0, 0, cutOut.getWidth(), cutOut.getHeight(), + (int) (0 * factor), (int) (outputImage.getHeight() - (position.getHeight() + 1) * factor), - (int) ((1 + position.getWidth()) * factor), (int) (outputImage.getHeight() - - (position.getHeight() + 1) * factor + position.getHeight() * factor), + (int) ((position.getWidth() + 2) * factor), + (int) (outputImage.getHeight() - (position.getHeight()) * factor + position.getHeight() * factor), null); return cutOut; + } catch (final PdfAsException e) { logger.warn("PDF-AS Exception", e); throw ErrorExtractor.searchPdfAsError(e, status); -- cgit v1.2.3