PdfFileSignature

Inheritance: java.lang.Object, com.aspose.pdf.facades.Facade com.aspose.pdf.facades.SaveableFacade com.aspose.pdf.facades.PdfFileSignature, com.aspose.pdf.facades.Facade, com.aspose.pdf.facades.SaveableFacade com.aspose.pdf.facades.PdfFileSignature, com.aspose.pdf.facades.SaveableFacade, com.aspose.pdf.facades.PdfFileSignature

All Implemented Interfaces: com.aspose.ms.System.IDisposable, IFacade, ISaveableFacade, Closeable, AutoCloseable

public final class PdfFileSignature extends SaveableFacade

Represents a class to sign a pdf file with a certificate.

Constructors

ConstructorDescription
PdfFileSignatureThe constructor of PdfFileSignature class.
PdfFileSignatureThe constructor of PdfFileSignature class.
PdfFileSignatureThe constructor of PdfFileSignature class.
PdfFileSignatureThe constructor of PdfFileSignature class.
PdfFileSignatureThe constructor of PdfFileSignature class.

Methods

MethodDescription
bindPdfBinds a Pdf stream for editing.
bindPdfBinds a Pdf file for editing.
certifyCertify the document with the MDP signature.
certifyCertify the document with the MDP signature which is placed in already presented signature field. Before signing signature field must be empty, i.e. field must not contain signature dictionary. Thus pdf document already has signature field, you should not supply the place to stamp the signature, corresponding page and rectangle are taken from signature field which is found by signature name (see sigName parameter).
closeCloses the facade.
containsSignatureChecks if the pdf has a digital signature or not.
containsUsageRightsChecks if the pdf has a usage rights or not.
coversWholeDocumentChecks if the signature covers the whole document.
coversWholeDocumentChecks if the signature covers the whole document.
disposeCloses the facade. This method is obsolete, use close() instead.
extractCertificateExtracts signature’s single X.509 certificate as a stream.
extractCertificateExtracts signature’s single X.509 certificate as a stream.
extractImageExtracts signature’s image.
extractImageExtracts signature’s image.
getAccessPermissionsReturns the access permissions value of certified document by the MDP signature type.
getBlankSignNamesGets the names of all empty signature fields.
getContactInfoGets the contact information of a signature.
getContactInfoGets the contact information of a signature.
getDateTimeGets the signature’s datetime.
getDateTimeGets the signature’s datetime.
getLocationGets the location of a signature.
getLocationGets the location of a signature.
getReasonGets the reason of a signature.
getReasonGets the reason of a signature.
getRevisionGets the revision of a signature.
getRevisionGets the revision of a signature.
getSignatureAppearanceGets a graphic appearance for the signature. Property value represents image file name.
getSignatureAppearanceStreamGets a graphic appearance for the signature. Property value represents image stream.
getSignatureNames/ *

/ * Gets the names of all not empty signatures. / *

/ *

/ *

 / * string inFile=TestPath + “example1.pdf”; / * PdfFileSignature pdfSign=new PdfFileSignature(); / * pdfSign.bindPdf(inFile); / * java.util.List names=pdfSign.getSignatureNames(); / * for(int i=0;i<names.size();i++) / * { / * System.out.println(“signature name:” + names[i]); / * System.out.println(“coverswholedocument:” + pdfSign.coversWholeDocument(names[i])); / * System.out.println(“revision:” + pdfSign.getRevision(names[i])); / * System.out.println(“verifysigned:” + pdfSign.verifySignature(names[i])); / * System.out.println(“reason:” + pdfSign.getReason(names[i])); / * System.out.println(“location:” + pdfSign.getLocation(names[i])); / * System.out.println(“datatime:” + pdfSign.getDateTime(names[i])); / * } / * System.out.println(“totalvision:” + pdfSign.GetTotalRevision()); / * / * 
/ *
getSignatureNamesGets the names of all not empty signatures. string inFile=TestPath + “example1.pdf”; PdfFileSignature pdfSign=new PdfFileSignature(); pdfSign.bindPdf(inFile); java.util.List names=pdfSign.getSignatureNames(); for(int i=0;i<names.size();i++) { System.out.println(“signature name:” + names[i]); System.out.println(“coverswholedocument:” + pdfSign.coversWholeDocument(names[i])); System.out.println(“revision:” + pdfSign.getRevision(names[i])); System.out.println(“verifysigned:” + pdfSign.verifySignature(names[i])); System.out.println(“reason:” + pdfSign.getReason(names[i])); System.out.println(“location:” + pdfSign.getLocation(names[i])); System.out.println(“datatime:” + pdfSign.getDateTime(names[i])); } System.out.println(“totalvision:” + pdfSign.GetTotalRevision());
getSignaturesInfoRetrieves information about all signatures algorithm present in the PDF document.
getSignerNameGets the name of person or organization who signing the pdf document.
getSignerNameGets the name of person or organization who signing the pdf document.
getSignNames

Gets the names of all not empty signatures.


getSignNames

Gets the names of all not empty signatures.


 String inFile=TestPath + “example1.pdf”; PdfFileSignature pdfSign=new PdfFileSignature(); pdfSign.bindPdf(inFile); ArrayList names=pdfSign.getSignNames(true); for(int i=0;i<names.Count;i++) { System.out.println(“signature name:"+(String)names[i]); System.out.println(“coverswholedocument:"+pdfSign.IsCoversWholeDocument((String)names[i])); System.out.println(“revision:"+pdfSign.GetRevision((String)names[i])); System.out.println(“verifysigned:"+pdfSign.VerifySigned((String)names[i])); System.out.println(“reason:"+pdfSign.GetReason((String)names[i])); System.out.println(“location:"+pdfSign.GetLocation((String)names[i])); System.out.println(“datatime:"+pdfSign.GetDateTime((String)names[i])); } System.out.println(“totalvision:"+pdfSign.GetTotalRevision()); 
getTotalRevisionGets the toltal revision.
isCertifiedGets the flag determining whether a document is certified or not.
isContainSignatureChecks if the pdf has a digital signature or not.
isCoversWholeDocumentChecks if the signature covers the whole document.
isLtvEnabledGets the LTV enabled flag.
removeSignatureRemove the signature according to the name of the signature. string inFile = TestPath + “example1.pdf”; PdfFileSignature pdfSign = new PdfFileSignature(); pdfSign.bindPdf(inFile); IList names = pdfSign.getSignatureNames(); for(int i = 0; i < names.size(); i++) { pdfSign.removeSignature(names[i]); } pdfSign.save(TestPath + “signed_removed.pdf”);
removeSignatureRemoves the signature according to the name of the signature. string inFile = TestPath + “example1.pdf”; PdfFileSignature pdfSign = new PdfFileSignature(); pdfSign.bindPdf(inFile); IList names = pdfSign.getSignatureNames(); for(int i = 0; i < names.size(); i++) { pdfSign.removeSignature(names[i], false); } pdfSign.save(TestPath + “signed_removed.pdf”);
removeSignature

Remove the signature according to the name of the signature.


 String inFile = TestPath + “example1.pdf”; PdfFileSignature pdfSign = new PdfFileSignature(); pdfSign.bindPdf(inFile); List names = pdfSign.getSignNames(); for(int i = 0; i < names.size(); i++) { pdfSign.removeSignature((String)names.get(i)); } pdfSign.save(TestPath + “signed_removed.pdf”); 
removeSignature

Removes the signature according to the name of the signature.


 String inFile = TestPath + “example1.pdf”; PdfFileSignature pdfSign = new PdfFileSignature(); pdfSign.BindPdf(inFile); List names = pdfSign.getSignNames(); for(int i = 0; i < names.size(); i++) { pdfSign.removeSignature((String)names.get(i), false); } pdfSign.save(TestPath + “signed_removed.pdf”); 
removeSignaturesRemoves all signatures. string inFile = TestPath + “example1.pdf”; var pdfSign = new PdfFileSignature(); pdfSign.bindPdf(inFile); pdfSign.removeSignatures(); pdfSign.save(TestPath + “signed_removed.pdf”);
removeUsageRightsRemoves the usage rights entry.
saveSave signed pdf file. Output filename must be provided before with the help of coresponding PdfFileSignature constructor.
saveSave signed pdf file. Output filename must be provided before with the help of coresponding PdfFileSignature constructor.
saveSave signed pdf file. Output filename must be provided before with the help of coresponding PdfFileSignature constructor.
setCertificateSet certificate file and password for signing routine.
setSignatureAppearanceSets a graphic appearance for the signature. Property value represents image file name.
setSignatureAppearanceStreamSets a graphic appearance for the signature. Property value represents image stream.
signSign the document with the given type signature.
signMake a signature on the pdf document.
signSign the document with the given type signature.
signSign the document with the given type signature which is placed in already presented signature field.
sign

Sign the document with the given type signature which is placed in already presented signature field. Before signing signature field must be empty, i.e. field must not contain signature dictionary. Thus pdf document already has signature field, you should not supply the place to stamp the signature, corresponding page and rectangle are taken from signature field which is found by signature name (see SigName parameter). Such data as signature reason, contact and location must be provided by corresponding properties of the Signature object sig.


 String inFile = TestPath + “example1.pdf”; String outFile = TestPath + “signature.pdf”; PKCS1 sig = new PKCS1(“certificate.pfx”, “password”); sig.setReason ( “Some reason”); sig.setContact ( “Smith”); sig.setLocation ( “New York”); PdfFileSignature pdfSign = new PdfFileSignature(inFile, outFile); pdfSign.setSignatureAppearance ( TestPath + “butterfly.jpg”); pdfSign.sign(“Signature1”, sig); pdfSign.save(); 
sign

Sign the document with the given type signature which is placed in already presented signature field. Before signing signature field must be empty, i.e. field must not contain signature dictionary. Thus pdf document already has signature field, you should not supply the place to stamp the signature, corresponding page and rectangle are taken from signature field which is found by signature name (see SigName parameter).


 String inFile = TestPath + “example1.pdf”; String outFile = TestPath + “signature.pdf”; PKCS1 sig = new PKCS1(“certificate.pfx”, “password”); PdfFileSignature pdfSign = new PdfFileSignature(inFile, outFile); pdfSign.setSignatureAppearance ( TestPath + “butterfly.jpg”); pdfSign.sign(“Signature1”, “Allen”, “success”, “ChangSha”, sig); pdfSign.save(); 
tryExtractCertificateExtracts signature’s single X.509 certificate as a stream.
tryExtractCertificateExtracts signature’s single X.509 certificate.
verifySignatureChecks the validity of a signature.
verifySignatureChecks the validity of a signature.
verifySignatureChecks the validity of a signature.
verifySignatureChecks the validity of a signature.
verifySignatureChecks the validity of a signature.
verifySignatureChecks the validity of a signature.
verifySignedChecks the validity of a signature. The method is deprecated and will be deleted in 25.1 version. Use VerifySignature method instead.

PdfFileSignature

public PdfFileSignature()

The constructor of PdfFileSignature class.

PdfFileSignature

The constructor of PdfFileSignature class.

PdfFileSignature

The constructor of PdfFileSignature class.

PdfFileSignature

The constructor of PdfFileSignature class.

PdfFileSignature

The constructor of PdfFileSignature class.

bindPdf

Binds a Pdf stream for editing.

bindPdf

Binds a Pdf file for editing.

certify

Certify the document with the MDP signature.

certify

Certify the document with the MDP signature which is placed in already presented signature field. Before signing signature field must be empty, i.e. field must not contain signature dictionary. Thus pdf document already has signature field, you should not supply the place to stamp the signature, corresponding page and rectangle are taken from signature field which is found by signature name (see sigName parameter).

close

public void close()

Closes the facade.

containsSignature

public boolean containsSignature()

Checks if the pdf has a digital signature or not.

Returns: Return a result of bool type.

containsUsageRights

public boolean containsUsageRights()

Checks if the pdf has a usage rights or not.

Returns: Returns a result of bool type.

coversWholeDocument

Checks if the signature covers the whole document.

coversWholeDocument

Checks if the signature covers the whole document.

dispose

@Deprecated public void dispose()

Closes the facade. This method is obsolete, use close() instead.

extractCertificate

Extracts signature’s single X.509 certificate as a stream.

extractCertificate

Extracts signature’s single X.509 certificate as a stream.

extractImage

Extracts signature’s image.

extractImage

Extracts signature’s image.

getAccessPermissions

public DocMDPAccessPermissions getAccessPermissions()

Returns the access permissions value of certified document by the MDP signature type.

Returns: PdfException If the document is being certified, then returns access permissions value; otherwise, is thrown. @see com.aspose.pdf.DocMDPAccessPermissions

getBlankSignNames

@Deprecated public List < String > getBlankSignNames()

Gets the names of all empty signature fields.

Returns: Return a arrayList. @deprecated Use GetBlankSignatureNames() instead.

getContactInfo

Gets the contact information of a signature.

getContactInfo

Gets the contact information of a signature.

getDateTime

Gets the signature’s datetime.

getDateTime

Gets the signature’s datetime.

getLocation

Gets the location of a signature.

getLocation

Gets the location of a signature.

getReason

Gets the reason of a signature.

getReason

Gets the reason of a signature.

getRevision

Gets the revision of a signature.

getRevision

Gets the revision of a signature.

getSignatureAppearance

public String getSignatureAppearance()

Gets a graphic appearance for the signature. Property value represents image file name.

Returns: String value

getSignatureAppearanceStream

public InputStream getSignatureAppearanceStream()

Gets a graphic appearance for the signature. Property value represents image stream.

Returns: InputStream element

getSignatureNames

public final com.aspose.ms.System.Collections.Generic.IGenericList< SignatureName > getSignatureNames()

/ *

/ * Gets the names of all not empty signatures. / *

/ *

/ *

 / * string inFile=TestPath + “example1.pdf”; / * PdfFileSignature pdfSign=new PdfFileSignature(); / * pdfSign.bindPdf(inFile); / * java.util.List names=pdfSign.getSignatureNames(); / * for(int i=0;i<names.size();i++) / * { / * System.out.println(“signature name:” + names[i]); / * System.out.println(“coverswholedocument:” + pdfSign.coversWholeDocument(names[i])); / * System.out.println(“revision:” + pdfSign.getRevision(names[i])); / * System.out.println(“verifysigned:” + pdfSign.verifySignature(names[i])); / * System.out.println(“reason:” + pdfSign.getReason(names[i])); / * System.out.println(“location:” + pdfSign.getLocation(names[i])); / * System.out.println(“datatime:” + pdfSign.getDateTime(names[i])); / * } / * System.out.println(“totalvision:” + pdfSign.GetTotalRevision()); / * / * 
/ *

Returns: Return an IList. /

getSignatureNames

public final com.aspose.ms.System.Collections.Generic.IGenericList< SignatureName > getSignatureNames(boolean onlyActive)

Gets the names of all not empty signatures. string inFile=TestPath + “example1.pdf”; PdfFileSignature pdfSign=new PdfFileSignature(); pdfSign.bindPdf(inFile); java.util.List names=pdfSign.getSignatureNames(); for(int i=0;i<names.size();i++) { System.out.println(“signature name:” + names[i]); System.out.println(“coverswholedocument:” + pdfSign.coversWholeDocument(names[i])); System.out.println(“revision:” + pdfSign.getRevision(names[i])); System.out.println(“verifysigned:” + pdfSign.verifySignature(names[i])); System.out.println(“reason:” + pdfSign.getReason(names[i])); System.out.println(“location:” + pdfSign.getLocation(names[i])); System.out.println(“datatime:” + pdfSign.getDateTime(names[i])); } System.out.println(“totalvision:” + pdfSign.GetTotalRevision());

Parameters:

ParameterTypeDescription
onlyActiveif true, return only active signatures; otherwise, return all signatures.

Returns: Return an IList.

getSignaturesInfo

public final List <com.aspose.pdf.engine.security.SignatureAlgorithmInfo> getSignaturesInfo()

Retrieves information about all signatures algorithm present in the PDF document.

Returns: A list of {@link SignatureAlgorithmInfo} instances containing information about each signature.

getSignerName

Gets the name of person or organization who signing the pdf document.

getSignerName

Gets the name of person or organization who signing the pdf document.

getSignNames

public final List < String > getSignNames()

Gets the names of all not empty signatures.


Returns: Return a arrayList.

getSignNames

@Deprecated public List < String > getSignNames(boolean onlyActive)

Gets the names of all not empty signatures.


 String inFile=TestPath + "example1.pdf"; PdfFileSignature pdfSign=new PdfFileSignature(); pdfSign.bindPdf(inFile); ArrayList names=pdfSign.getSignNames(true); for(int i=0;i

Parameters:

Parameter Type Description
onlyActive boolean value, if true, return only active signatures; otherwise, return all signatures.

Returns: Return a arrayList. @deprecated The method can produce the same signature names, which cannot be distinguished during verification. Use getSignatureNames(boolean onlyActive) instead.

getTotalRevision

public int getTotalRevision()

Gets the toltal revision.

Returns: Return the total number of signature revision.

isCertified

public boolean isCertified()

Gets the flag determining whether a document is certified or not.

Returns: boolean value

isContainSignature

@Deprecated public boolean isContainSignature()

Checks if the pdf has a digital signature or not.

Returns: Return a result of bool type.

isCoversWholeDocument

Checks if the signature covers the whole document.

isLtvEnabled

public final boolean isLtvEnabled()

Gets the LTV enabled flag.

Returns: boolean value

removeSignature

Remove the signature according to the name of the signature. string inFile = TestPath + “example1.pdf”; PdfFileSignature pdfSign = new PdfFileSignature(); pdfSign.bindPdf(inFile); IList names = pdfSign.getSignatureNames(); for(int i = 0; i < names.size(); i++) { pdfSign.removeSignature(names[i]); } pdfSign.save(TestPath + “signed_removed.pdf”);

removeSignature

Removes the signature according to the name of the signature. string inFile = TestPath + “example1.pdf”; PdfFileSignature pdfSign = new PdfFileSignature(); pdfSign.bindPdf(inFile); IList names = pdfSign.getSignatureNames(); for(int i = 0; i < names.size(); i++) { pdfSign.removeSignature(names[i], false); } pdfSign.save(TestPath + “signed_removed.pdf”);

removeSignature

Remove the signature according to the name of the signature.


 String inFile = TestPath + "example1.pdf"; PdfFileSignature pdfSign = new PdfFileSignature(); pdfSign.bindPdf(inFile); List names = pdfSign.getSignNames(); for(int i = 0; i < names.size(); i++) { pdfSign.removeSignature((String)names.get(i)); } pdfSign.save(TestPath + "signed_removed.pdf"); 

removeSignature

Removes the signature according to the name of the signature.


 String inFile = TestPath + "example1.pdf"; PdfFileSignature pdfSign = new PdfFileSignature(); pdfSign.BindPdf(inFile); List names = pdfSign.getSignNames(); for(int i = 0; i < names.size(); i++) { pdfSign.removeSignature((String)names.get(i), false); } pdfSign.save(TestPath + "signed_removed.pdf"); 

removeSignatures

public final void removeSignatures()

Removes all signatures. string inFile = TestPath + “example1.pdf”; var pdfSign = new PdfFileSignature(); pdfSign.bindPdf(inFile); pdfSign.removeSignatures(); pdfSign.save(TestPath + “signed_removed.pdf”);

removeUsageRights

public void removeUsageRights()

Removes the usage rights entry.

save

@Deprecated public void save()

Save signed pdf file. Output filename must be provided before with the help of coresponding PdfFileSignature constructor.

save

Save signed pdf file. Output filename must be provided before with the help of coresponding PdfFileSignature constructor.

save

Save signed pdf file. Output filename must be provided before with the help of coresponding PdfFileSignature constructor.

setCertificate

Set certificate file and password for signing routine.

setSignatureAppearance

Sets a graphic appearance for the signature. Property value represents image file name.

setSignatureAppearanceStream

Sets a graphic appearance for the signature. Property value represents image stream.

sign

Sign the document with the given type signature.

sign

Make a signature on the pdf document.

sign

Sign the document with the given type signature.

sign

Sign the document with the given type signature which is placed in already presented signature field.

sign

Sign the document with the given type signature which is placed in already presented signature field. Before signing signature field must be empty, i.e. field must not contain signature dictionary. Thus pdf document already has signature field, you should not supply the place to stamp the signature, corresponding page and rectangle are taken from signature field which is found by signature name (see SigName parameter). Such data as signature reason, contact and location must be provided by corresponding properties of the Signature object sig.


 String inFile = TestPath + "example1.pdf"; String outFile = TestPath + "signature.pdf"; PKCS1 sig = new PKCS1("certificate.pfx", "password"); sig.setReason ( "Some reason"); sig.setContact ( "Smith"); sig.setLocation ( "New York"); PdfFileSignature pdfSign = new PdfFileSignature(inFile, outFile); pdfSign.setSignatureAppearance ( TestPath + "butterfly.jpg"); pdfSign.sign("Signature1", sig); pdfSign.save(); 

sign

Sign the document with the given type signature which is placed in already presented signature field. Before signing signature field must be empty, i.e. field must not contain signature dictionary. Thus pdf document already has signature field, you should not supply the place to stamp the signature, corresponding page and rectangle are taken from signature field which is found by signature name (see SigName parameter).


 String inFile = TestPath + "example1.pdf"; String outFile = TestPath + "signature.pdf"; PKCS1 sig = new PKCS1("certificate.pfx", "password"); PdfFileSignature pdfSign = new PdfFileSignature(inFile, outFile); pdfSign.setSignatureAppearance ( TestPath + "butterfly.jpg"); pdfSign.sign("Signature1", "Allen", "success", "ChangSha", sig); pdfSign.save(); 

tryExtractCertificate

Extracts signature’s single X.509 certificate as a stream.

tryExtractCertificate

Extracts signature’s single X.509 certificate.

verifySignature

Checks the validity of a signature.

verifySignature

Checks the validity of a signature.

verifySignature

Checks the validity of a signature.

verifySignature

Checks the validity of a signature.

verifySignature

Checks the validity of a signature.

verifySignature

Checks the validity of a signature.

verifySigned

Checks the validity of a signature. The method is deprecated and will be deleted in 25.1 version. Use VerifySignature method instead.