SignatureProfile Enum
Lists signature profiles.
Declaration
public enum SignatureProfile extends Enum<SignatureProfile> implements IIntEnum
Members
| Name | Description |
|---|---|
PDF
|
A standard PDF signature in PKCS#7 format. |
P_AD_ES_BES
|
A PAdES (PDF Advanced Electronic Signatures) signature with the Basic Electronic Signature (BES) profile. |
fromValue(int value)
|
Returns the |
getName()
|
Returns the name of the |
getValue()
|
Returns the integer value of the |
toString()
|
Returns the string representation of the |
valueOf(String name)
|
Returns the |
values()
|
Returns an array of all |
Remarks
Call the Pkcs7DocumentSigner.getProfile() method to get the signature profile. Call the Pkcs7DocumentSigner.setProfile(value) method to specify the profile.
Refer to the following help topic for additional information: Sign PDF Documents — PDF Document API for Java.
Example
Create a PAdES Signature
The following code snippet creates a PAdES signature:
import java.io.*;
import java.nio.file.*;
import com.devexpress.docs.pdf.*;
import com.devexpress.system.drawing.*;
public class Main {
public static void main(String[] args) throws Exception {
try (InputStream inputStream = Files.newInputStream(Path.of("Document.pdf"));
PdfDocument pdfDocument = new PdfDocument(inputStream);
InputStream certificateStream = Files.newInputStream(Path.of("certificate.pfx"))) {
// Create a signature field and bind it to a widget on the first page.
SignatureField signatureField = new SignatureField("Signature1");
pdfDocument.getFields().add(signatureField);
pdfDocument.getPages().getFirst().getAnnotations().add(
new SignatureWidgetAnnotation(signatureField, new RectangleF(20, 400, 200, 60)));
// Specify the certificate and signer information.
SignatureOptions options = new SignatureOptions();
options.setCertificate(certificateStream, "CERTIFICATE_PASSWORD");
options.setReason("Approved");
// Create a PAdES signature.
Pkcs7DocumentSigner signer = new Pkcs7DocumentSigner(options);
signer.setProfile(SignatureProfile.P_AD_ES_BES);
pdfDocument.addSignature(signatureField, signer);
Files.createDirectories(Path.of("output"));
try (OutputStream outputStream = Files.newOutputStream(Path.of("output", "Document.pdf"))) {
pdfDocument.save(outputStream);
}
}
}
}