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
PTPDFDocumentModelinstance 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’sPTPDFDocumentModel.fileURLinstance property.Declaration
Objective-C
- (nonnull instancetype)initWithPDFDoc:(nonnull PTPDFDoc *)pdfDoc;Swift
convenience init(pdfDoc: PTPDFDoc)Parameters
pdfDocThe PDF document
Return Value
an initialized
PTPDFDocumentModelinstance -
Initializes a
PTPDFDocumentModelinstance 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
pdfDocThe PDF document
fileURLThe URL location of the document’s backing file, or
nilif unknownReturn Value
an initialized
PTPDFDocumentModelinstance -
Initializes a
PTPDFDocumentModelinstance with a file URL.Note
In Swift, this method returns
Voidand is marked with thethrowskeyword 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) throwsParameters
fileURLThe URL location of the document to be opened
outErrorOn 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
nilfor this parameter if you do not want the error information.Return Value
an initialized
PTPDFDocumentModelif the PDF document could be opened, ornilif an error occurred -
Undocumented
Declaration
Objective-C
- (instancetype)init NS_UNAVAILABLE; -
Undocumented
Declaration
Objective-C
+ (instancetype)new NS_UNAVAILABLE; -
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
Voidand is marked with thethrowskeyword 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) throwsParameters
isFullSaveRequiredThe location where the boolean result should be stored
pdfDocThe PDF document
outErrorOn 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
nilfor this parameter if you do not want the error information.Return Value
YESif the full-save requirement could be determined, orNOif an error occurred -
Returns whether a full save (non-incremental) is required for the PDF document.
Note
In Swift, this method returns
Voidand is marked with thethrowskeyword 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>) throwsParameters
isFullSaveRequiredThe location where the boolean result should be stored
outErrorOn 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
nilfor this parameter if you do not want the error information.Return Value
YESif the full-save requirement could be determined, orNOif an error occurred -
Saves the PDF document with the specified flags.
Note
In Swift, this method returns
Voidand is marked with thethrowskeyword 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) throwsParameters
flagsThe flags determining how the save should be performed
outErrorOn 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
nilfor this parameter if you do not want the error information.Return Value
YESif the PDF document was saved successfully, orNOif an error occurred and the document could not be saved
-
Creates and returns a new
PTPDFDocumentModelinstance initialized with the file URL.Note
In Swift, this method returns
Voidand is marked with thethrowskeyword 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 -> SelfParameters
fileURLThe URL location of the document to be opened
outErrorOn 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
nilfor this parameter if you do not want the error information.Return Value
an initialized
PTPDFDocumentModelinstance, ornilif an error occurred
PTPDFDocumentModel Class Reference