Signatures in iOS Viewer
This section only applies if you licensed the Annotations and Digital Signatures components before 1 May 2021. In this case, PSPDFKit comes with a ready-to-use user interface that allows you to provide digital signing capabilities inside your apps. In all other cases, digital signatures can be created programmatically.
When creating a signature in the UI, you can provide a certificate or draw an ink signature, or both. The document is only digitally signed if a certificate has been provided. If, in addition to selecting the certificate, an ink signature was drawn, it will be embedded in the appearance of the signature form element. If no certificate has been provided, only the ink signature is added to the document, and the document won’t be digitally signed.
By default, the user is able to select a certificate if there are
registeredSignersavailable. This behavior can be customized via
Signing with a Form Element
If there are no stored signatures in the shared
SignatureStore, then tapping an empty signature form element shows a
SignatureViewController, which is where you can both sign a document with an ink signature and assign a certificate to your signature.
If there are already stored signatures, a
SignatureSelectorViewController is shown instead, allowing you to either choose an existing signature or create a new one.
Signing without a Form Element
If a document doesn’t have a signature form element, you can still digitally sign it. The way to initiate this flow is to tap on the signature toolbar button and then select or create a signature, as shown above. If you added a certificate to the signature, you’ll be asked to select the signature placement on the page; otherwise, the signature is placed into the document and you can move and resize it to your liking. After making the selection, you’ll be asked for the password of the certificate. Finally, after entering the password, the document will be signed.
Ink Signature Behavior
There’s a difference between signature form elements that have been signed with an ink signature only and form elements signed with a digital signature (which might also contain an ink signature). You can only add one or the other to a single signature form element. A signature form element is considered signed whenever there’s an overlapping ink signature on it, or if it contains a digital signature. If there’s an existing ink signature in a signature form element, you’ll first need to delete it before you can add a digital signature to the element.
Only Allow Digital Signing
By default, users can create both an ink signature without a signer and a digital signature by selecting a signer in
SignatureViewController. There might be use cases where you don’t want users to create an ink signature at all and only allow digitally signing via a predefined signer, without users being able to change it. This can be done by subclassing
SignatureViewController and overriding the
signer property to return the predefined signer that needs to be used. Additionally, you should set
.never — either on the signature view controller directly, or on
PDFConfiguration.signatureCertificateSelectionMode — to disable the user choosing another signer.
To allow the user to select a different certificate but still prevent the creation of a normal ink signature, you can subclass
CertificatePickerViewController and only show the signers you want to allow the user to select by overriding the default