Signature Extraction
Contents
[
Hide
]
Extract signature certificate
Use this workflow when you need to save the certificate associated with an existing signature.
Steps
- Create a
PdfFileSignatureinstance and bind the signed PDF. - Select the signature name to inspect.
- Call
extractCertificateto open the certificate stream. - Copy the certificate bytes to an output file.
- Close the stream resources and the facade object.
Java example
public static void extractSignatureCertificate(Path inputFile, Path outputFile) throws Exception {
PdfFileSignature pdfSignature = new PdfFileSignature();
try {
pdfSignature.bindPdf(inputFile.toString());
SignatureName signatureName = pdfSignature.getSignatureNames().get_Item(0);
try (InputStream inputStream = pdfSignature.extractCertificate(signatureName);
OutputStream outputStream = Files.newOutputStream(outputFile)) {
inputStream.transferTo(outputStream);
}
} finally {
pdfSignature.close();
}
}
The current PdfFileSignatureExamples.java class does not include a dedicated Java sample for extracting a rendered signature image.