PSPDFDocumentSharingViewControllerDelegate

Objective-C

@protocol PSPDFDocumentSharingViewControllerDelegate <NSObject>

Swift

protocol PDFDocumentSharingViewControllerDelegate : NSObjectProtocol

The delegate for the PDFDocumentSharingViewController

  • Called when the destination has been handed over the generated files to share them.

    For some actions that happen outside the host application, such as sharing to UIActivityViewController or Printing, the fact that the error parameter is nil does not necessarily mean that the ultimate action was performed correctly, but that the files were handed over to the destination process correctly.

    Note

    This method is not guaranteed to be called from the main thread.

    Declaration

    Objective-C

    - (void)documentSharingViewController:
                (nonnull PSPDFDocumentSharingViewController *)shareController
        didFinishSharingWithConfiguration:
            (nonnull PSPDFDocumentSharingConfiguration *)configuration
                                 userInfo:
                                     (nonnull NSDictionary<
                                         PSPDFDocumentSharingUserInfoKey, id> *)
                                         userInfo
                                    error:(nullable NSError *)error;

    Swift

    optional func documentSharingViewController(_ shareController: PDFDocumentSharingViewController, didFinishSharingWith configuration: DocumentSharingConfiguration, userInfo: [PDFDocumentSharingUserInfoKey : Any] = [:], error: Error?)

    Parameters

    shareController

    The controller performing the action.

    configuration

    The configuration use to create the files that were shared.

    userInfo

    Contextual information generated from the sharing action. See PSPDFDocumentSharingUserInfoKey.

    error

    The resulting error from trying to send the files to the destination.

  • Called when the documents have been processed for being exported, and the resulting data has been handed over to the appropriate destination, based on the current state of the controller.

    Declaration

    Objective-C

    - (void)documentSharingViewController:
                (nonnull PSPDFDocumentSharingViewController *)shareController
                 didFinishGeneratingFiles:(nonnull NSArray<PSPDFFile *> *)files
                        withConfiguration:
                            (nonnull PSPDFDocumentSharingConfiguration *)
                                configuration
                                    error:(nullable NSError *)error;

    Swift

    optional func documentSharingViewController(_ shareController: PDFDocumentSharingViewController, didFinishGenerating files: [PSPDFFile], with configuration: DocumentSharingConfiguration, error: Error?)

    Parameters

    shareController

    The controller performing the action.

    files

    The files that were handed over to the destination.

    configuration

    The configuration to be used when sharing the document.

    error

    The error, if any, that was generated during file crunching.

  • Sharing has been cancelled.

    Declaration

    Objective-C

    - (void)documentSharingViewController:
                (nonnull PSPDFDocumentSharingViewController *)shareController
                   didCancelSharingAtStep:(PSPDFDocumentSharingStep)sharingStep
                        withConfiguration:
                            (nonnull PSPDFDocumentSharingConfiguration *)
                                configuration;

    Swift

    optional func documentSharingViewController(_ shareController: PDFDocumentSharingViewController, didCancelSharingAt sharingStep: PDFDocumentSharingViewController.Step, with configuration: DocumentSharingConfiguration)

    Parameters

    shareController

    The sharing controller that was cancelled.

    sharingStep

    Indicates the step in which the sharing was cancelled.

    configuration

    The sharing configuration at the moment the sharing was cancelled.

  • Called when the sharing configuration UI is dismissed by the user.

    Declaration

    Objective-C

    - (void)documentSharingViewControllerWasDismissed;

    Swift

    optional func documentSharingViewControllerWasDismissed()
  • Notifies the delegate about the progress in the underlying file crunching process for the documents to be shared.

    This method is going to be called both when the file crunching starts (progress = 0) and when it finishes (progress = 1).

    Note

    This method is not guaranteed to be called from the main thread.

    Declaration

    Objective-C

    - (void)documentSharingViewController:
                (nonnull PSPDFDocumentSharingViewController *)shareController
                      preparationProgress:(CGFloat)progress;

    Swift

    optional func documentSharingViewController(_ shareController: PDFDocumentSharingViewController, preparationProgress progress: CGFloat)

    Parameters

    shareController

    The sharing controller notifying about file processing progress.

    progress

    The progress of the total file crunching, represented from 0 to 1.

  • Asks the delegate for the filename that should be used for the generated files when sharing the given document.

    This method is going to be called once per document being shared during the file crunching process. The returned name will be used to write the resulting document to disk. The name you return shouldn’t include the .pdf file extension.

    Note

    This method is only going to be called when sharing documents with PSPDFDocumentSharingFileFormatOptionPDF selected. Custom filenames for PSPDFDocumentSharingFileFormatOptionImage or PSPDFDocumentSharingFileFormatOptionOriginal are currently not supported.

    Return nil to use the document’s default filename.

    Declaration

    Objective-C

    - (nullable NSString *)
              documentSharingViewController:
                  (nonnull PSPDFDocumentSharingViewController *)shareController
        filenameForGeneratedFileForDocument:(nonnull PSPDFDocument *)sharingDocument
                                destination:
                                    (nonnull PSPDFDocumentSharingDestination)
                                        destination;

    Swift

    optional func documentSharingViewController(_ shareController: PDFDocumentSharingViewController, filenameForGeneratedFileFor sharingDocument: Document, destination: DocumentSharingConfiguration.Destination) -> String?

    Parameters

    shareController

    The controller that’s asking for the filename.

    sharingDocument

    The document that’s being shared.

    destination

    The destination the document is going to be shared to.

  • Defaults to true.

    Called when the documents are being prepared to be shared. This method is called right before the file crunching process starts.

    You can use this method as a checkpoint to avoid doing any processing on any files based on your own criteria.

    Declaration

    Objective-C

    - (BOOL)documentSharingViewController:
                (nonnull PSPDFDocumentSharingViewController *)shareController
         shouldProcessForSharingWithState:
             (nonnull PSPDFDocumentSharingConfiguration *)sharingConfiguration;

    Swift

    optional func documentSharingViewController(_ shareController: PDFDocumentSharingViewController, shouldProcessForSharingWithState sharingConfiguration: DocumentSharingConfiguration) -> Bool

    Parameters

    shareController

    The controller that’s notifying the delegate.

    sharingConfiguration

    The configuration options that the documents are going to be exported with.

    Return Value

    true to allow the files to be processed, false to stop the sharing process.

  • Defaults to true.

    Called as the last step before the files are handed over to their destination.

    Return false to prevent the files from being handed over to the destination. This is useful if you wish to handle the file sharing yourself if, for instance, you’re in a secure environment in which the default destinations do not fit your needs.

    Note

    It is your responsibility to dismiss the sharing view controller if you decide to stop the sharing process.

    Declaration

    Objective-C

    - (BOOL)documentSharingViewController:
                (nonnull PSPDFDocumentSharingViewController *)shareController
                         shouldShareFiles:(nonnull NSArray<PSPDFFile *> *)files
                            toDestination:(nonnull PSPDFDocumentSharingDestination)
                                              destination;

    Swift

    optional func documentSharingViewController(_ shareController: PDFDocumentSharingViewController, shouldShare files: [PSPDFFile], toDestination destination: DocumentSharingConfiguration.Destination) -> Bool

    Parameters

    shareController

    The controller that’s notifying the delegate.

    files

    The files that are about to be handed over to the destination.

    destination

    The share destination.

    Return Value

    true to allow the files to be shared to the given destination, false to stop the sharing process.

  • Defaults to YES.

    Asks the delegate if the document that’s being shared should be saved before sharing.

    This delegate method is not called if the Document being shared has its annotationSaveMode set to disabled.

    Note

    If this method’s implementation returns false, the current state of the document won’t be saved and the document will be shared with the last saved state.

    Declaration

    Objective-C

    - (BOOL)documentSharingViewController:
                (nonnull PSPDFDocumentSharingViewController *)shareController
                       shouldSaveDocument:(nonnull PSPDFDocument *)document
                              withOptions:(NSDictionary<PSPDFDocumentSaveOption, id>
                                               *_Nonnull *_Nonnull)options;

    Swift

    optional func documentSharingViewController(_ shareController: PDFDocumentSharingViewController, shouldSave document: Document, withOptions options: AutoreleasingUnsafeMutablePointer<NSDictionary>) -> Bool

    Parameters

    shareController

    The controller that’s notifying the delegate.

    document

    The document that’s being shared.

    options

    The options to apply when saving the document.

    Return Value

    Whether the document should be saved with the provided options.