PSPDFSigner

Objective-C


@interface PSPDFSigner
    : NSObject <PSPDFDocumentSignerDelegate, PSPDFDocumentSignerDataSource,
                PSPDFExternalSignature, NSSecureCoding>

Swift

class PDFSigner : NSObject, PDFDocumentSignerDelegate, PDFDocumentSignerDataSource, ExternalSignature, NSSecureCoding

PSPDFSigner is an abstract signer class. Override methods in subclasses as necessary.

  • The PDF filter name to use for this signer. Typical values are Adobe.PPKLite, Entrust.PPKEF, CICI.SignIt, and VeriSign.PPKVS. Returns Adobe.PPKLite as default value, as it’s the only value supported for now.

    Declaration

    Objective-C

    @property (nonatomic, readonly) NSString *_Nonnull filter;

    Swift

    var filter: String { get }
  • The PDF Digital Signature type. This translated directly to signature “SubFilter” type in the PDF.

    Returns .CMS by default, as this is the only value fully supported for now. Other values are .SHA1 (deprecated), and .Pades for advanced digital signatures which are only partially supported.

    Declaration

    Objective-C

    @property (nonatomic) PSPDFSignatureType signatureType;

    Swift

    var signatureType: PDFSignatureType { get set }
  • The name that will be displayed in the signature UI to identify this signer.

    Note

    This is not the signer’s name that will appear in the signature itself. The signer’s name always comes from the certificate that was used to sign the document.

    Declaration

    Objective-C

    @property (nonatomic, nullable) NSString *displayName;

    Swift

    var displayName: String? { get set }
  • The person or entity who signed the document. Important: For security reasons, if the API requires you to pass a certificate for signing, the CN of the certificate will be used and this field will be ignored.

    Declaration

    Objective-C

    @property (nonatomic, nullable) NSString *signersName;

    Swift

    var signersName: String? { get set }
  • The reason that will be embedded in every digital signature created by this instance of PSPDFSigner. For example, if you are signing a PDF contract you can set this property to I agree with the terms of this contract.

    Declaration

    Objective-C

    @property (nonatomic, nullable) NSString *reason;

    Swift

    var reason: String? { get set }
  • The place where this signature was created. For example, ‘Vienna’.

    Declaration

    Objective-C

    @property (nonatomic, nullable) NSString *location;

    Swift

    var location: String? { get set }
  • Private key from the certificate used to produce the signature by encrypting the message digest from the PDF file. (see details https://pspdfkit.com/guides/ios/features/digital-signatures/).

    Note

    If you don’t set a custom delegate object that will perform the actual signing, you must set this property.

    Declaration

    Objective-C

    @property (nonatomic, nullable) PSPDFPrivateKey *privateKey;

    Swift

    var privateKey: PSPDFPrivateKey? { get set }
  • The data source responsible for providing information about the digital signature, like the algorithms that will be used to hash and encrypt, whether biometric properties should also be embedded or not, or the visual appearance that the signature form element will have once the document is saved.

    Declaration

    Objective-C

    @property (nonatomic, weak) id<PSPDFDocumentSignerDataSource> _Nullable dataSource;

    Swift

    weak var dataSource: PDFDocumentSignerDataSource? { get set }
  • The delegate that will be called when the actual signing process is taking place. It gives the opportunity to customize the signature process in an asynchronous way. If this delegate is not set, a default digital signature will be created by using the privateKey property of the receiver.

    Declaration

    Objective-C

    @property (nonatomic, weak) id<PSPDFDocumentSignerDelegate> _Nullable delegate;

    Swift

    weak var delegate: PDFDocumentSignerDelegate? { get set }
  • Builds a document where element is prepared with a custom appearance and filled with contents of estimatedSize.

    Declaration

    Objective-C

    - (void)prepareFormElement:(nonnull PSPDFSignatureFormElement *)element
        toBeSignedWithAppearance:
            (nonnull PSPDFSignatureAppearance *)signatureAppearance
                        contents:(nonnull id<PSPDFSignatureContents>)contents
               writingToDataSink:(nonnull id<PSPDFDataSink>)dataSink
                      completion:
                          (nonnull PSPDFSignatureCreationBlock)completionBlock;

    Swift

    func prepare(_ element: SignatureFormElement, toBeSignedWith signatureAppearance: PSPDFSignatureAppearance, contents: PDFSignatureContents, writingTo dataSink: DataSink) async throws -> (Bool, DataSink)

    Parameters

    element

    The signature form element to sign.

    signatureAppearance

    The PSPDFSignatureAppearance instance that customizes how the signature will appear in the signed document. If nil, the default signature appearance will be used.

    contents

    An implementation of the PSPDFSignatureContents protocol that will be used to fill the digital signature contents. Typically, you will want to pass an instance of a PSPDFBlankSignatureContents to simply fill the signature contents with zeros.

    dataSink

    The destination data sink for the prepared document. - see: PSPDFDataSink.

    completionBlock

    A closure called after preparation succeeds or fails.

  • Embeds signature contents in a form signature element. It assumes that the document that contains element has been prepared for digital signatures by calling prepareFormElement:toBeSignedWithAppearance:contents:writingToDataSink:completion: before.

    Declaration

    Objective-C

    - (void)embedSignatureInFormElement:(nonnull PSPDFSignatureFormElement *)element
                           withContents:(nonnull id<PSPDFSignatureContents>)contents
                      writingToDataSink:(nonnull id<PSPDFDataSink>)dataSink
                             completion:(nonnull PSPDFSignatureCreationBlock)
                                            completionBlock;

    Swift

    func embedSignature(in element: SignatureFormElement, with contents: PDFSignatureContents, writingTo dataSink: DataSink) async throws -> (Bool, DataSink)

    Parameters

    element

    The signature form element to sign.

    contents

    An implementation of the PSPDFSignatureContents protocol that will be used to fill the digital signature contents.

    dataSink

    The destination data sink for the prepared document. - see: PSPDFDataSink.

    completionBlock

    A closure called after embedding succeeds or fails.

  • This method signs a piece of data using a private key and uses hashAlgorithm for the signature padding.

    Declaration

    Objective-C

    - (nonnull NSData *)signData:(nonnull NSData *)data
                      privateKey:(nonnull PSPDFPrivateKey *)privateKey
                   hashAlgorithm:(PSPDFSignatureHashAlgorithm)hashAlgorithm;

    Swift

    func sign(_ data: Data, privateKey: PSPDFPrivateKey, hashAlgorithm: PDFSignatureHashAlgorithm) -> Data
  • Signs the passed form element element and writes the signed document to dataSink. The completion block will signal if the result was successful, return the signed document, if it was signed correctly, and the signing error, if there’s any.

    Declaration

    Objective-C

    - (void)signFormElement:(nonnull PSPDFSignatureFormElement *)element
            withCertificate:(nonnull PSPDFX509 *)certificate
            writeToDataSink:(nonnull id<PSPDFDataSink>)dataSink
            completionBlock:(nullable void (^)(BOOL, id<PSPDFDataSink> _Nullable,
                                               NSError *_Nullable))completionBlock;

    Swift

    func sign(_ element: SignatureFormElement, withCertificate certificate: X509, writeTo dataSink: DataSink) async throws -> (Bool, DataSink)

    Parameters

    element

    The signature form element to sign.

    certificate

    The X509 certificate that will be used to create the digital signature.

    dataSink

    The destination data sink for the signed document. - see: PSPDFDataSink.

    completionBlock

    A closure called after signing succeeds or fails.

  • Signs the passed form element element and writes the signed document to dataSink. The completion block will signal if the result was successful, return the signed document, if it was signed correctly, and the signing error, if there’s any.

    Declaration

    Objective-C

    - (void)signFormElement:(nonnull PSPDFSignatureFormElement *)element
        withCertificateChain:(nonnull NSArray<PSPDFX509 *> *)certificateChain
             writeToDataSink:(nonnull id<PSPDFDataSink>)dataSink
             completionBlock:(nullable void (^)(BOOL, id<PSPDFDataSink> _Nullable,
                                                NSError *_Nullable))completionBlock;

    Swift

    func sign(_ element: SignatureFormElement, withCertificateChain certificateChain: [X509], writeTo dataSink: DataSink) async throws -> (Bool, DataSink)

    Parameters

    element

    The signature form element to sign.

    certificateChain

    The X509 certificate chain to create the digital signature. The first certificate is the signing certificate.

    dataSink

    The destination data sink for the signed document. - see: PSPDFDataSink.

    completionBlock

    A closure called after signing succeeds or fails.

  • Signs the passed form element element and writes the signed document to path. The completion block will signal if the result was successful, return the signed document, if it was signed correctly, and the signing error, if there’s any.

    Declaration

    Objective-C

    - (void)signFormElement:(nonnull PSPDFSignatureFormElement *)element
            withCertificate:(nonnull PSPDFX509 *)certificate
                    writeTo:(nonnull NSString *)path
            completionBlock:(nullable void (^)(BOOL, PSPDFDocument *_Nullable,
                                               NSError *_Nullable))completionBlock;

    Swift

    func sign(_ element: SignatureFormElement, withCertificate certificate: X509, writeTo path: String) async throws -> (Bool, Document)

    Parameters

    element

    The signature form element to sign.

    certificate

    The X509 certificate that will be used to create the digital signature.

    path

    The destination path for the signed document.

    completionBlock

    A closure called after signing succeeds or fails.

  • Signs the passed form element element and writes the signed document to path. The completion block will signal if the result was successful, return the signed document, if it was signed correctly, and the signing error, if there’s any.

    Declaration

    Objective-C

    - (void)signFormElement:(nonnull PSPDFSignatureFormElement *)element
        withCertificateChain:(nonnull NSArray<PSPDFX509 *> *)certificateChain
                     writeTo:(nonnull NSString *)path
             completionBlock:(nullable void (^)(BOOL, PSPDFDocument *_Nullable,
                                                NSError *_Nullable))completionBlock;

    Swift

    func sign(_ element: SignatureFormElement, withCertificateChain certificateChain: [X509], writeTo path: String) async throws -> (Bool, Document)

    Parameters

    element

    The signature form element to sign.

    certificateChain

    The X509 certificate chain to create the digital signature. The first certificate is the signing certificate.

    path

    The destination path for the signed document.

    completionBlock

    A closure called after signing succeeds or fails.

  • Undocumented

    Declaration

    Objective-C

    - (void)requestSigningCertificate:(id)sourceController completionBlock:(nullable void (^)(PSPDFX509 *_Nullable x509, NSError *_Nullable error))completionBlock;

    Swift

    func requestSigningCertificate(_ sourceController: Any) async throws -> X509