/** * Add parameters of signature to be created externally. See * {@link #saveIncrementalForExternalSigning(OutputStream)} method description on external * signature creation scenario details. * <p> * Only one signature may be added in a document. To sign several times, * load document, add signature, save incremental and close again. * * @param sigObject is the PDSignatureField model * @param options signature options * @throws IOException if there is an error creating required fields * @throws IllegalStateException if one attempts to add several signature * fields. */ public void addSignature(PDSignature sigObject, SignatureOptions options) throws IOException { addSignature(sigObject, null, options); }
/** * Add parameters of signature to be created externally using default signature options. See * {@link #saveIncrementalForExternalSigning(OutputStream)} method description on external * signature creation scenario details. * <p> * Only one signature may be added in a document. To sign several times, * load document, add signature, save incremental and close again. * * @param sigObject is the PDSignatureField model * @throws IOException if there is an error creating required fields * @throws IllegalStateException if one attempts to add several signature * fields. */ public void addSignature(PDSignature sigObject) throws IOException { addSignature(sigObject, new SignatureOptions()); }
/** * Add a signature to be created using the instance of given interface. * <p> * Only one signature may be added in a document. To sign several times, * load document, add signature, save incremental and close again. * * @param sigObject is the PDSignatureField model * @param signatureInterface is an interface whose implementation provides * signing capabilities. Can be null if external signing if used. * @throws IOException if there is an error creating required fields * @throws IllegalStateException if one attempts to add several signature * fields. */ public void addSignature(PDSignature sigObject, SignatureInterface signatureInterface) throws IOException { addSignature(sigObject, signatureInterface, new SignatureOptions()); }
/** * Prepares the TimeStamp-Signature and starts the saving-process. * * @param document given Pdf * @param output Where the file will be written * @throws IOException */ public void signDetached(PDDocument document, OutputStream output) throws IOException { int accessPermissions = SigUtils.getMDPPermission(document); if (accessPermissions == 1) { throw new IllegalStateException( "No changes to the document are permitted due to DocMDP transform parameters dictionary"); } // create signature dictionary PDSignature signature = new PDSignature(); signature.setType(COSName.DOC_TIME_STAMP); signature.setFilter(PDSignature.FILTER_ADOBE_PPKLITE); signature.setSubFilter(COSName.getPDFName("ETSI.RFC3161")); // No certification allowed because /Reference not allowed in signature directory // see ETSI EN 319 142-1 Part 1 and ETSI TS 102 778-4 // http://www.etsi.org/deliver/etsi_en%5C319100_319199%5C31914201%5C01.01.00_30%5Cen_31914201v010100v.pdf // http://www.etsi.org/deliver/etsi_ts/102700_102799/10277804/01.01.01_60/ts_10277804v010101p.pdf // register signature dictionary and sign interface document.addSignature(signature, this); // write incremental (only for signing purpose) document.saveIncremental(output); }
document.addSignature(signature); ExternalSigningSupport externalSigning = document.saveIncrementalForExternalSigning(output); document.addSignature(signature, this, signatureOptions);
/** * Add parameters of signature to be created externally. See * {@link #saveIncrementalForExternalSigning(OutputStream)} method description on external * signature creation scenario details. * * @param sigObject is the PDSignatureField model * @param options signature options * @throws IOException if there is an error creating required fields */ public void addSignature(PDSignature sigObject, SignatureOptions options) throws IOException { addSignature(sigObject, null, options); }
/** * Add parameters of signature to be created externally. See * {@link #saveIncrementalForExternalSigning(OutputStream)} method description on external * signature creation scenario details. * <p> * Only one signature may be added in a document. To sign several times, * load document, add signature, save incremental and close again. * * @param sigObject is the PDSignatureField model * @param options signature options * @throws IOException if there is an error creating required fields * @throws IllegalStateException if one attempts to add several signature * fields. */ public void addSignature(PDSignature sigObject, SignatureOptions options) throws IOException { addSignature(sigObject, null, options); }
signatureOptions.setVisualSignature(visibleSignatureProperties.getVisibleSignature()); signatureOptions.setPage(visibleSignatureProperties.getPage() - 1); doc.addSignature(signature, signatureInterface, signatureOptions); doc.addSignature(signature, signatureInterface);
signatureOptions.setVisualSignature(createVisualSignatureTemplate(doc, 0, rect)); signatureOptions.setPage(0); doc.addSignature(signature, signatureInterface, signatureOptions);
/** * Add a signature to be created using the instance of given interface. * * @param sigObject is the PDSignatureField model * @param signatureInterface is an interface which provides signing capabilities * @throws IOException if there is an error creating required fields */ public void addSignature(PDSignature sigObject, SignatureInterface signatureInterface) throws IOException { addSignature(sigObject, signatureInterface, new SignatureOptions()); }
/** * Add parameters of signature to be created externally using default signature options. See * {@link #saveIncrementalForExternalSigning(OutputStream)} method description on external * signature creation scenario details. * * @param sigObject is the PDSignatureField model * @throws IOException if there is an error creating required fields */ public void addSignature(PDSignature sigObject) throws IOException { addSignature(sigObject, new SignatureOptions()); }
byte[] inputBytes = IOUtils.toByteArray(inputStream); PDDocument document = PDDocument.load(new ByteArrayInputStream(inputBytes)); ... document.addSignature(new PDSignature(this.dts.getDocumentTimeStamp()), this); saveIncremental(new FileOutputStream("C:/result.pdf"), new ByteArrayInputStream(inputBytes), document, this); document.close();
/** * Add parameters of signature to be created externally using default signature options. See * {@link #saveIncrementalForExternalSigning(OutputStream)} method description on external * signature creation scenario details. * <p> * Only one signature may be added in a document. To sign several times, * load document, add signature, save incremental and close again. * * @param sigObject is the PDSignatureField model * @throws IOException if there is an error creating required fields * @throws IllegalStateException if one attempts to add several signature * fields. */ public void addSignature(PDSignature sigObject) throws IOException { addSignature(sigObject, new SignatureOptions()); }
/** * Add a signature to be created using the instance of given interface. * <p> * Only one signature may be added in a document. To sign several times, * load document, add signature, save incremental and close again. * * @param sigObject is the PDSignatureField model * @param signatureInterface is an interface whose implementation provides * signing capabilities. Can be null if external signing if used. * @throws IOException if there is an error creating required fields * @throws IllegalStateException if one attempts to add several signature * fields. */ public void addSignature(PDSignature sigObject, SignatureInterface signatureInterface) throws IOException { addSignature(sigObject, signatureInterface, new SignatureOptions()); }
PDDocument document = PDDocument.load(inputStream); ... document.addSignature(new PDSignature(this.dts.getDocumentTimeStamp()), this); document.saveIncremental(new FileOutputStream("C:/result.pdf")); document.close();
PDDocument pdf = PDDocument.load(inputFile); MessageDigest digest = MessageDigest.getInstance("SHA-256"); TSAClient tsaClient = new TSAClient(new URL("your time stamp authority"), null, null, digest); pdf.addSignature(signature, new TimestampSignatureImpl(tsaClient)); pdf.saveIncremental(new FileOutputStream(outputFile)); pdf.close();
pdDocument.addSignature(pdSignature, signatureInterface);
/** * Prepares the TimeStamp-Signature and starts the saving-process. * * @param document given Pdf * @param output Where the file will be written * @throws IOException */ public void signDetached(PDDocument document, OutputStream output) throws IOException { int accessPermissions = SigUtils.getMDPPermission(document); if (accessPermissions == 1) { throw new IllegalStateException( "No changes to the document are permitted due to DocMDP transform parameters dictionary"); } // create signature dictionary PDSignature signature = new PDSignature(); signature.setType(COSName.DOC_TIME_STAMP); signature.setFilter(PDSignature.FILTER_ADOBE_PPKLITE); signature.setSubFilter(COSName.getPDFName("ETSI.RFC3161")); // No certification allowed because /Reference not allowed in signature directory // see ETSI EN 319 142-1 Part 1 and ETSI TS 102 778-4 // http://www.etsi.org/deliver/etsi_en%5C319100_319199%5C31914201%5C01.01.00_30%5Cen_31914201v010100v.pdf // http://www.etsi.org/deliver/etsi_ts/102700_102799/10277804/01.01.01_60/ts_10277804v010101p.pdf // register signature dictionary and sign interface document.addSignature(signature, this); // write incremental (only for signing purpose) document.saveIncremental(output); }
document.addSignature(signature); ExternalSigningSupport externalSigning = document.saveIncrementalForExternalSigning(output); document.addSignature(signature, this, signatureOptions);
addSignature(sigField.getSignature(), signatureInterface, options);