PSPDFDocumentDelegate

Objective-C

@protocol PSPDFDocumentDelegate <NSObject>

Swift

protocol PDFDocumentDelegate : NSObjectProtocol

Delegate to receive events regarding Document.

This delegate offers callbacks for custom actions after save events.

  • PDF files can contain actions to other PDF files (PSPDFRemoteGoToAction). Usually, these are attached to link annotations, but actions can also be connected to outline or forms.

    PSPDFKit automatically tries to find the linked files based on the relative path. There are also built-in tokens such as Documents, Cache, Library, Bundle and PSBundle that help to navigate inside the typical iOS/macOS application folder structure.

    This delegate allows custom tokens to be resolved, such as /MyAppToken. This delegate will only get called for unknown tokens, not any built-in ones.

    See

    PSPDFDocumentProvider resolveTokenizedPath:alwaysLocal:

    Return nil if the token cannot be resolved.

    Declaration

    Objective-C

    - (nonnull NSString *)pdfDocument:(nonnull PSPDFDocument *)document
        resolveCustomAnnotationPathToken:(nonnull NSString *)pathToken;

    Swift

    optional func pdfDocument(_ document: Document, resolveCustomAnnotationPathToken pathToken: String) -> String
  • Called after saving was successful. If document wasn’t modified, delegate will not be called.

    This is called in response to Document.save(options:) or Document.save(options:completion:), which saves changes like editing annotations. This includes auto-saving from PDFViewController. On the other hand, the document editor performs structural operations like reordering pages and uses a different saving mechanism. Therefore, this delegate method is not called when saving using PDFDocumentEditor or the document editor UI.

    Warning

    Might be called from a background thread.

    Declaration

    Objective-C

    - (void)pdfDocumentDidSave:(nonnull PSPDFDocument *)document;

    Swift

    optional func pdfDocumentDidSave(_ document: Document)
  • Called after saving failed.

    Warning

    Might be called from a background thread.

    Declaration

    Objective-C

    - (void)pdfDocument:(nonnull PSPDFDocument *)document
        saveDidFailWithError:(nonnull NSError *)error;

    Swift

    optional func pdfDocument(_ document: Document, saveDidFailWithError error: Error)