PSPDFProcessorSaveOptions


@interface PSPDFProcessorSaveOptions : NSObject

This class describes the save options you want to enforce when processing a pdf file. Using a save options object overrides the default options of a file.

A pdf file can have multiple security-related options set. The owner password generally controls the editing of a document and is required as soon as you want to encrypt a document in any kind. The user password prevents users from viewing the pdf. It is optional but if you specify it you also need to specify an owner password.

You can also specify the key length of the encryption. This controls how large the key is that is used for actually encrypting the document. The key is derived from the passwords you specify. As soon as you specify at least an owner password you also need to decide on a key length to be used. You can also specify PSPDFProcessorSaveOptionsKeyLengthAutomatic in all cases and let PSPDFKit decide on if and what key length to use.

To specify what operations are allowed when opening the document with user privileges you can also set PSPDFDocumentPermissions. With user privileges you can always view the file in question and by specifying PSPDFDocumentPermissions you can grant further rights that otherwise would only be available when the user has owner privileges.

Note

In order to use this class, you need a license that enables you to use the Document Editor. If you want to process a file while keeping the options of the original file, simply use nil as safe option.
  • Allows you to set different passwords on the resulting document.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithOwnerPassword:(nullable NSString *)ownerPassword
                                     userPassword:(nullable NSString *)userPassword
                                        keyLength:(NSUInteger)keyLength;

    Swift

    convenience init(ownerPassword: String?, userPassword: String?, keyLength: UInt)

    Parameters

    ownerPassword

    The password to be used as the document owner password.

    userPassword

    The password to be used as the password of a regular user.

    keyLength

    The length of the crypto key. This key must be a multiple of 8 and between 40 and 128. You can also set the length to PSPDFProcessorSaveOptionsKeyLengthAutomatic to let PSPDFKit maintain the keylength for you. If you do not have special needs, this might be the best choice for both, encrypted and unencrypted documents.

    Return Value

    A newly initialized instance of the receiver.

  • Allows you to set different passwords on the resulting document.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithOwnerPassword:(nullable NSString *)ownerPassword
                                     userPassword:(nullable NSString *)userPassword
                                        keyLength:(NSUInteger)keyLength
                                      permissions:(PSPDFDocumentPermissions)
                                                      documentPermissions;

    Swift

    init(ownerPassword: String?, userPassword: String?, keyLength: UInt, permissions documentPermissions: PSPDFDocumentPermissions)

    Parameters

    ownerPassword

    The password to be used as the document owner password.

    userPassword

    The password to be used as the password of a regular user.

    keyLength

    The length of the crypto key. This key must be a multiple of 8 and between 40 and 128. You can also set the length to PSPDFProcessorSaveOptionsKeyLengthAutomatic to let PSPDFKit maintain the keylength for you. If you do not have special needs, this might be the best choice for both, encrypted and unencrypted documents.

    documentPermissions

    The permissions that should be set on the document.

    Return Value

    A newly initialized instance of the receiver.

  • The owner password that will be set in the processed document or nil if the password should be removed.

    Declaration

    Objective-C

    @property (readonly, copy, nonatomic, nullable) NSString *ownerPassword;

    Swift

    var ownerPassword: String? { get }
  • The user password that will be set in the processed document or nil if the password should be removed.

    Declaration

    Objective-C

    @property (readonly, copy, nonatomic, nullable) NSString *userPassword;

    Swift

    var userPassword: String? { get }
  • The key-length of the encryption.

    Declaration

    Objective-C

    @property (readonly, nonatomic) NSUInteger keyLength;

    Swift

    var keyLength: UInt { get }
  • The PSPDFDocumentPermissions that will be set.

    Declaration

    Objective-C

    @property (readonly, nonatomic) PSPDFDocumentPermissions permissions;

    Swift

    var permissions: PSPDFDocumentPermissions { get }
  • Returns a PSPDFProcessorSaveOptions instance with owner and user password set. keyLength must be divisible by 8 and in the range of 40 to 128. - note: This method requires the Document Editor component to be enabled for your license.

    Declaration

    Objective-C

    + (nonnull instancetype)
    optionsWithOwnerPassword:(nonnull NSString *)ownerPassword
                userPassword:(nonnull NSString *)userPassword
                   keyLength:(NSUInteger)keyLength;

    Swift

    convenience init(ownerPassword: String, userPassword: String, keyLength: UInt)
  • Returns a PSPDFProcessorSaveOptions instance with owner and user password set. keyLength must be divisible by 8 and in the range of 40 to 128. - note: This method requires the Document Editor component to be enabled for your license.

    Declaration

    Objective-C

    + (nonnull instancetype)
    optionsWithOwnerPassword:(nonnull NSString *)ownerPassword
                userPassword:(nonnull NSString *)userPassword
                   keyLength:(NSUInteger)keyLength
                 permissions:(PSPDFDocumentPermissions)documentPermissions;

    Swift

    convenience init(ownerPassword: String, userPassword: String, keyLength: UInt, permissions documentPermissions: PSPDFDocumentPermissions)