Package org.jpedal.tools
Class PdfSigner
java.lang.Object
org.jpedal.tools.PdfSigner
Digitally signs PDF documents
Example usage:
PdfSigner.signPdf(
"/input.pdf",
"/output.pdf",
"1234",
"/keystore.p12",
"John Doe",
"London",
"Accepting Agreement"
);
Note: Your keystore must meet the following conditions to be suitable for signing:
- The keystore must be a PKCS#12 file containing your private key and X.509 certificate
- The certificate must be valid
- The certificate signature algorithm must be SHA256 RSA
- The private key usage must be digitalSignature
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Document Access Permissions (As specified in PDF 12.8.2.2.2 - Table 257) -
Field Summary
Modifier and TypeFieldDescriptionstatic final int
The default signature size if none is specified. -
Method Summary
Modifier and TypeMethodDescriptionstatic void
signPdf
(String input, String output, String password, String keystore, String name, String location, String reason) Signs the PDF file and writes the result to diskstatic void
signPdf
(String input, String output, String password, String keystore, String name, String location, String reason, int signatureSize) Signs the PDF file and writes the result to diskstatic void
signPdf
(String input, String output, String password, String keystore, String name, String location, String reason, PdfSigner.ACCESS_PERMISSION permissions) Signs the PDF file and writes the result to diskstatic void
signPdf
(String input, String output, String password, String keystore, String name, String location, String reason, PdfSigner.ACCESS_PERMISSION permissions, int signatureSize) Signs the PDF file and writes the result to disk
-
Field Details
-
DEFAULT_SIGNATURE_SIZE
public static final int DEFAULT_SIGNATURE_SIZEThe default signature size if none is specified.- See Also:
-
-
Method Details
-
signPdf
public static void signPdf(String input, String output, String password, String keystore, String name, String location, String reason) throws IOException Signs the PDF file and writes the result to disk- Parameters:
input
- The file location of the document to be signedoutput
- The file location of the document which is to be producedpassword
- The password for your key storekeystore
- The file location of your key storename
- The name of the person/business signing the documentlocation
- The real-world location of where the document is said to be signedreason
- The reason for signing the document- Throws:
IOException
- IOException
-
signPdf
public static void signPdf(String input, String output, String password, String keystore, String name, String location, String reason, PdfSigner.ACCESS_PERMISSION permissions) throws IOException Signs the PDF file and writes the result to disk- Parameters:
input
- The file location of the document to be signedoutput
- The file location of the document which is to be producedpassword
- The password for your key storekeystore
- The file location of your key storename
- The name of the person/business signing the documentlocation
- The real-world location of where the document is said to be signedreason
- The reason for signing the documentpermissions
- The Document Access Permissions level (seePdfSigner.ACCESS_PERMISSION
- Throws:
IOException
- IOException
-
signPdf
public static void signPdf(String input, String output, String password, String keystore, String name, String location, String reason, int signatureSize) throws IOException Signs the PDF file and writes the result to disk- Parameters:
input
- The file location of the document to be signedoutput
- The file location of the document which is to be producedpassword
- The password for your key storekeystore
- The file location of your key storename
- The name of the person/business signing the documentlocation
- The real-world location of where the document is said to be signedreason
- The reason for signing the documentsignatureSize
- The size of the /Contents value in the signature dictionary- Throws:
IOException
- IOException
-
signPdf
public static void signPdf(String input, String output, String password, String keystore, String name, String location, String reason, PdfSigner.ACCESS_PERMISSION permissions, int signatureSize) throws IOException Signs the PDF file and writes the result to disk- Parameters:
input
- The file location of the document to be signedoutput
- The file location of the document which is to be producedpassword
- The password for your key storekeystore
- The file location of your key storename
- The name of the person/business signing the documentlocation
- The real-world location of where the document is said to be signedreason
- The reason for signing the documentpermissions
- The Document Access Permissions level (seePdfSigner.ACCESS_PERMISSION
signatureSize
- The size of the /Contents value in the signature dictionary- Throws:
IOException
- IOException
-