PSPDFSigner


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

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 (readonly, nonatomic) NSString *_Nonnull filter;

    Swift

    var filter: String { get }
  • The PDF SubFilter entry value. Typical values are adbe.x509.rsa_sha1, adbe.pkcs7.detached, and adbe.pkcs7.sha1. Returns adbe.pkcs7.detached as default value, as it’s the only value supported for now.

    Declaration

    Objective-C

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

    Swift

    var subFilter: String { get }
  • 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 (assign, readwrite, nonatomic, nullable) NSString *displayName;

    Swift

    var displayName: 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 (assign, readwrite, nonatomic, nullable) NSString *reason;

    Swift

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

    Declaration

    Objective-C

    @property (assign, readwrite, 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/current/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 (assign, readwrite, nonatomic, nullable) PSPDFPrivateKey *privateKey;

    Swift

    var privateKey: PSPDFPrivateKey? { get set }
  • Deprecated

    Deprecated in PSPDFKit 8.0 for iOS. Instead of the externalSignatureDelegate property, you can use the delegate property for greater flexibility.

    A delegate to provide your own external signature (see PSPDFExternalSignature).

    Declaration

    Objective-C

    @property (readwrite, nonatomic)
        id<PSPDFExternalSignature> _Nullable externalSignatureDelegate;

    Swift

    weak var externalSignatureDelegate: PSPDFExternalSignature? { 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 (readwrite, nonatomic)
        id<PSPDFDocumentSignerDataSource> _Nullable dataSource;

    Swift

    weak var dataSource: PSPDFDocumentSignerDataSource? { 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 (readwrite, nonatomic)
        id<PSPDFDocumentSignerDelegate> _Nullable delegate;

    Swift

    weak var delegate: PSPDFDocumentSignerDelegate? { get set }
  • (Override) This method requests the signing certificate on demand. If the certificate is for instance password protected or must be fetched over the network, you can push a custom UIViewController on the passed navigation controller to display a custom UI while unlocking/fetching the certificate. If you are done, call the done handler with the fetched certificate and/or and error value. sourceController should be of type UINavigationController.

    Declaration

    Objective-C

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

    Swift

    func requestSigningCertificate(_ sourceController: Any, completionBlock: ((PSPDFX509?, Error?) -> Void)? = nil)
  • 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: PSPDFSignatureHashAlgorithm) -> Data
  • Deprecated

    Deprecated in PSPDFKit 8.0 for iOS. Call signFormElement:withCertificate:writeTo:completionBlock: instead and set the dataSource to configure the signature properties.

    (Optional) Signs the passed form element element and writes the signed document to path. If successful, returns YES for success, NO otherwise and error is set.

    Declaration

    Objective-C

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

    Swift

    func sign(_ element: PSPDFSignatureFormElement, withCertificate certificate: PSPDFX509, writeTo path: String, appearance signatureAppearance: PSPDFSignatureAppearance?, biometricProperties: PSPDFSignatureBiometricProperties?, completionBlock: ((Bool, PSPDFDocument?, Error?) -> Void)? = nil)

    Parameters

    element

    The signature form element to sign.

    certificate

    The PSPDFX509 instance that represents the certificate for signing the signature form element.

    path

    The destination path for the signed document.

    signatureAppearance

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

    biometricProperties
    The `PSPDFSignatureBiometricProperties` instance that adds enhanced security properties to the signature,
    

    like input pressure, type, etc.

  • Deprecated

    Deprecated in PSPDFKit 8.0 for iOS. Call signFormElement:withCertificate:writeToDataSink:completionBlock: instead and set the dataSource to configure the signature properties.

    (Optional) Signs the passed form element element and writes the signed document to dataSink. If successful, returns YES for success, NO otherwise and error is set.

    Declaration

    Objective-C

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

    Swift

    func sign(_ element: PSPDFSignatureFormElement, withCertificate certificate: PSPDFX509, writeTo dataSink: PSPDFDataSink, appearance signatureAppearance: PSPDFSignatureAppearance?, biometricProperties: PSPDFSignatureBiometricProperties?, completionBlock: ((Bool, PSPDFDataSink?, Error?) -> Void)? = nil)

    Parameters

    element

    The signature form element to sign.

    certificate

    The PSPDFX509 instance that represents the certificate for signing the signature form element.

    dataSink

    The destination data sink for the signed document.

    signatureAppearance

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

    biometricProperties
    The `PSPDFSignatureBiometricProperties` instance that adds enhanced security properties to the signature,
    

    like input pressure, type, etc.

  • 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: PSPDFSignatureFormElement, withCertificate certificate: PSPDFX509, writeTo dataSink: PSPDFDataSink, completionBlock: ((Bool, PSPDFDataSink?, Error?) -> Void)? = nil)

    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.

  • 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: PSPDFSignatureFormElement, withCertificate certificate: PSPDFX509, writeTo path: String, completionBlock: ((Bool, PSPDFDocument?, Error?) -> Void)? = nil)

    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.