PSPDFViewController
Objective-C
@interface PSPDFViewController
: PSPDFBaseViewController <
MFMailComposeViewControllerDelegate,
MFMessageComposeViewControllerDelegate,
PSPDFAnnotationTableViewControllerDelegate,
PSPDFBackForwardActionListDelegate,
PSPDFBookmarkViewControllerDelegate,
PSPDFConflictResolutionManagerDelegate, PSPDFControlDelegate,
PSPDFDocumentSharingViewControllerDelegate, PSPDFErrorHandler,
PSPDFExternalURLHandler, PSPDFFlexibleToolbarContainerDelegate,
PSPDFInlineSearchManagerDelegate, PSPDFOutlineViewControllerDelegate,
PSPDFOverridable, PSPDFPresentationContext,
PSPDFSearchViewControllerDelegate, PSPDFTextSearchDelegate,
PSPDFWebViewControllerDelegate>
Swift
class PDFViewController : PDFBaseViewController, MFMailComposeViewControllerDelegate, MFMessageComposeViewControllerDelegate, AnnotationTableViewControllerDelegate, BackForwardActionListDelegate, BookmarkViewControllerDelegate, ConflictResolutionManagerDelegate, ControlDelegate, PDFDocumentSharingViewControllerDelegate, ErrorHandler, ExternalURLHandler, FlexibleToolbarContainerDelegate, InlineSearchManagerDelegate, OutlineViewControllerDelegate, Overridable, PresentationContext, SearchViewControllerDelegate, TextSearchDelegate, WebViewControllerDelegate
This is the main view controller to display PDF documents.
This view controller can be used modally or embedded in another view controller.
Note
When adding as a child view controller, ensure view controller containment is set up correctly. If you override this class, ensure allUIViewController
methods you’re using do call super.
https://pspdfkit.com/guides/ios/customizing-the-interface/embedding-the-pspdfviewcontroller-inside-a-custom-container-view-controller/
For subclassing, use overrideClass:withClass:
to register your custom subclasses.
https://pspdfkit.com/guides/ios/getting-started/overriding-classes/
The best time for setting properties is during initialization in commonInitWithDocument:configuration:
. Some properties require a call to reloadData
if they are changed after the controller has been displayed. Do not set properties during a rotation phase or view appearance (e.g. use viewDidAppear:
instead of viewWillAppear:
) since that could corrupt internal state, instead use updateSettingsForBoundsChangeBlock
.
To provide a more immersive viewing experience, PDFViewController
shows content underneath the navigation bar
and allows the user to tap to hide this bar. Therefore, using bars with transparent backgrounds is not supported.
PDFViewController
will automatically handle disabling transparent bar backgrounds when its a direct child of a
UINavigationController
or a UITabBarController
. For other view controller hierarchies, you should disable
transparent bar backgrounds by setting the scrollEdgeAppearance
to be the same as the standardAppearance
on
the navigation bar, toolbar, or tab bar.
-
Initialize with a document.
Note
Document can be nil. In this case, just the background is displayed and the User Interface stays visible. Also supports creation viainitWithCoder:
to allow usage in Storyboards.Declaration
Objective-C
- (nonnull instancetype)initWithDocument:(nullable PSPDFDocument *)document configuration: (nullable PSPDFConfiguration *)configuration;
Swift
init(document: Document?, configuration: PDFConfiguration?)
-
Convenience init for
initWithDocument:configuration:
that uses a default configuration set.Declaration
Objective-C
- (nonnull instancetype)initWithDocument:(nullable PSPDFDocument *)document;
Swift
convenience init(document: Document?)
-
Property for the currently displayed document.
Note
To allow easier setup via Storyboards, this property also acceptsNSString
s. (The default bundle path will be used.)Declaration
Objective-C
@property (nonatomic, nullable) PSPDFDocument *document;
Swift
var document: Document? { get set }
-
Set or get selected annotations.
@note: All set selected annotations must be on the same page view.
Declaration
Objective-C
@property (nonatomic, copy) NSArray<PSPDFAnnotation *> *_Nonnull selectedAnnotations;
Swift
var selectedAnnotations: [Annotation] { get set }
-
The document view controller displaying the current document.
The
documentViewController
is a child view controller ofPDFViewController
. It is responsible for the main document content view, shown when the view controller is inPSPDFViewModeDocument
.Declaration
Objective-C
@property (nonatomic, readonly, nullable) PSPDFDocumentViewController *documentViewController;
Swift
var documentViewController: PSPDFDocumentViewController? { get }
-
Register delegate to capture events, change properties.
Declaration
Objective-C
@property (nonatomic, weak) id<PSPDFViewControllerDelegate> _Nullable delegate;
Swift
@IBOutlet weak var delegate: PSPDFViewControllerDelegate? { get set }
-
Register to be informed of and direct form submissions.
Declaration
Objective-C
@property (nonatomic, weak) id<PSPDFFormSubmissionDelegate> _Nullable formSubmissionDelegate;
Swift
@IBOutlet weak var formSubmissionDelegate: PDFFormSubmissionDelegate? { get set }
-
Reloads the view hierarchy and triggers a re-render of the document. This method is required to be called after most changed settings. Certain setters like changing a document will trigger this implicitly.
If possible (= the document has not changed significantly) this will preserve:
- The current view state (page and scrolling position)
Selected annotations
Note
This is called implicitly with
updateConfigurationWithBuilder:
.To reset the view port, call
applyViewState:animateIfPossible:
with a view state that only offers a page and not a specific view port:[[PSPDFViewState alloc] initWithPageIndex:pageIndex]
-
Reloads the view hierarchy and triggers a re-render of specific pages.
Annotation selection will be cleared.
Declaration
Objective-C
- (void)reloadPagesAtIndexes:(nonnull NSIndexSet *)indexes animated:(BOOL)animated;
Swift
func reloadPages(indexes: IndexSet, animated: Bool)
Parameters
indexes
The index set of the pages in the document to be reloaded.
animated
Whether to animate the view updates.
-
The index of the current page.
If there is more than one page displayed, the getter returns the index of the first page in the spread that is in the center of the viewport. With
PageTransition.scrollPerSpread
(displaying a single spread), this will be the lowest visible page index. WithPageTransition.scrollContinuous
this will be the index of the page in the center of the viewport.More advanced APIs to handle spread transitions and other document view mode related APIs are available through
PSPDFDocumentViewController
. In particular, these may be useful:documentViewController.visibleSpreadViews
,PSPDFSpreadView
’sspreadIndex
property, anddocumentViewController.layout.pageRangeForSpread(at spreadIndex)
.Setting the page index will be ignored if the document is not valid (e.g. locked).
See
-documentViewController
Declaration
Objective-C
@property (nonatomic) PSPDFPageIndex pageIndex;
Swift
var pageIndex: PageIndex { get set }
-
Sets the current page while optionally animating the change.
More advanced APIs to handle spread transitions and other document view mode related APIs are available through
PSPDFDocumentViewController
.Setting the page index will be ignored if the document is not valid (e.g. locked).
See
-documentViewController
Declaration
Objective-C
- (void)setPageIndex:(PSPDFPageIndex)pageIndex animated:(BOOL)animated;
Swift
func setPageIndex(_ pageIndex: PageIndex, animated: Bool)
Parameters
pageIndex
The page to transition to.
animated
true
if the transition should be animated,false
otherwise. -
Captures the current view–state of the receiver as a serializable object.
Note
There may not always be a view–state to capture. Reasons for this include the view not being loaded yet, no document being set, etc. As a rule of thumb, you should only expect to obtain a nonnull value afterviewDidAppear:
and beforeviewWillDisappear:
has been called.Declaration
Objective-C
@property (nonatomic, readonly, nullable) PSPDFViewState *viewState;
Swift
var viewState: PSPDFViewState? { get }
-
Applies a previously captured view state, optionally animated.
A word on timing: The most common use–case for this method is to seamlessly restore the reading position in a document when displaying the receiver. However, since restoring a viewport requires a fairly complete view hierarchy, you should not try to call this method directly after init. If you subclass PSPDFViewController,
viewWillAppear:
andviewDidLayoutSubviews
(after callingsuper
) are good times to do so.Note
ForPageTransition.curl
, only the page is restored.Declaration
Objective-C
- (void)applyViewState:(nonnull PSPDFViewState *)viewState animateIfPossible:(BOOL)animateIfPossible;
Swift
func applyViewState(_ viewState: PSPDFViewState, animateIfPossible: Bool)
Parameters
viewState
The state to restore.
animateIfPossible
A hint whether applying the state should be animated. It is not always possible to animate application of a new view state: Animation only ever happens if the view controller is currently on screen. Therefore, a
true
value may be silently ignored. -
Searches for
searchText
within the current document. Opens thePSPDFSearchViewController
, or presents inline search UI basedsearchMode
inPDFConfiguration
. IfsearchText
is nil, the UI is shown but no search is performed. The only valid option isPSPDFPresentationOptionSearchHeadless
to disable the search UI.Note
If search is already active (as determined by
isSearchActive
) then calling this method again will ignoreoptions
and won’t present the controller again. If you need to do that, first cancel the previous search usingcancelSearchAnimated:
.Declaration
Objective-C
- (void)searchForString:(nullable NSString *)searchText options:(nullable NSDictionary<PSPDFPresentationOption, id> *) options sender:(nullable id)sender animated:(BOOL)animated;
Swift
func search(for searchText: String?, options: [PresentationOption : Any]? = nil, sender: Any?, animated: Bool)
Parameters
options
Forwarded to the
presentViewController:options:animated:sender:completion:
method.sender
Used to anchor the search popover, if one should be displayed (see
searchMode
inPDFConfiguration
). -
Cancels search and hides search UI.
Declaration
Objective-C
- (void)cancelSearchAnimated:(BOOL)animated;
Swift
func cancelSearch(animated: Bool)
-
Returns YES if a search UI is currently being presented.
Declaration
Objective-C
@property (nonatomic, readonly, getter=isSearchActive) BOOL searchActive;
Swift
var isSearchActive: Bool { get }
-
The search view manager
Declaration
Objective-C
@property (nonatomic, readonly) PSPDFSearchHighlightViewManager *_Nonnull searchHighlightViewManager;
Swift
var searchHighlightViewManager: PSPDFSearchHighlightViewManager { get }
-
The inline search manager used when
PSPDFSearchModeInline
is set.Declaration
Objective-C
@property (nonatomic, readonly) PSPDFInlineSearchManager *_Nonnull inlineSearchManager;
Swift
var inlineSearchManager: InlineSearchManager { get }
-
The appearance manager, responsible for the rendering style and app theme.
Declaration
Objective-C
@property (nonatomic, readonly) PSPDFAppearanceModeManager *_Nonnull appearanceModeManager;
Swift
var appearanceModeManager: PDFAppearanceModeManager { get }
-
Text extraction class for current document. The delegate is set to this controller. Don’t change but create your own text search class instead if you need a different delegate.
Note
Will be recreated as the document changes. Returns nil if the document is nil. Thread safe.Declaration
Objective-C
@property (nonatomic, readonly) PSPDFTextSearch *_Nonnull textSearch;
Swift
var textSearch: TextSearch { get }
-
Executes a passed in PDF action.
Declaration
Objective-C
- (BOOL)executePDFAction:(nullable PSPDFAction *)action targetRect:(CGRect)targetRect pageIndex:(PSPDFPageIndex)pageIndex animated:(BOOL)animated actionContainer:(nullable id)actionContainer;
Parameters
action
The action to execute.
targetRect
The rect that triggered this action in the receiver’s view coordinate space.
pageIndex
The current page index. This is used for relative actions like
NamedActionType.nextPage
and to register a back action in the back-forward action list.animated
Whether the transition the action is describing should be animated.
actionContainer
The sender that triggered the execution of this action, such as an annotation or a button.
Return Value
Whether the action or at least one of its sub-actions was added to
backForwardList
. -
Represents previously invoked PDF actions and allows navigation through the action history.
You need to manually update this list if you’re executing actions outside of this view controller.
Declaration
Objective-C
@property (nonatomic, readonly) PSPDFBackForwardActionList *_Nonnull backForwardList;
Swift
var backForwardList: BackForwardActionList { get }
-
View that is displayed as User Interface.
Declaration
Objective-C
@property (nonatomic, readonly) PSPDFUserInterfaceView *_Nonnull userInterfaceView;
Swift
var userInterfaceView: UserInterfaceView { get }
-
Show or hide User Interface controls, titlebar, status bar (depending on the appearance properties).
Declaration
Objective-C
@property (nonatomic, assign, unsafe_unretained, readwrite, getter=isUserInterfaceVisible) BOOL userInterfaceVisible;
Swift
var isUserInterfaceVisible: Bool { get set }
-
Show or hide User Interface controls. optionally animated.
Declaration
Objective-C
- (BOOL)setUserInterfaceVisible:(BOOL)show animated:(BOOL)animated;
Swift
func setUserInterfaceVisible(_ show: Bool, animated: Bool) -> Bool
-
Show the User Interface. Respects
UserInterfaceViewMode
.Declaration
Objective-C
- (BOOL)showControlsAnimated:(BOOL)animated;
Swift
func show(animated: Bool) -> Bool
-
Hide the User Interface. Respects
UserInterfaceViewMode
.Declaration
Objective-C
- (BOOL)hideControlsAnimated:(BOOL)animated;
Swift
func hide(animated: Bool) -> Bool
-
Hide the User Interface (respects
UserInterfaceViewMode
) and additional elements like page selection.Declaration
Objective-C
- (BOOL)hideControlsAndPageElementsAnimated:(BOOL)animated;
Swift
func hideAndPageElements(animated: Bool) -> Bool
-
Toggles the User Interface. Respects
UserInterfaceViewMode
.Declaration
Objective-C
- (BOOL)toggleControlsAnimated:(BOOL)animated;
Swift
func toggle(animated: Bool) -> Bool
-
Content view. Use this if you want to add any always-visible UI elements. ContentView does NOT overlay the
navigationBar
/statusBar
, even if that one is transparent.Declaration
Objective-C
@property (nonatomic, readonly) PSPDFRelayTouchesView *_Nonnull contentView;
Swift
var contentView: RelayTouchesView { get }
-
Check this to determine the navigation bar visibility when it is managed by PSPDFKit. Will return the same value as
navigationController.navigationBarHidden
ifshouldHideNavigationBarWithUserInterface
is not set oruserInterfaceViewMode
is set toUserInterfaceViewMode.always
.Note
PSPDFKit always setsnavigationController.navigationBarHidden
tofalse
when managing navigation bar visibility.Declaration
Objective-C
@property (nonatomic, readonly, getter=isNavigationBarHidden) BOOL navigationBarHidden;
Swift
var isNavigationBarHidden: Bool { get }
-
The controller state that this view controller is currently in.
Declaration
Objective-C
@property (nonatomic, readonly) PSPDFControllerState controllerState;
Swift
var controllerState: ControllerState { get }
-
If
controllerState
equalsPSPDFControllerStateError
orPSPDFControllerStateLocked
, contains the underlying error.Declaration
Objective-C
@property (nonatomic, readonly, nullable) NSError *controllerStateError;
Swift
var controllerStateError: Error? { get }
-
The view controller that is used to present the current controller state overlay of the
PDFViewController
.Setting the overlay view controller makes it a child view controller of the receiver.
Note
The default value for this property is an internal view controller that is used to visualize the state. Only set this property if you want to take care of state handling yourself.Declaration
Objective-C
@property (nonatomic, nullable) UIViewController<PSPDFControllerStateHandling> *overlayViewController;
Swift
var overlayViewController: (UIViewController & ControllerStateHandling)? { get set }
-
Return the pageView for a given page. Returns nil if page is not Initialized (e.g. page is not visible.) Usually, using the delegates is a better idea to get the current page.
Declaration
Objective-C
- (nullable PSPDFPageView *)pageViewForPageAtIndex:(PSPDFPageIndex)pageIndex;
Swift
func pageViewForPage(at pageIndex: PageIndex) -> PSPDFPageView?
-
Get or set the current view mode. (
PSPDFViewModeDocument
orViewMode.thumbnails
)Declaration
Objective-C
@property (nonatomic) PSPDFViewMode viewMode;
Swift
var viewMode: ViewMode { get set }
-
Set the view mode, optionally animated.
Declaration
Objective-C
- (void)setViewMode:(PSPDFViewMode)viewMode animated:(BOOL)animated;
Swift
func setViewMode(_ viewMode: ViewMode, animated: Bool)
-
The controller shown in the
ViewMode.thumbnails
view mode. Contains a (grid) collectionView. Lazily created.Declaration
Objective-C
@property (nonatomic, readonly) PSPDFThumbnailViewController *_Nonnull thumbnailController;
Swift
var thumbnailController: PSPDFThumbnailViewController { get }
-
The controller shown in the
ViewMode.documentEditor
view mode. Lazily created.Note
Requires the Document Editor component to be enabled for your license.Declaration
Objective-C
@property (nonatomic, readonly) PSPDFDocumentEditorViewController *_Nonnull documentEditorController;
Swift
var documentEditorController: PSPDFDocumentEditorViewController { get }
-
Return array of all currently visible
PDFPageView
objects.@note: The underlying view is
UICollectionView
, thus this might return views that are not visible. Some reasons why the collection view might keep views around:- Prefetching (for smoother scrolling)
- The view contains a first responder (It is kept around until the responder moves somewhere else)
Declaration
Objective-C
@property (nonatomic, readonly) NSArray<PSPDFPageView *> *_Nonnull visiblePageViews;
Swift
var visiblePageViews: [PSPDFPageView] { get }
-
Called when
viewWillLayoutSubviews
is triggered.Note
You can use this to adapt to view frame changes (i.e., add or remove toolbar items). CheckpdfController.traitCollection
and act accordingly. -
Resets the apperance mode when view disappears. Defaults to
true
. Setting this property tofalse
can be useful when presenting multiplePDFViewController
instances and you want to persist the appearance mode.Note
You set this property tofalse
, you need to manually handle the appearance mode reset after dismissing the last controller.Declaration
Objective-C
@property (nonatomic) BOOL shouldResetAppearanceModeWhenViewDisappears;
Swift
var shouldResetAppearanceModeWhenViewDisappears: Bool { get set }
-
The configuration. Defaults to
+PSPDFConfiguration.defaultConfiguration
.Warning
You cannot set this property tonil
since the pdf controller must always have a configuration.Declaration
Objective-C
@property (nonatomic, copy, readonly) PSPDFConfiguration *_Nonnull configuration;
Swift
@NSCopying var configuration: PDFConfiguration { get }
-
Changes any value within
PDFConfiguration
and correctly updates the state in the controller.Note
This will invokereloadData
to apply the changes, which will reset the zoom level back to 1.0.Declaration
Objective-C
- (void)updateConfigurationWithBuilder: (nonnull void (^)(PSPDFConfigurationBuilder *_Nonnull))builderBlock;
Swift
func updateConfiguration(builder builderBlock: (PDFConfigurationBuilder) -> Void)
-
Updates the configuration without triggering a view reload.
See
updateConfigurationWithBuilder: for a better alternative.
Warning
You should know what you’re doing with using this updater.
The
PDFViewController
will not be reloaded, which can bring it into an invalid state. Use this for properties that don’t require reloading such astextSelectionEnabled
orscrollOnEdgeTapEnabled
. The benefit is that this method does not trigger a reload and thus is faster. As a general rule, any property that changes the view hierarchy will require an explicit update.Changes in PSPDFKit might result in differences around explicit/implicit updating. A property which was picked up before might no longer be updated automatically with an update. Makes sure to test calls to this option whenever you attempt a version update.
Declaration
Objective-C
- (void)updateConfigurationWithoutReloadingWithBuilder: (nonnull void (^)(PSPDFConfigurationBuilder *_Nonnull))builderBlock;
Swift
func updateConfigurationWithoutReloading(builder builderBlock: (PDFConfigurationBuilder) -> Void)
-
Show a modal view controller or a popover with automatically added close button on the left side. Use sender (
UIBarButtonItem
orUIView
) OR rect inoptions
(both only needed for the popover)See
PSPDFPresentationActions.h for compatible keys for
options
.Note
If this returns NO, the completion block won’t be called and presentation was blocked.
Declaration
Objective-C
- (BOOL)presentViewController:(nonnull UIViewController *)controller options: (nullable NSDictionary<PSPDFPresentationOption, id> *) options animated:(BOOL)animated sender:(nullable id)sender completion:(nullable void (^)(void))completion;
Swift
func present(_ controller: UIViewController, options: [PresentationOption : Any]? = nil, animated: Bool, sender: Any?, completion: (() -> Void)? = nil) -> Bool
-
Dismisses a view controller or popover controller, if class matches.
-
Invoked when a document action wants to present a new document modally. Can be subclassed to change behavior.
See
PSPDFPresentationActions.h for compatible keys foroptions
.Declaration
Objective-C
- (void)presentPDFViewControllerWithDocument:(nonnull PSPDFDocument *)document options:(nullable NSDictionary< PSPDFPresentationOption, id> *) options sender:(nullable id)sender animated:(BOOL)animated configurationBlock: (nullable void (^)(PSPDFViewController *_Nonnull)) configurationBlock completion: (nullable void (^)(void))completion;
Swift
func present(with document: Document, options: [PresentationOption : Any]? = nil, sender: Any?, animated: Bool, configurationBlock: ((PDFViewController) -> Void)?) async
-
Allows file preview using QuickLook. Will call
presentPDFViewControllerWithDocument:
if the pdf filetype is detected.See
PSPDFPresentationActions.h for compatible keys foroptions
.Declaration
Objective-C
- (void)presentPreviewControllerForURL:(nonnull NSURL *)fileURL title:(nullable NSString *)title options: (nullable NSDictionary< PSPDFPresentationOption, id> *)options sender:(nullable id)sender animated:(BOOL)animated completion:(nullable void (^)(void))completion;
Swift
func presentPreviewController(for fileURL: URL, title: String?, options: [PresentationOption : Any]? = nil, sender: Any?, animated: Bool) async
-
A convenience accessor for a pre-configured, persistent, annotation state manager for the controller.
Declaration
Objective-C
@property (nonatomic, readonly) PSPDFAnnotationStateManager *_Nonnull annotationStateManager;
Swift
var annotationStateManager: PSPDFAnnotationStateManager { get }
-
Use this if you want to customize the navigation bar appearance of a
PDFViewController
.Note
This creates anavigationItem
on demand, only call this method if you need it.Declaration
Objective-C
@property (nonatomic, readonly) PSPDFNavigationItem *_Nonnull navigationItem;
Swift
var navigationItem: NavigationItem { get }
-
Closes the active modal view controller. Default button in
leftBarButtonItems
if view is presented modally.Declaration
Objective-C
@property (nonatomic, readonly) UIBarButtonItem *_Nonnull closeButtonItem;
Swift
var closeButtonItem: UIBarButtonItem { get }
-
Presents the view controller of the
documentInfoCoordinator
, which show information like the document outline and bookmarks.Declaration
Objective-C
@property (nonatomic, readonly) UIBarButtonItem *_Nonnull outlineButtonItem;
Swift
var outlineButtonItem: UIBarButtonItem { get }
-
Presents the
SearchViewController
or theInlineSearchManager
for searching text in the currentdocument
.Declaration
Objective-C
@property (nonatomic, readonly) UIBarButtonItem *_Nonnull searchButtonItem;
Swift
var searchButtonItem: UIBarButtonItem { get }
-
A bar button item that shows Reader View, which reformats document text into an easy-to-read, single-column view that’s optimized for mobile devices.
This bar button item is not included by default. It must be programatically added to the left or right bar button items.
Reader View can also be presented programatically using the
ReaderViewController
class.Note
Requires the Reader View component to be enabled for your license.
See
https://pspdfkit.com/guides/ios/features/reader-view/ for further documentation.
Declaration
Objective-C
@property (nonatomic, readonly) UIBarButtonItem *_Nonnull readerViewButtonItem;
Swift
var readerViewButtonItem: UIBarButtonItem { get }
-
Toggles between the document and the thumbnails view state (
ViewMode.thumbnails
).See
PSPDFViewMode
See
setViewMode:animated:
Declaration
Objective-C
@property (nonatomic, readonly) UIBarButtonItem *_Nonnull thumbnailsButtonItem;
Swift
var thumbnailsButtonItem: UIBarButtonItem { get }
-
Toggles between the document and the document editor view state (
ViewMode.documentEditor
).Note
Requires the Document Editor component to be enabled for your license.
See
See
setViewMode:animated:
Declaration
Objective-C
@property (nonatomic, readonly) UIBarButtonItem *_Nonnull documentEditorButtonItem;
Swift
var documentEditorButtonItem: UIBarButtonItem { get }
-
Presents custom printing options and then invokes
UIPrintInteractionController
for document printing.This is a preset for invoking
PDFDocumentSharingViewController
usingDocumentSharingConfiguration.Destination.print
.Declaration
Objective-C
@property (nonatomic, readonly) UIBarButtonItem *_Nonnull printButtonItem;
Swift
var printButtonItem: UIBarButtonItem { get }
-
Presents export options and then invokes
UIDocumentInteractionController
to open the document in other apps.This is a preset for invoking
PDFDocumentSharingViewController
usingDocumentSharingConfiguration.Destination.otherApplication
.Declaration
Objective-C
@property (nonatomic, readonly) UIBarButtonItem *_Nonnull openInButtonItem;
Swift
var openInButtonItem: UIBarButtonItem { get }
-
Presents export options and then invokes
MFMailComposeViewController
to send the document via email.This is a preset for invoking
PDFDocumentSharingViewController
usingDocumentSharingConfiguration.Destination.email
.Note
Will only work when sending emails is configured on the device.Declaration
Objective-C
@property (nonatomic, readonly) UIBarButtonItem *_Nonnull emailButtonItem;
Swift
var emailButtonItem: UIBarButtonItem { get }
-
Presents export options and then invokes
MFMessageComposeViewController
to send the document via iMessage/SMS.This is a preset for invoking
PDFDocumentSharingViewController
usingDocumentSharingConfiguration.Destination.messages
.Note
Will only work if iMessage or SMS is configured on the device. Doesn’t work on Mac Catalyst as of macOS 12.Declaration
Objective-C
@property (nonatomic, readonly) UIBarButtonItem *_Nonnull messageButtonItem;
Swift
var messageButtonItem: UIBarButtonItem { get }
-
Shows and hides the
AnnotationToolbar
toolbar for creating annotations.Note
Requires theFeatures.annotationEditing
feature flag.Declaration
Objective-C
@property (nonatomic, readonly) UIBarButtonItem *_Nonnull annotationButtonItem;
Swift
var annotationButtonItem: UIBarButtonItem { get }
-
Shows a user interface for adding a signature to the document.
Note
Requires the Electronic Signatures feature to be enabled in your license.Declaration
Objective-C
@property (nonatomic, readonly) UIBarButtonItem *_Nonnull signatureButtonItem;
Swift
var signatureButtonItem: UIBarButtonItem { get }
-
Presents the
BookmarkViewController
for creating/editing/viewing bookmarks.Declaration
Objective-C
@property (nonatomic, readonly) UIBarButtonItem *_Nonnull bookmarkButtonItem;
Swift
var bookmarkButtonItem: UIBarButtonItem { get }
-
Presents the
BrightnessViewController
to control screen brightness and to change the appearance mode.Note
iOS has a similar feature in the control center, but PSPDFKit brightness includes an additional software brightener. Not available on Mac Catalyst.Declaration
Objective-C
@property (nonatomic, readonly) UIBarButtonItem *_Nonnull brightnessButtonItem;
Swift
var brightnessButtonItem: UIBarButtonItem { get }
-
Presents the
UIActivityViewController
for various actions, including many of the above button items.Declaration
Objective-C
@property (nonatomic, readonly) UIBarButtonItem *_Nonnull activityButtonItem;
Swift
var activityButtonItem: UIBarButtonItem { get }
-
Presents the
PDFSettingsViewController
to control some aspects of PSPDFViewController UX.Declaration
Objective-C
@property (nonatomic, readonly) UIBarButtonItem *_Nonnull settingsButtonItem;
Swift
var settingsButtonItem: UIBarButtonItem { get }
-
Transitions to the
.contentEditing
view mode.Important
Using this bar button item requires Content Editing feature to be included in your license.
Declaration
Objective-C
@property (nonatomic, readonly) UIBarButtonItem *_Nonnull contentEditingButtonItem;
Swift
var contentEditingButtonItem: UIBarButtonItem { get }
-
Add your custom
UIBarButtonItems
so that they won’t be automatically enabled/disabled. Contains thecloseButtonItem
by default.Warning
This needs to be set before settingleft/rightBarButtonItems
.Declaration
Objective-C
@property (nonatomic, copy) NSArray<UIBarButtonItem *> *_Nonnull barButtonItemsAlwaysEnabled;
Swift
var barButtonItemsAlwaysEnabled: [UIBarButtonItem] { get set }
-
Handles the controllers for metadata infos (outline, annotations, bookmarks, embedded files)
Declaration
Objective-C
@property (nonatomic, readonly) PSPDFDocumentInfoCoordinator *_Nonnull documentInfoCoordinator;
Swift
var documentInfoCoordinator: PSPDFDocumentInfoCoordinator { get }
-
Accesses and manages the annotation toolbar. To check if the toolbar is visible, check if a window is set on the toolbar.
Declaration
Objective-C
@property (nonatomic, readonly, nullable) PSPDFAnnotationToolbarController *annotationToolbarController;
Swift
var annotationToolbarController: PSPDFAnnotationToolbarController? { get }
-
Override this initializer to allow all use cases (storyboard loading, etc)
Warning
Do not call this method directly, except for calling super when overriding it.Declaration
Objective-C
- (void)commonInitWithDocument:(nullable PSPDFDocument *)document configuration:(nonnull PSPDFConfiguration *)configuration;
Swift
func commonInit(with document: Document?, configuration: PDFConfiguration)
-
Called when a document view controller has been created.
A document view controller may be created and destroyed multiple times through out the lifetime of a
PDFViewController
, depending on the document being set and its state.You can implement this method to customize a document view controller’s appearance.
Declaration
Objective-C
- (void)documentViewControllerDidLoad;
Swift
func documentViewControllerDidLoad()
-
Override if you’re changing the toolbar to your own. The toolbar is only displayed, if
PDFViewController
is inside aUINavigationController
.Declaration
Objective-C
- (void)updateToolbarAnimated:(BOOL)animated;
Swift
func updateToolbar(animated: Bool)
-
Return rect of the content view area excluding translucent toolbar/status bar.
Note
This method does not compensate for the navigation bar alone. Returns the view bounds when the view controller is not visible.Declaration
Objective-C
@property (nonatomic, readonly) CGRect contentRect;
Swift
var contentRect: CGRect { get }
-
Bar Button Actions
Declaration
Objective-C
- (void)annotationButtonPressed:(nullable id)sender;
Swift
func annotationButtonPressed(_ sender: Any?)
-
Will save the document. Don’t call this method directly.
Called with one of the reasons outlined in
PSPDFAutosaveReason
. Can be overridden to customize or disable autosaving.Note
document
might differ from the current set document, if it is changed while a file notification is received async.Declaration
Objective-C
- (void)handleAutosaveRequestForDocument:(nonnull PSPDFDocument *)document reason:(PSPDFAutosaveReason)reason;
Swift
func handleAutosaveRequest(for document: Document, reason: PSPDFAutosaveReason)
-
A collection of customizable interaction components.
Declaration
Objective-C
@property (nonatomic, readonly) id<PSPDFDocumentViewInteractions> _Nonnull interactions;
Swift
var interactions: DocumentViewInteractions { get }
-
Convenience initializer that takes a document and a generated configuration.
Declaration
Swift
convenience init(document: Document? = nil, delegate: PDFViewControllerDelegate? = nil, configurationBuilder builder: ((PDFConfigurationBuilder) -> Void) = { _ in })
Parameters
document
Document can be nil. In this case, just the background is displayed and the User Interface stays visible.
builder
A closure with optional configuration parameters.
-
A publisher that fires whenever the
pageIndex
changes.Declaration
Swift
var pageIndexPublisher: AnyPublisher<PageIndexChangeEvent, Never> { get }
-
Declaration
Swift
open override func validate(_ command: UICommand)