From 252703c09a6ab591382d443cda5e7a910ff1d584 Mon Sep 17 00:00:00 2001 From: Alexander Marsalek Date: Fri, 25 Jun 2021 09:12:35 +0200 Subject: test for issue #47 --- .../pdfas/cli/test/SignaturBlockParameterTest.java | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'pdf-as-cli/src/test/java/at') diff --git a/pdf-as-cli/src/test/java/at/gv/egiz/pdfas/cli/test/SignaturBlockParameterTest.java b/pdf-as-cli/src/test/java/at/gv/egiz/pdfas/cli/test/SignaturBlockParameterTest.java index 5689b080..f723a6c1 100644 --- a/pdf-as-cli/src/test/java/at/gv/egiz/pdfas/cli/test/SignaturBlockParameterTest.java +++ b/pdf-as-cli/src/test/java/at/gv/egiz/pdfas/cli/test/SignaturBlockParameterTest.java @@ -231,6 +231,42 @@ public class SignaturBlockParameterTest { //expected: but was: } + + @Test + public void testWithTextAfterVariable() throws IOException, PDFASError, PdfAsException { + + PdfAs pdfas = PdfAsFactory.createPdfAs(new File(getPath("pdfas-config"))); + Configuration config = pdfas.getConfiguration(); + + + byte[] input = IOUtils.toByteArray(new FileInputStream(getPath("simple_rotated_0.pdf"))); + + IPlainSigner signer = new PAdESSignerKeystore(getPath("test.p12"), KS_ALIAS, KS_PASS, KS_KEY_PASS, KS_TYPE); + + String profile = "SIGNATURBLOCK_DE_NOTE_DYNAMIC_WITH_TEXT_AFTER_VARIABLE"; + System.out.println("Testing " + profile); + + DataSource source = new ByteArrayDataSource(input); + String outFile = getPath("out") + "/" + profile + "-umlaute.pdf"; + FileOutputStream fos = new FileOutputStream(outFile); + SignParameter signParameter = PdfAsFactory.createSignParameter( + config, source, fos); + + Map map = new HashMap<>(); + map.put("subject", "TEST123"); + map.put("foo", "baräöÜ"); + signParameter.setDynamicSignatureBlockArguments(map); + signParameter.setPlainSigner(signer); + signParameter.setSignatureProfileId(profile); + + SignResult result = pdfas.sign(signParameter); + + fos.close(); + String name = getName(outFile, "PDF-AS Signatur1"); + Assert.assertEquals("Andreas Fitzek ECC text after variable", name); + //expected: but was: + } + private String getName(String fileName, String sigFieldName) throws IOException { PDDocument pdDoc = PDDocument.load(new File(fileName)); PDSignature signature = null; -- cgit v1.2.3