PSPDFDocumentProvider


@interface PSPDFDocumentProvider : NSObject

A PSPDFDocument consists of one or multiple PSPDFDocumentProvider‘s. Each document provider has exactly one data source (file/data/dataProvider) - note: This class is used within PSPDFDocument and should not be instantiated externally.

  • Referenced data provider.

    Declaration

    Objective-C

    @property (readonly, nonatomic, nullable) id<PSPDFDataProviding> dataProvider;
  • The data provider URL, if the data provider exposes it.

    Declaration

    Objective-C

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

    Swift

    var fileURL: URL? { get }
  • Returns an NSData representation, memory-maps files, copies a data provider.

    Declaration

    Objective-C

    - (nullable NSData *)dataRepresentationWithError:
        (NSError *_Nullable *_Nullable)error;

    Swift

    func dataRepresentation() throws -> Data
  • Returns the fileSize of this documentProvider.

    Declaration

    Objective-C

    @property (readonly, nonatomic) unsigned long long fileSize;

    Swift

    var fileSize: UInt64 { get }
  • Accesses the parent document.

    Declaration

    Objective-C

    @property (readonly, nonatomic) PSPDFDocument *_Nullable document;

    Swift

    weak var document: PSPDFDocument? { get }
  • Delegate for writing annotations. Defaults to the current set document.

    Declaration

    Objective-C

    @property (readwrite, atomic)
        id<PSPDFDocumentProviderDelegate> _Nullable delegate;

    Swift

    weak var delegate: PSPDFDocumentProviderDelegate? { get set }
  • Returns the page info object for the supplied pageIndex, if it exists. - note: Unlike with -[PSPDFDocument pageInfoForPageAtIndex:] here the returned PSPDFPageInfo‘s pageIndex property always equals the supplied pageIndex argument

    Declaration

    Objective-C

    - (nullable PSPDFPageInfo *)pageInfoForPageAtIndex:(NSUInteger)pageIndex;

    Swift

    func pageInfoForPage(at pageIndex: UInt) -> PSPDFPageInfo?
  • Number of pages in the PDF. 0 if source is invalid. Filtered by pageRange.

    Declaration

    Objective-C

    @property (readonly, nonatomic) NSUInteger pageCount;

    Swift

    var pageCount: UInt { get }
  • Returns the page offset relative to the document.

    Declaration

    Objective-C

    @property (readonly, nonatomic) NSUInteger pageOffsetForDocument;

    Swift

    var pageOffsetForDocument: UInt { get }
  • Set a password. Doesn’t try to unlock the document.

    Declaration

    Objective-C

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

    Swift

    var password: String? { get }
  • The attached content signature.

    Declaration

    Objective-C

    @property (readonly, copy, nonatomic, nullable) NSData *contentSignature;

    Swift

    var contentSignature: Data? { get }
  • A PDF flag that indicates whether printing is allowed. - note: This replaces allowsCopying and allowsPrinting from earlier versions of the SDK.

    Declaration

    Objective-C

    @property (readonly, nonatomic) PSPDFDocumentPermissions permissions;

    Swift

    var permissions: PSPDFDocumentPermissions { get }
  • Was the PDF file encrypted at file creation time?

    Declaration

    Objective-C

    @property (readonly, nonatomic) BOOL isEncrypted;

    Swift

    var isEncrypted: Bool { get }
  • Has the PDF file been unlocked? (is it still locked?).

    Declaration

    Objective-C

    @property (readonly, nonatomic) BOOL isLocked;

    Swift

    var isLocked: Bool { get }
  • Are we able to add/change annotations in this file? Annotations can’t be added to encrypted documents or if there are parsing errors. - note: If PSPDFFeatureMaskAnnotationEditing isn’t available, this will return NO.

    Declaration

    Objective-C

    @property (readonly, nonatomic) BOOL canEmbedAnnotations;

    Swift

    var canEmbedAnnotations: Bool { get }
  • A flag that indicates whether changing existing annotations or creating new annotations are allowed - note: Searches and checks the digital signatures on the first call (caches the result for subsequent calls)

    Declaration

    Objective-C

    @property (readonly, nonatomic) BOOL allowAnnotationChanges;

    Swift

    var allowAnnotationChanges: Bool { get }
  • A file identifier. - note: A permanent identifier based on the contents of the file at the time it was originally created.

    Declaration

    Objective-C

    @property (readonly, copy, nonatomic, nullable) NSData *fileId;

    Swift

    var fileId: Data? { get }
  • Access the PDF title. (.pdf will be truncated) - note: If there’s no title in the PDF metadata, the file name will be used.

    Declaration

    Objective-C

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

    Swift

    var title: String { get }
  • Return a textParser for the specific document page. Page starts at 0. Will parse the page contents before returning. Might take a while.

    Declaration

    Objective-C

    - (nullable PSPDFTextParser *)textParserForPageAtIndex:(NSUInteger)pageIndex;

    Swift

    func textParserForPage(at pageIndex: UInt) -> PSPDFTextParser?
  • Outline extraction class for current PDF. Lazy initialized. Can be subclassed.

    Declaration

    Objective-C

    @property (readonly, nonatomic) PSPDFOutlineParser *_Nonnull outlineParser;

    Swift

    var outlineParser: PSPDFOutlineParser { get }
  • Returns the AcroForm parser. Forms are a separate component and might not be enabled for your license. If forms are not enabled or not part of your license, this will return nil.

    See

    formsEnabled on the PSPDFDocument class.

    Declaration

    Objective-C

    @property (readonly, nonatomic, nullable) PSPDFFormParser *formParser;

    Swift

    var formParser: PSPDFFormParser? { get }
  • Link annotation parser class for current PDF. Lazy initialized. Can be subclassed.

    Declaration

    Objective-C

    @property (readonly, nonatomic)
        PSPDFAnnotationManager *_Nonnull annotationManager;

    Swift

    var annotationManager: PSPDFAnnotationManager { get }
  • Page labels found in the current PDF. Lazy initialized. Can be subclassed.

    Declaration

    Objective-C

    @property (readonly, nonatomic) PSPDFLabelParser *_Nonnull labelParser;

    Swift

    var labelParser: PSPDFLabelParser { get }
  • Access the PDF metadata.

    Declaration

    Objective-C

    @property (readonly, copy, nonatomic)
        NSDictionary<NSString *, id> *_Nonnull metadata;

    Swift

    var metadata: [String : Any] { get }
  • Get the XMP metadata in XML format, if there is any.

    Declaration

    Objective-C

    @property (readonly, nonatomic, nullable) NSString *XMPMetadata;

    Swift

    var xmpMetadata: String? { get }
  • May be used to customize and override rotation for a page. - note: Valid rotation values are 0, 90, 180 and 270. A call to reloadData is required if the document is currently displayed in a PSPDFViewController. You might also want to clear existing cache, so you don’t get a malformed image while re-rendering. [self.pspdfkit.cache invalidateImageFromDocument:self.document pageIndex:pageIndex];

    Declaration

    Objective-C

    - (void)setRotation:(NSUInteger)rotation forPageAtIndex:(NSUInteger)pageIndex;

    Swift

    func setRotation(_ rotation: UInt, forPageAt pageIndex: UInt)
  • Resolves a named destination. E.g. for a PSPDFRemoteGoToAction. On success, returns a valid page index. On failure, NSNotFound.

    Declaration

    Objective-C

    - (NSUInteger)resolveNamedDestination:(nonnull NSString *)namedDestination;

    Swift

    func resolveNamedDestination(_ namedDestination: String) -> UInt
  • Saves changed annotations. - warning: You shouldn’t call this method directly, use the high-level save method in PSPDFDocument instead.

    Declaration

    Objective-C

    - (BOOL)saveAnnotationsWithOptions:
                (nullable NSDictionary<NSString *, id> *)options
                                 error:(NSError *_Nullable *_Nullable)error;

    Swift

    func saveAnnotations(options: [String : Any]? = nil) throws
  • Resolves a path like /localhost/Library/test.pdf into a full path. If either alwaysLocal is set or localhost is part of the path, we’ll handle this as a local URL.

    Declaration

    Objective-C

    - (nonnull NSString *)resolveTokenizedPath:(nonnull NSString *)path
                                   alwaysLocal:(BOOL)alwaysLocal;

    Swift

    func resolveTokenizedPath(_ path: String, alwaysLocal: Bool) -> String
  • Used to automatically process the actions that follow a keystroke or selection change (for choice fields) Must pass appropriate values in the eventParams dictionary. In particular, willCommit and change, should be set correctly. The returned dictionary contains the response code and the modified change value possibly Handles K and V actions.

    Declaration

    Objective-C

    - (nullable NSDictionary<NSString *, id> *)
    executeValueChangedJSActionSequenceWithActionContainer:
        (nullable id)actionContainer
                                               application:
                                                   (nullable id<
                                                       PSPDFApplicationJSExport>)
                                                       application
                                               eventParams:
                                                   (nullable NSDictionary<
                                                       NSString *, id> *)eventParams
                                                     error:(NSError *_Nullable
                                                                *_Nullable)error;

    Swift

    func executeValueChangedJSActionSequence(withActionContainer actionContainer: Any?, application: PSPDFApplicationJSExport?, eventParams: [String : Any]?) throws -> [String : Any]
  • Executes the format action for the container. If no action exists, returns the value unchanged. Handles F actions from the additional actions dictionary.

    Declaration

    Objective-C

    - (nullable NSString *)
    executeFormatActionWithActionContainer:(nullable id)actionContainer
                               application:(nullable id<PSPDFApplicationJSExport>)
                                               application
                               eventParams:(nullable NSDictionary<NSString *, id> *)
                                               eventParams
                                     error:(NSError *_Nullable *_Nullable)error;

    Swift

    func executeFormatAction(withActionContainer actionContainer: Any?, application: PSPDFApplicationJSExport?, eventParams: [String : Any]?) throws -> String
  • Executes all calculate actions in the document that depend on the sourceForm value. For performance reasons, this method isn’t automatically executed on creation time. If you need up-to-date form values be sure to call this method at least once (passing nil as the sourceForm) before accessing the form values. PSPDFViewController will do this for you automatically, if you are displaying the document. - note: Executes synchronously. Use with caution for complex actions, as it blocks the main thread. (Must be run on main thread). - returns: YES if successful.

    Declaration

    Objective-C

    - (BOOL)
    updateCalculatedFieldsDependingOnForm:(nullable PSPDFFormElement *)sourceForm
                                    error:(NSError *_Nullable *_Nullable)error;

    Swift

    func updateCalculatedFieldsDepending(onForm sourceForm: PSPDFFormElement?) throws

    Return Value

    YES if successful.