PSPDFDocumentSharingViewController


@interface PSPDFDocumentSharingViewController
    : PSPDFStaticTableViewController <PSPDFStyleable, PSPDFOverridable>

Shows an interface to share a set of documents, allowing the user to customize different aspects of the operation, such as how the annotations should be saved, and a specific page range to share.

Documents can be shared to different Destinations made available through the PSPDFDocumentSharingDestination enumeration. By default, the PSPDFDocumentSharingViewController 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 PSPDFDocumentSharingViewController 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.

  • Unavailable

    Undocumented

    Declaration

    Objective-C

    PSPDF_DEFAULT_TABLEVIEWCONTROLLER_INIT_UNAVAILABLE
  • Unavailable

    Undocumented

    Declaration

    Objective-C

    PSPDF_DEFAULT_TABLEVIEWCONTROLLER_INIT_UNAVAILABLE
  • Unavailable

    Undocumented

    Declaration

    Objective-C

    PSPDF_DEFAULT_TABLEVIEWCONTROLLER_INIT_UNAVAILABLE
  • Unavailable

    Undocumented

    Declaration

    Objective-C

    PSPDF_DEFAULT_TABLEVIEWCONTROLLER_INIT_UNAVAILABLE
  • Unavailable

    Undocumented

    Declaration

    Objective-C

    PSPDF_DEFAULT_TABLEVIEWCONTROLLER_INIT_UNAVAILABLE
  • Initializes the sharing view controller with the given configuration. Caller has to handle presentation.

    Note

    Some sharing options might not work as expected if sharing multiple documents.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithDocuments:
        (nonnull NSArray<PSPDFDocument *> *)documents;

    Swift

    init(documents: [PSPDFDocument])

    Parameters

    documents

    The documents to be shared. Required to contain at least one document.

  • List of documents this control has been initialized with.

    Required to contain at least one document.

    Declaration

    Objective-C

    @property (readonly, nonatomic) NSArray<PSPDFDocument *> *_Nonnull documents;

    Swift

    var documents: [PSPDFDocument] { get }
  • The configurations the user can pick to share to. Each configuration object defines one destination.

    By default, this contains the default configuration for the .activity destination.

    Note

    Configurations are required to have different destinations. If this is set to an empty array, the default .activity destination configuration is loaded instead.

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic)
        NSArray<PSPDFDocumentSharingConfiguration *>
            *_Nonnull sharingConfigurations;

    Swift

    var sharingConfigurations: [PSPDFDocumentSharingConfiguration] { get set }
  • The currently selected option for handling annotations in the documents being shared.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic)
        PSPDFDocumentSharingAnnotationOptions selectedAnnotationOption;

    Swift

    var selectedAnnotationOption: PSPDFDocumentSharingAnnotationOptions { get set }
  • The currently selected option for the page range to share from the documents being shared.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic)
        PSPDFDocumentSharingPagesOptions selectedPageSelectionOption;

    Swift

    var selectedPageSelectionOption: PSPDFDocumentSharingPagesOptions { get set }
  • The currently selected file format option to share the documents as.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic)
        PSPDFDocumentSharingFileFormatOptions selectedFileFormatOption;

    Swift

    var selectedFileFormatOption: PSPDFDocumentSharingFileFormatOptions { get set }
  • Returns the currently active sharing configuration.

    If set, ensure that the used destination is part of the sharingConfigurations. Will assert if this is not the case.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic)
        PSPDFDocumentSharingDestination _Nonnull selectedDestination;

    Swift

    var selectedDestination: PSPDFDocumentSharingDestination { get set }
  • The document sharing controller delegate.

    Declaration

    Objective-C

    @property (readwrite, nonatomic)
        id<PSPDFDocumentSharingViewControllerDelegate> _Nullable delegate;

    Swift

    @IBOutlet weak var delegate: PSPDFDocumentSharingViewControllerDelegate? { get set }
  • Delegate used for getting the list of visible pages.

    Note

    This protocol is implemented on PSPDFViewController.

    Note

    When sharing multiple documents, this delegate is ignored and all pages will be shared by default.

    Declaration

    Objective-C

    @property (readwrite, nonatomic)
        id<PSPDFVisiblePagesDataSource> _Nullable visiblePagesDataSource;

    Swift

    weak var visiblePagesDataSource: PSPDFVisiblePagesDataSource? { get set }
  • The range from which the user can pick to share pages from the document. This is automatically set to the range of the first document as the configuration is set

    Note

    When sharing multiple documents, the value of this property is ignored and all pages will be shared by default.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) NSRange shareablePageRange;

    Swift

    var shareablePageRange: NSRange { get set }
  • Checks if the controller has options at all - and simply calls the delegate if not. This prevents showing the controller without any options and just a commit button. Will return YES if the controller has options available, NO if the delegate has been called.

    Declaration

    Objective-C

    @property (readonly, nonatomic)
        BOOL checkIfControllerHasOptionsAvailableAndCallDelegateIfNot;

    Swift

    var checkIfControllerHasOptionsAvailableAndCallDelegateIfNot: Bool { get }
  • Button title for commit.

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic) NSString *_Nonnull commitButtonTitle;

    Swift

    var commitButtonTitle: String { get set }
  • Commits the sharing action based on the current configuration.

    Declaration

    Objective-C

    - (void)commitWithCurrentConfiguration;

    Swift

    func commitWithCurrentConfiguration()
  • Cancels the current file crunching operation, if any.

    Declaration

    Objective-C

    - (void)cancelDocumentPreparationIfAny;

    Swift

    func cancelDocumentPreparationIfAny()
  • Presents the sharing interface in the appropriate way to the user.

    Note

    In some cases, such as when the document has no options to be configured (single page, so there are no pages to pick from, or no annotations), the document will be automatically forwarded to the selected destination.

    Declaration

    Objective-C

    - (void)presentFromViewController:
                (nonnull UIViewController<PSPDFPresentationActions> *)viewController
                               sender:(nullable id)sender;

    Swift

    func present(from viewController: UIViewController & PSPDFPresentationActions, sender: Any?)

    Parameters

    viewController

    The view controller that should present the sharing interface.

    sender

    The action sender.

  • Returns the currently selected options for a configuration with the given destination, if it exists.

    Declaration

    Objective-C

    - (nullable PSPDFDocumentSharingConfiguration *)
    currentSharingConfigurationForDestination:
        (nonnull PSPDFDocumentSharingDestination)destination;

    Swift

    func currentSharingConfiguration(forDestination destination: PSPDFDocumentSharingDestination) -> PSPDFDocumentSharingConfiguration?

    Parameters

    destination

    Destination to retrieve the options from.

    Return Value

    The (modified by the user) sharing configuration associated with the provided destination.

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

    Declaration

    Objective-C

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

    Swift

    var documentSecurityOptions: PSPDFDocumentSecurityOptions? { 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 (readonly, nonatomic) 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 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: PSPDFDocumentSharingDestination) -> 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: PSPDFDocumentSharingDestination) -> 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

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

    Swift

    func title(for option: PSPDFDocumentSharingAnnotationOptions = []) -> 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

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

    Swift

    func subtitle(forAnnotationsOptions option: PSPDFDocumentSharingAnnotationOptions = [], sharingConfiguration: PSPDFDocumentSharingConfiguration) -> String

    Parameters

    option

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

    Return Value

    The customized title for the option.