From f6d416f004ed294cff71e25358d7b37a9750a1b6 Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Fri, 13 Jan 2023 14:02:43 +0100 Subject: fix(sigblock): invalid preview in case of sig-blocks with more than half page height Issue: #68 ## Info: This is only a work-around, because it looks like a general issue in methods to create visual signature tables. T --- .../egiz/pdfas/cli/test/SigblockPreviewMain.java | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 pdf-as-cli/src/test/java/at/gv/egiz/pdfas/cli/test/SigblockPreviewMain.java (limited to 'pdf-as-cli/src') diff --git a/pdf-as-cli/src/test/java/at/gv/egiz/pdfas/cli/test/SigblockPreviewMain.java b/pdf-as-cli/src/test/java/at/gv/egiz/pdfas/cli/test/SigblockPreviewMain.java new file mode 100644 index 00000000..dba52463 --- /dev/null +++ b/pdf-as-cli/src/test/java/at/gv/egiz/pdfas/cli/test/SigblockPreviewMain.java @@ -0,0 +1,37 @@ +package at.gv.egiz.pdfas.cli.test; + +import java.awt.Image; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.FileInputStream; + +import javax.imageio.ImageIO; + +import at.gv.egiz.pdfas.lib.api.PdfAs; +import at.gv.egiz.pdfas.lib.api.PdfAsFactory; +import at.gv.egiz.pdfas.lib.api.sign.SignParameter; +import iaik.x509.X509Certificate; +import lombok.SneakyThrows; + +public class SigblockPreviewMain { + + private static final String PDFAS_CONFIG_DIR = "/home/tlenz/Projekte/pdfas4/config/default_4.2.0/"; + + + @SneakyThrows + public static void main(String[] args) throws Exception { + String cwd = System.getProperty("user.dir"); + File output = new File(cwd + File.separator + "build/output.png"); + X509Certificate cert = new X509Certificate(new FileInputStream("/home/tlenz/diverses/cert_debug/binding3.pem")); + + PdfAs pdfas = PdfAsFactory.createPdfAs(new File(PDFAS_CONFIG_DIR)); + SignParameter param = PdfAsFactory.createSignParameter(pdfas.getConfiguration(), null, null); + param.setSignatureProfileId("ERROR_LOGO"); + //param.setSignatureProfileId("SIGNATURBLOCK_DE"); + + + Image placeholder = pdfas.generateVisibleSignaturePreview(param, cert, 72 * 4); + ImageIO.write((BufferedImage)placeholder, "png", output); + } + +} -- cgit v1.2.3