Skip to content

Signatures ​

Foxit PDF SDK for iOS provides digital signature create, verify, remove, and property APIs via Core SDK. Recipients can verify document origin and whether content was altered.

UI Extensions built-in signatures

With the full reader (UI Extensions), the SignatureModule handles signing and verification—no extra code required.

Default signature types

The SDK includes default signature callbacks for:

  • Adobe.PPKLite + adbe.pkcs7.detached
  • Adobe.PPKLite + adbe.pkcs7.sha1

Core class ​

ClassDescription
FSSignatureSignature object. Create with [FSPDFPage addSignature:], retrieve with [FSPDFDoc getSignature:]

Digest algorithm constants ​

ConstantDescription
FSSignatureDigestSHA1SHA-1
FSSignatureDigestSHA256SHA-256
FSSignatureDigestSHA384SHA-384
FSSignatureDigestSHA512SHA-512

Signature key constants ​

Use setKeyValue:value::

ConstantDescription
FSSignatureKeyNameSignerSigner
FSSignatureKeyNameLocationLocation
FSSignatureKeyNameReasonReason
FSSignatureKeyNameContactInfoContact info
FSSignatureKeyNameDNDistinguished name
FSSignatureKeyNameTextCustom text

Appearance flag constants ​

Use setAppearanceFlags::

ConstantDescription
FSSignatureAPFlagSignerShow signer
FSSignatureAPFlagReasonShow reason
FSSignatureAPFlagSigningTimeShow signing time
FSSignatureAPFlagDNShow DN
FSSignatureAPFlagLocationShow location
FSSignatureAPFlagBitmapShow image
FSSignatureAPFlagTextShow custom text

Example: sign and verify ​

objc
#import <FoxitRDK/FSPDFObjC.h>

FSPDFDoc *doc = [[FSPDFDoc alloc] initWithPath:@"path/to/Sample.pdf"];
[doc load:nil];
FSPDFPage *page = [doc getPage:0];

// Add signature field
FSRectF *rect = [[FSRectF alloc] initWithLeft1:100 bottom1:600 right1:300 top1:700];
FSSignature *signature = [page addSignature:rect];

// Appearance
[signature setAppearanceFlags:
    FSSignatureAPFlagSigner | FSSignatureAPFlagDN |
    FSSignatureAPFlagReason | FSSignatureAPFlagSigningTime |
    FSSignatureAPFlagLocation];

// Signature metadata
[signature setKeyValue:FSSignatureKeyNameSigner value:@"John Smith"];
[signature setKeyValue:FSSignatureKeyNameLocation value:@"Beijing"];
[signature setKeyValue:FSSignatureKeyNameReason value:@"Document approval"];
[signature setFilter:@"Adobe.PPKLite"];
[signature setSubFilter:@"adbe.pkcs7.detached"];

// Sign
NSString *certPath = @"path/to/cert.pfx";
NSString *savePath = @"path/to/signed.pdf";
FSProgressive *progressive = [signature startSign:certPath
                                    cert_password:@"123"
                                 digest_algorithm:FSSignatureDigestSHA256
                                        save_path:savePath
                                      client_data:nil
                                            pause:nil];

FSProgressState state = FSProgressiveToBeContinued;
while (state == FSProgressiveToBeContinued) {
    state = [progressive resume];
}

// Verify all signatures in signed document
FSPDFDoc *signedDoc = [[FSPDFDoc alloc] initWithPath:savePath];
[signedDoc load:nil];

int count = [signedDoc getSignatureCount];
for (int i = 0; i < count; i++) {
    FSSignature *sig = [signedDoc getSignature:i];
    if (!sig || [sig isEmpty]) continue;

    FSProgressive *verifyProgress = [sig startVerify:nil pause:nil];
    FSProgressState vState = FSProgressiveToBeContinued;
    while (vState == FSProgressiveToBeContinued) {
        vState = [verifyProgress resume];
    }

    unsigned int verifiedState = [sig getState];
    if (verifiedState & FSSignatureStateVerifyValid) {
        NSLog(@"Signature %d is valid", i);
    }
}

API reference

See the API reference for FSSignature.