PSPDFDocumentSharingViewController

Objective-C


@interface PSPDFDocumentSharingViewController
    : PSPDFBaseViewController <PSPDFStyleable, PSPDFOverridable>

Swift

class PDFDocumentSharingViewController : PDFBaseViewController, Styleable, Overridable

Displays an interface that allows the user to pick a set of options that determine how a set of PDF files should be processed before being shared to a destination. By default, the user can choose the file type, the page range, and how annotations should be handled.

Documents can be shared to different Destinations specified by the PSPDFDocumentSharingDestination enumeration. By default, the PDFDocumentSharingViewController will share toPSPDFDocumentSharingDestinationActivity, which will let the user pick the ultimate action for the generated documents via a UIActivityViewController instance (which can be customized via the -activityViewControllerForSharingItems:sender: method.).

A single PDFDocumentSharingViewController instance can offer multiple destinations to share the documents to to the user — they will be represented on a segmented control on the navigation bar of the sharing view controller. However, a Share can only be performed to a single destination at a time. To add Destinations to the list the user can choose from, create a PSPDFDocumentSharingConfiguration object and set the appropriate value on its builder’s destination property, then add that configuration to the sharingConfigurations property on the sharing view controller.

Please note that Destinations are exclusive per sharing view controller instance, so you can’t have 2 or more configurations with the same destination set.

Once the instance has been configured appropriately, call -presentFromViewController:sender: on it to present the UI.

  • May be used to specify custom PSPDFDocumentSecurityOptions, such as passwords and key length. Defaults to nil.

    Declaration

    Objective-C

    @property (nonatomic, readonly, nullable) PSPDFDocumentSecurityOptions *documentSecurityOptions;

    Swift

    var documentSecurityOptions: Document.SecurityOptions? { get }
  • Subclass to allow setting default printer info or changing the printer job name. (see printerID, https://stackoverflow.com/questions/12898476/airprint-set-default-printer-in-uiprintinteractioncontroller)

    Declaration

    Objective-C

    @property (nonatomic, readonly) UIPrintInfo *_Nonnull printInfo;

    Swift

    var printInfo: UIPrintInfo { get }
  • Returns a preconfigured activity view controller suitable for sharing the items generated after processing the documents with the selected configuration.

    You can override this method and return your own UIActivityViewController instance if you wish to customize the options that are available for sharing the documents.

    Declaration

    Objective-C

    - (nullable UIActivityViewController *)
        activityViewControllerForSharingItems:(nonnull NSArray *)activityItems
                                       sender:(nonnull id)sender;

    Swift

    func activityViewController(forSharingItems activityItems: [Any], sender: Any) -> UIActivityViewController?

    Parameters

    activityItems

    The items that the document processing generated, to be shared.

    sender

    The sender that requested the UIActivityViewController.

    Return Value

    An UIActivityViewController instance suitable for sharing the provided activity items, or nil if the documents are not suitable to being shared.

  • Override this method to customize the mail compose view controller that’s used when sharing to the Email destination.

    Declaration

    Objective-C

    - (void)configureMailComposeViewController:
        (nonnull MFMailComposeViewController *)mailComposeViewController;

    Swift

    func configureMailComposeViewController(_ mailComposeViewController: MFMailComposeViewController)

    Parameters

    mailComposeViewController

    The mail compose view controller that’ll be used to send the email.

  • Override this method to modify the processor configuration to be used when crunching the files after the configuration options have been selected.

    Declaration

    Objective-C

    - (void)configureProcessorConfigurationOptions:
        (nonnull PSPDFProcessorConfiguration *)processorConfiguration;

    Swift

    func configureProcessorConfigurationOptions(_ processorConfiguration: PSPDFProcessorConfiguration)

    Parameters

    processorConfiguration

    The processor configuration created based on the sharing configuration.

  • Override this method to customize the attachment data and information for documents being shared to Mail.app.

    Note

    This method is only called when sharing to Mail destination.

    Warning

    Your implementation must call super as its last step.

    Declaration

    Objective-C

    - (void)addAttachmentData:(nonnull NSData *)attachment
                     mimeType:(nonnull NSString *)mimeType
                     fileName:(nonnull NSString *)filename;

    Swift

    func addAttachmentData(_ attachment: Data, mimeType: String, fileName filename: String)
  • Override to customize the title that the segmented control on the sharing configuration interface displays for the provided destination.

    Declaration

    Objective-C

    - (nonnull NSString *)titleForDestination:
        (nonnull PSPDFDocumentSharingDestination)destination;

    Swift

    func title(forDestination destination: DocumentSharingConfiguration.Destination) -> String

    Parameters

    destination

    Destination for which the title should be provided.

    Return Value

    The title for the given destination.

  • Override this method to return a custom location to export the document to for a given destination.

    See

    PSPDFDocumentSharingDestination for the available destinations.

    Declaration

    Objective-C

    - (nullable NSString *)temporaryDirectoryForSharingToDestination:
        (nonnull PSPDFDocumentSharingDestination)destination;

    Swift

    func temporaryDirectoryForSharing(toDestination destination: DocumentSharingConfiguration.Destination) -> String?

    Parameters

    destination

    The destination the document is going to be shared to.

    Return Value

    The directory path to export the document to. If nil, a default temporary directory is going to be created.

  • Override this method to return a customized subtitle for the available annotation options.

    Declaration

    Objective-C

    - (nullable NSString *)titleForAnnotationOptions:
        (PSPDFDocumentSharingAnnotationOptions)option;

    Swift

    func title(for option: DocumentSharingConfiguration.AnnotationOptions = []) -> String?

    Parameters

    option

    The annotation option to return the title for. See PSPDFDocumentSharingAnnotationOptions.

    Return Value

    The customized title for the option.

  • Override this method to return a customized title for the available annotation options.

    Declaration

    Objective-C

    - (nullable NSString *)
        subtitleForAnnotationsOptions:(PSPDFDocumentSharingAnnotationOptions)option
                 sharingConfiguration:(nonnull PSPDFDocumentSharingConfiguration *)
                                          sharingConfiguration;

    Swift

    func subtitle(forAnnotationsOptions option: DocumentSharingConfiguration.AnnotationOptions = [], sharingConfiguration: DocumentSharingConfiguration) -> String?

    Parameters

    option

    The annotation option to return the title for. See PSPDFDocumentSharingAnnotationOptions.

    Return Value

    The customized title for the option or nil if a subtitle should not be displayed.