PTPDFDocumentModel


@interface PTPDFDocumentModel : NSObject

A model class that manages access to a PTPDFDoc instance.

The PTPDFDocumentModel encapsulates some of the more complex operations that can be performed on a PTPDFDoc, especially saving of the document in a way that handles common pitfalls.

  • Initializes a PTPDFDocumentModel instance with a PDF document.

    If the PDF document was loaded from a file, as opposed to a memory buffer, then the location of the file is retrieved via -[PTPDFDoc GetFileName]. The file path is then used to set the model’s PTPDFDocumentModel.fileURL instance property.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithPDFDoc:(nonnull PTPDFDoc *)pdfDoc;

    Swift

    convenience init(pdfDoc: PTPDFDoc)

    Parameters

    pdfDoc

    The PDF document

    Return Value

    an initialized PTPDFDocumentModel instance

  • Initializes a PTPDFDocumentModel instance with a PDF document and file URL.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithPDFDoc:(nonnull PTPDFDoc *)pdfDoc
                                   fileURL:(nullable NSURL *)fileURL;

    Swift

    init(pdfDoc: PTPDFDoc, fileURL: URL?)

    Parameters

    pdfDoc

    The PDF document

    fileURL

    The URL location of the document’s backing file, or nil if unknown

    Return Value

    an initialized PTPDFDocumentModel instance

  • Initializes a PTPDFDocumentModel instance with a file URL.

    Note

    In Swift, this method returns Void and is marked with the throws keyword to indicate that it throws an error in cases of failure.

    Declaration

    Objective-C

    - (nullable instancetype)initWithFileURL:(nonnull NSURL *)fileURL
                                       error:(out NSError *_Nullable *_Nullable)
                                                 outError;

    Swift

    convenience init(fileURL: URL) throws

    Parameters

    fileURL

    The URL location of the document to be opened

    outError

    On input, a pointer to an error object. If an error occurs, this pointer is set to an actual error object containing the error information. You may specify nil for this parameter if you do not want the error information.

    Return Value

    an initialized PTPDFDocumentModel if the PDF document could be opened, or nil if an error occurred

  • Undocumented

    Declaration

    Objective-C

    - (instancetype)init NS_UNAVAILABLE;
  • Undocumented

    Declaration

    Objective-C

    + (instancetype)new NS_UNAVAILABLE;
  • The modelled PDF document.

    Declaration

    Objective-C

    @property (nonatomic, strong, readonly) PTPDFDoc *_Nonnull pdfDoc;

    Swift

    var pdfDoc: PTPDFDoc { get }
  • The URL of the PDF document’s backing file.

    This file URL is used when the document is saved or when the on-disk representation of the document is required.

    Declaration

    Objective-C

    @property (nonatomic, strong, readonly, nullable) NSURL *fileURL;

    Swift

    var fileURL: URL? { get }
  • Whether the PDF document has been modified since it was opened or last saved.

    The default value of this property is NO.

    Declaration

    Objective-C

    @property (nonatomic, readonly, getter=isModified) BOOL modified;

    Swift

    var isModified: Bool { get }
  • Returns whether a full save (non-incremental) is required for the specified PDF document.

    Note

    In Swift, this method returns Void and is marked with the throws keyword to indicate that it throws an error in cases of failure.

    Declaration

    Objective-C

    + (BOOL)isFullSaveRequired:(out BOOL *_Nonnull)isFullSaveRequired
                     forPDFDoc:(nonnull PTPDFDoc *)pdfDoc
                         error:(out NSError *_Nullable *_Nullable)outError;

    Swift

    class func isFullSaveRequired(_ isFullSaveRequired: UnsafeMutablePointer<ObjCBool>, for pdfDoc: PTPDFDoc) throws

    Parameters

    isFullSaveRequired

    The location where the boolean result should be stored

    pdfDoc

    The PDF document

    outError

    On input, a pointer to an error object. If an error occurs, this pointer is set to an actual error object containing the error information. You may specify nil for this parameter if you do not want the error information.

    Return Value

    YES if the full-save requirement could be determined, or NO if an error occurred

  • Returns whether a full save (non-incremental) is required for the PDF document.

    Note

    In Swift, this method returns Void and is marked with the throws keyword to indicate that it throws an error in cases of failure.

    Declaration

    Objective-C

    - (BOOL)isFullSaveRequired:(out BOOL *_Nonnull)isFullSaveRequired
                         error:(out NSError *_Nullable *_Nullable)outError;

    Swift

    func isFullSaveRequired(_ isFullSaveRequired: UnsafeMutablePointer<ObjCBool>) throws

    Parameters

    isFullSaveRequired

    The location where the boolean result should be stored

    outError

    On input, a pointer to an error object. If an error occurs, this pointer is set to an actual error object containing the error information. You may specify nil for this parameter if you do not want the error information.

    Return Value

    YES if the full-save requirement could be determined, or NO if an error occurred

  • Saves the PDF document with the specified flags.

    Note

    In Swift, this method returns Void and is marked with the throws keyword to indicate that it throws an error in cases of failure.

    Declaration

    Objective-C

    - (BOOL)savePDFDocWithFlags:(PTSaveOptions)flags
                          error:(out NSError *_Nullable *_Nullable)outError;

    Swift

    func savePDFDoc(withFlags flags: PTSaveOptions) throws

    Parameters

    flags

    The flags determining how the save should be performed

    outError

    On input, a pointer to an error object. If an error occurs, this pointer is set to an actual error object containing the error information. You may specify nil for this parameter if you do not want the error information.

    Return Value

    YES if the PDF document was saved successfully, or NO if an error occurred and the document could not be saved

  • Creates and returns a new PTPDFDocumentModel instance initialized with the file URL.

    Note

    In Swift, this method returns Void and is marked with the throws keyword to indicate that it throws an error in cases of failure.

    Declaration

    Objective-C

    + (nullable instancetype)
        documentForFileAtURL:(nonnull NSURL *)fileURL
                       error:(out NSError *_Nullable *_Nullable)outError;

    Swift

    class func documentForFile(at fileURL: URL) throws -> Self

    Parameters

    fileURL

    The URL location of the document to be opened

    outError

    On input, a pointer to an error object. If an error occurs, this pointer is set to an actual error object containing the error information. You may specify nil for this parameter if you do not want the error information.

    Return Value

    an initialized PTPDFDocumentModel instance, or nil if an error occurred