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.
-
Unavailable
Not the designated initializer
Undocumented
Declaration
Objective-C
PSPDF_DEFAULT_VIEWCONTROLLER_INIT_UNAVAILABLE
-
Unavailable
Not the designated initializer
Undocumented
Declaration
Objective-C
PSPDF_DEFAULT_VIEWCONTROLLER_INIT_UNAVAILABLE
-
Unavailable
Not the designated initializer
Undocumented
Declaration
Objective-C
PSPDF_DEFAULT_VIEWCONTROLLER_INIT_UNAVAILABLE
-
Unavailable
Not the designated initializer
Undocumented
Declaration
Objective-C
PSPDF_DEFAULT_VIEWCONTROLLER_INIT_UNAVAILABLE
-
Initializes a view controller to share the given documents using the default sharing configuration. This uses the default sharing configuration for
PSPDFDocumentSharingDestinationActivity
.Declaration
Objective-C
- (nonnull instancetype)initWithDocuments: (nonnull NSArray<PSPDFDocument *> *)documents;
Swift
convenience init(documents: [Document])
Parameters
documents
The documents to be shared. Required to contain at least one document.
-
Initializes a view controller to share the given documents according the given configurations.
Declaration
Objective-C
- (nonnull instancetype) initWithDocuments:(nonnull NSArray<PSPDFDocument *> *)documents sharingConfigurations: (nullable NSArray<PSPDFDocumentSharingConfiguration *> *) sharingConfigurations;
Swift
init(documents: [Document], sharingConfigurations: [DocumentSharingConfiguration]?)
Parameters
documents
The documents to be shared. Required to contain at least one document.
sharingConfigurations
The configurations for the possible sharing destinations. If nil or empty, the default sharing configuration for
PSPDFDocumentSharingDestinationActivity
is used. -
List of documents this control has been initialized with.
Declaration
Objective-C
@property (nonatomic, readonly) NSArray<PSPDFDocument *> *_Nonnull documents;
Swift
var documents: [Document] { get }
-
The configurations the user can pick to share to.
Initially uses the configurations passed to the initializer.
Note
Setting 2 or more configurations with the same destination is invalid and will result in an assert.Declaration
Objective-C
@property (nonatomic) NSArray<PSPDFDocumentSharingConfiguration *> *_Nonnull sharingConfigurations;
Swift
var sharingConfigurations: [DocumentSharingConfiguration] { get set }
-
The currently selected file format option to share the documents as.
Default value is determined based on the active destination.
Read more: https://pspdfkit.com/guides/ios/miscellaneous/document-sharing/
Declaration
Objective-C
@property (nonatomic) PSPDFDocumentSharingFileFormatOptions selectedFileFormatOption;
Swift
var selectedFileFormatOption: DocumentSharingConfiguration.FileFormatOptions { get set }
-
The currently selected option for the page range to share from the documents being shared.
Note
Default value is determined based on the active destination.@discussion When sharing multiple documents, the only two valid options are PSPDFDocumentSharingPageSelectionAnnotated and PSPDFDocumentSharingPageSelectionAll.
Read more: https://pspdfkit.com/guides/ios/miscellaneous/document-sharing/
Declaration
Objective-C
@property (nonatomic) PSPDFDocumentSharingPagesOptions selectedPageSelectionOption;
Swift
var selectedPageSelectionOption: DocumentSharingConfiguration.PageOptions { get set }
-
The currently selected option for handling annotations in the documents being shared.
Default value is determined based on the active destination.
Read more: https://pspdfkit.com/guides/ios/miscellaneous/document-sharing/
Declaration
Objective-C
@property (nonatomic) PSPDFDocumentSharingAnnotationOptions selectedAnnotationOption;
Swift
var selectedAnnotationOption: DocumentSharingConfiguration.AnnotationOptions { get set }
-
Returns the destination that’s currently active on the view controller.
Note
When setting this property, the new destination needs to be defined as the destination of one of thesharingConfigurations
objects.Declaration
Objective-C
@property (nonatomic) PSPDFDocumentSharingDestination _Nonnull selectedDestination;
Swift
var selectedDestination: DocumentSharingConfiguration.Destination { get set }
-
The document sharing controller delegate.
Note
When sharing is invoked via the default PSPDFKit UI, this will be set to the presentingPDFViewController
instance.Declaration
Objective-C
@property (nonatomic, weak) id<PSPDFDocumentSharingViewControllerDelegate> _Nullable delegate;
Swift
@IBOutlet weak var delegate: PDFDocumentSharingViewControllerDelegate? { get set }
-
Delegate used for getting the list of visible pages.
Note
This protocol is implemented on
PDFViewController
.Note
When sharing multiple documents, this delegate is ignored and all pages will be shared by default.
Declaration
Objective-C
@property (nonatomic, weak) id<PSPDFVisiblePagesDataSource> _Nullable visiblePagesDataSource;
-
The range from which the user can pick to share pages from the document. This range is only valid when the
selectedPageSelectionOption
is set toDocumentSharingConfiguration.PageOptions.range
.@discussion When sharing multiple documents, the value of this property is ignored.
Declaration
Objective-C
@property (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 (nonatomic, readonly) BOOL checkIfControllerHasOptionsAvailableAndCallDelegateIfNot;
Swift
var checkIfControllerHasOptionsAvailableAndCallDelegateIfNot: Bool { get }
-
Button title for “commit”.
Declaration
Objective-C
@property (nonatomic, copy) 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 & PresentationActions, 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: DocumentSharingConfiguration.Destination) -> DocumentSharingConfiguration?
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 (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, ornil
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.