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: PSPDFDocument, resolveCustomAnnotationPathToken pathToken: String) -> String
  • Called after saving was successful. If document wasn’t modified, delegates will not be called.

    Warning

    Might be called from a background thread.

    Declaration

    Objective-C

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

    Swift

    optional func pdfDocumentDidSave(_ document: PSPDFDocument)
  • 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: PSPDFDocument, saveDidFailWithError error: Error)