aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pdf-as-cli/src/test/java/at/gv/egiz/pdfas/cli/test/ProduceSignBlockImg.java8
-rw-r--r--pdf-as-pdfbox-2/src/main/java/at/gv/egiz/pdfas/lib/impl/signing/pdfbox2/PADESPDFBOXSigner.java16
2 files changed, 13 insertions, 11 deletions
diff --git a/pdf-as-cli/src/test/java/at/gv/egiz/pdfas/cli/test/ProduceSignBlockImg.java b/pdf-as-cli/src/test/java/at/gv/egiz/pdfas/cli/test/ProduceSignBlockImg.java
index e3a087b3..7fe7eda7 100644
--- a/pdf-as-cli/src/test/java/at/gv/egiz/pdfas/cli/test/ProduceSignBlockImg.java
+++ b/pdf-as-cli/src/test/java/at/gv/egiz/pdfas/cli/test/ProduceSignBlockImg.java
@@ -1,7 +1,5 @@
package at.gv.egiz.pdfas.cli.test;
-import iaik.x509.X509Certificate;
-
import java.awt.Image;
import java.awt.image.RenderedImage;
import java.io.File;
@@ -16,10 +14,11 @@ import at.gv.egiz.pdfas.lib.api.Configuration;
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;
public class ProduceSignBlockImg {
public static void main(String[] args) throws IOException, PDFASError, CertificateException {
- PdfAs pdfAs = PdfAsFactory.createPdfAs(new File("/home/afitzek/.pdfas"));
+ PdfAs pdfAs = PdfAsFactory.createPdfAs(new File("/home/tlenz/Projekte/pdfas4/config/default_4.2.0/"));
Configuration cfg = pdfAs.getConfiguration();
cfg.setValue("sig_obj.SIGNATURBLOCK_SMALL_DE.value.SIG_LABEL", "iVBORw0KGgoAAAANSUhEUgAAAMgAAADIAQAAAACFI5MzAAAA30lEQVR42u2XQRKDMAhFcZVj5KamuWmO4SqUfLQz " +
@@ -27,9 +26,10 @@ public class ProduceSignBlockImg {
"Jj4vj1xEJS8J+1J6cg5YFqZ7FWRxNU2HxfsKUzkdIkP5tmGEkfW/9wiizyUvAFFQH2e7NyBBgAAAABJRU5ErkJggg==");
SignParameter signParameter = PdfAsFactory.createSignParameter(cfg, null, null);
- X509Certificate crt = new X509Certificate(new FileInputStream("/home/afitzek/qualified.cer"));
+ X509Certificate crt = new X509Certificate(new FileInputStream("/home/tlenz/diverses/cert_debug/cert_debug_1.crt"));
Image img = pdfAs.generateVisibleSignaturePreview(signParameter, crt, 256);
ImageIO.write((RenderedImage) img, "png", new File("/tmp/block.png"));
+
}
}
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);