From d2c8450b2e570c2ef6624b57ef6e048c88e99d37 Mon Sep 17 00:00:00 2001 From: Andreas Fitzek Date: Fri, 4 Nov 2016 11:00:41 +0100 Subject: use pdfbox saveIncremental method --- .../impl/signing/pdfbox2/PADESPDFBOXSigner.java | 63 +--------------------- 1 file changed, 1 insertion(+), 62 deletions(-) (limited to 'pdf-as-pdfbox-2/src') 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 da8654ce..37c8899d 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 @@ -571,55 +571,11 @@ public class PADESPDFBOXSigner implements IPdfSigner, IConfigurationConstants { } } - if (requestedSignature.isVisual()) { - - // if(requestedSignature.getSignaturePosition().) - /* - * PDAcroForm acroForm = - * doc.getDocumentCatalog().getAcroForm(); if (acroForm != - * null) { - * - * @SuppressWarnings("unchecked") List fields = - * acroForm.getFields(); PDSignatureField signatureField = - * null; - * - * if (fields != null) { for (PDField pdField : fields) { if - * (pdField instanceof PDSignatureField) { if - * (((PDSignatureField) pdField).getSignature() - * .getDictionary() .equals(signature.getDictionary())) { - * signatureField = (PDSignatureField) pdField; } } } } else - * { logger.warn( - * "Failed to apply rotation! [Cannot find Field list in acroForm!]" - * ); } - * - * if (signatureField != null) { if - * (signatureField.getWidget() != null) { if - * (signatureField.getWidget() - * .getAppearanceCharacteristics() == null) { - * PDAppearanceCharacteristicsDictionary dict = new - * PDAppearanceCharacteristicsDictionary( new - * COSDictionary()); signatureField.getWidget() - * .setAppearanceCharacteristics(dict); } - * - * if (signatureField.getWidget() - * .getAppearanceCharacteristics() != null) { - * signatureField.getWidget() - * .getAppearanceCharacteristics() .setRotation(90); } } } - * else { logger.warn( - * "Failed to apply rotation! [Cannot find signature Field!]" - * ); } } else { logger.warn( - * "Failed to apply rotation! [Cannot find acroForm!]" ); } - */ - } - - - - try { ByteArrayOutputStream bos = new ByteArrayOutputStream(); synchronized (doc) { - this.saveIncremental(bos, doc, pdfObject.getOriginalDocument().getInputStream(), signer); + doc.saveIncremental(bos); pdfObject.setSignedDocument(bos.toByteArray()); } @@ -651,23 +607,6 @@ public class PADESPDFBOXSigner implements IPdfSigner, IConfigurationConstants { } } - public void saveIncremental(OutputStream outStream, PDDocument doc, InputStream inStream, SignatureInterface signer) throws IOException{ - COSWriter writer = null; - try - { - writer = new COSWriter(outStream, inStream); - writer.write(doc, signer); - writer.close(); - } - finally - { - if (writer != null) - { - writer.close(); - } - } - } - @Override public PDFObject buildPDFObject(OperationStatus operationStatus) { return new PDFBOXObject(operationStatus); -- cgit v1.2.3