PTPDFDocumentFile

@interface PTPDFDocumentFile : NSObject

- (instancetype)initWithFileURL:(NSURL *)fileURL;

- (instancetype)initWithFileURL:(NSURL *)fileURL
        fileCoordinationEnabled:(BOOL)fileCoordinationEnabled NS_DESIGNATED_INITIALIZER;

- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)new NS_UNAVAILABLE;

/**
 * The URL of the PDF document file.
 */
@property (nonatomic, readonly, strong) NSURL *fileURL;

/**
 * The display name of the file, localized for the current locale.
 */
@property (nonatomic, readonly, copy) NSString *localizedDisplayName;

/**
 * The data model representation for the PDF document while it is open.
 *
 * @note The default value of this property is `nil`.
 */
@property (nonatomic, readonly, strong, nullable) PTPDFDocumentModel *model;

/**
 * The URL of the cache file used to indirectly access the file at `fileURL`.
 */
@property (nonatomic, readonly, strong, nullable) NSURL *cacheFileURL;

#pragma mark - File coordination

/**
 * Whether the File Coordination system is used in accessing the document.
 *
 * @note The default value of this property is `NO`.
 */
@property (nonatomic, readonly, assign, getter=isFileCoordinationEnabled) BOOL fileCoordinationEnabled;

/**
 * The presenter responsible for managing the document's file in the File Coordination system.
 *
 * The value of this property is nonnull when file coordination is enabled, otherwise `nil`.
 *
 * @see `PTPDFDocumentFile.fileCoordinationEnabled`
 */
@property (nonatomic, readonly, strong, nullable) id<NSFilePresenter> filePresenter;

#pragma mark - Opening

@property (nonatomic, copy, nullable) NSDictionary<PTPDFDocumentReadOptionKey, id> *defaultReadOptions;

- (void)openWithOptions:(nullable NSDictionary<PTPDFDocumentReadOptionKey, id> *)options
      completionHandler:(void (PT_ESCAPING ^ _Nullable)(BOOL success,
                                                        NSError * _Nullable error))completionHandler;

- (void)reloadContentsWithCompletionHandler:(void (PT_ESCAPING ^ _Nullable)(BOOL success,
                                                                            NSError * _Nullable error))completionHandler;

#pragma mark - Saving

/**
 * The default options to be used for write operations.
 */
@property (nonatomic, copy, nullable) NSDictionary<PTPDFDocumentWriteOptionKey, id> *defaultWriteOptions;

- (void)saveWithOptions:(nullable NSDictionary<PTPDFDocumentWriteOptionKey, id> *)options
      completionHandler:(void (PT_ESCAPING ^ _Nullable)(BOOL success,
                                                        NSError * _Nullable error))completionHandler;

/**
 * Saves the document to the file at the specified URL.
 *
 * @param fileURL The URL location of the file to which the document will be written.
 */
- (void)saveToFileAtURL:(NSURL *)fileURL
            withOptions:(nullable NSDictionary<PTPDFDocumentWriteOptionKey, id> *)options
      completionHandler:(void (PT_ESCAPING ^ _Nullable)(BOOL success,
                                                        NSError * _Nullable error))completionHandler;

#pragma mark - Closing

- (void)closeWithCompletionHandler:(void (PT_ESCAPING ^ _Nullable)(BOOL success,
                                                                   NSError * _Nullable error))completionHandler;

@end

Undocumented

  • Undocumented

    Declaration

    Objective-C

    - (instancetype)initWithFileURL:(NSURL *)fileURL;

    Swift

    convenience init(fileURL: URL)
  • Undocumented

    Declaration

    Objective-C

    - (instancetype)initWithFileURL:(NSURL *)fileURL
            fileCoordinationEnabled:(BOOL)fileCoordinationEnabled NS_DESIGNATED_INITIALIZER;

    Swift

    init(fileURL: URL, fileCoordinationEnabled: Bool)
  • Undocumented

    Declaration

    Objective-C

    - (instancetype)init NS_UNAVAILABLE;
  • Undocumented

    Declaration

    Objective-C

    + (instancetype)new NS_UNAVAILABLE;
  • The URL of the PDF document file.

    Declaration

    Objective-C

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

    Swift

    var fileURL: URL { get }
  • The display name of the file, localized for the current locale.

    Declaration

    Objective-C

    @property (nonatomic, copy, readonly) NSString *_Nonnull localizedDisplayName;

    Swift

    var localizedDisplayName: String { get }
  • The data model representation for the PDF document while it is open.

    Note

    The default value of this property is nil.

    Declaration

    Objective-C

    @property (nonatomic, strong, readonly, nullable) PTPDFDocumentModel *model;

    Swift

    var model: PTPDFDocumentModel? { get }
  • The URL of the cache file used to indirectly access the file at fileURL.

    Declaration

    Objective-C

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

    Swift

    var cacheFileURL: URL? { get }
  • Whether the File Coordination system is used in accessing the document.

    Note

    The default value of this property is NO.

    Declaration

    Objective-C

    @property (nonatomic, assign, unsafe_unretained, readonly,
              getter=isFileCoordinationEnabled) BOOL fileCoordinationEnabled;

    Swift

    var isFileCoordinationEnabled: Bool { get }
  • The presenter responsible for managing the document’s file in the File Coordination system.

    The value of this property is nonnull when file coordination is enabled, otherwise nil.

    Declaration

    Objective-C

    @property (nonatomic, strong, readonly, nullable) id<NSFilePresenter> filePresenter;

    Swift

    var filePresenter: (any NSFilePresenter)? { get }
  • Undocumented

    Declaration

    Objective-C

    @property (nonatomic, copy, nullable) NSDictionary<PTPDFDocumentReadOptionKey, id> *defaultReadOptions

    Swift

    var defaultReadOptions: [PTPDFDocumentFile.ReadOptionKey : Any]? { get set }
  • Undocumented

    Declaration

    Objective-C

    - (void)openWithOptions:(nullable NSDictionary<PTPDFDocumentReadOptionKey, id> *)options
          completionHandler:(void (PT_ESCAPING ^ _Nullable)(BOOL success,
                                                            NSError * _Nullable error))completionHandler;

    Swift

    func open(options: [PTPDFDocumentFile.ReadOptionKey : Any]? = nil) async throws -> Bool
  • Undocumented

    Declaration

    Objective-C

    - (void)reloadContentsWithCompletionHandler:(void (PT_ESCAPING ^ _Nullable)(BOOL success,
                                                                                NSError * _Nullable error))completionHandler;

    Swift

    func reloadContents() async throws -> Bool
  • The default options to be used for write operations.

    Declaration

    Objective-C

    @property (nonatomic, copy, nullable) NSDictionary<PTPDFDocumentWriteOptionKey, id> *defaultWriteOptions;

    Swift

    var defaultWriteOptions: [PTPDFDocumentFile.WriteOptionKey : Any]? { get set }
  • Undocumented

    Declaration

    Objective-C

    - (void)saveWithOptions:(nullable NSDictionary<PTPDFDocumentWriteOptionKey, id> *)options
          completionHandler:(void (PT_ESCAPING ^ _Nullable)(BOOL success,
                                                            NSError * _Nullable error))completionHandler;

    Swift

    func save(options: [PTPDFDocumentFile.WriteOptionKey : Any]? = nil) async throws -> Bool
  • Saves the document to the file at the specified URL.

    Declaration

    Objective-C

    - (void)saveToFileAtURL:(nonnull NSURL *)fileURL
                withOptions:
                    (nullable NSDictionary<PTPDFDocumentWriteOptionKey, id> *)
                        options
          completionHandler:
              (void (^_Nullable)(BOOL, NSError *_Nullable))completionHandler;

    Swift

    func saveToFile(at fileURL: URL, withOptions options: [PTPDFDocumentFile.WriteOptionKey : Any]? = nil) async throws -> Bool

    Parameters

    fileURL

    The URL location of the file to which the document will be written.

  • Undocumented

    Declaration

    Objective-C

    - (void)closeWithCompletionHandler:(void (PT_ESCAPING ^ _Nullable)(BOOL success,
                                                                       NSError * _Nullable error))completionHandler;

    Swift

    func close() async throws -> Bool