Pdf Fragment
Fragment that actually displays the PDF document. It contains only the document view without any additional views like outline, thumbnail bar, search, etc. Meant to be used if you want full custom implementation and design.
Inheritors
Types
Factory methods and bundle argument keys for PdfFragment.
Properties
Returns the active annotation tool.
Returns the variant of the active annotation tool variant (if any).
Returns the AI Assistant provider associated with this fragment.
Returns annotation configuration registry with annotation configuration for supported annotation types and/or tools.
Returns the annotation creator name used when creating new annotations.
Returns manager for annotation preferences.
Background color of the fragment. It's the background of the area behind the pages.
Returns the configuration for this fragment.
Returns content editing fill color configuration
Returns manager for content editing preferences.
Returns the current content editing state.
The loaded document, or null if no document is loaded.
The document coordinator used for managing multiple documents.
Whether the annotation overlay is drawn above overlay views. By default, overlay views are drawn above the annotation overlay. Set this to true to allow overlaid annotations (for example, stamps rendered in overlay mode) to cover overlay views.
Whether the annotation overlay is enabled. When disabled, annotations rendered in overlay mode will be hidden. This does not affect annotations rendered directly on the page.
Indicates whether interaction with the document is enabled right now. When the interaction is disabled you can no longer scroll or zoom the document in any way; any other UI like the thumbnail bar is still enabled.
Returns true if any of the special modes is active.
Whether redaction annotations are previewed as redacted, false by default. When true, redaction annotations are shown as redacted; when false, they are shown as marks.
Whether scrolling performed by the user is enabled. Enabled by default.
Indicates whether UI is enabled right now. UI is disabled when document is being saved/loaded, or when manually disabled.
Whether zooming performed by the user is enabled. Enabled by default.
An editor object that allows you to add/delete/modify measurement scales MeasurementValueConfiguration Be aware that this is null until a PDFDocument is assigned to the fragment.
The annotations currently displayed in overlay mode.
Annotation types that should be rendered as overlays.
Password view used for password-protected documents.
Returns the listener for recording edits for undo/redo functionality.
Returns a list of currently selected annotations, or an empty list if no annotations were selected.
Returns currently selected form element.
Steps into the built-in electronic signature flow before the signature dialog is shown and before a created signature is added to the document — for example to let the user pick a stroke thickness and opacity in a UI of your own, or to decide where the signature goes.
The currently used signature storage that will be used to store signatures when they're added to the document. If null, the default storage will be used by all the handlers.
Returns the current text selection.
This fragment's undo manager instance for performing undo/redo operations of annotation edits.
Returns the ViewProjection for transforming between the view coordinates and PDF coordinates.
Fetch the list of pages currently visible on the screen.
Functions
Adds annotation to page asynchronously, refreshing rendering in all UI components.
Adds an AnnotationViewsListener to the list of listeners that will be notified when the internal views factory creates an EditText widget for editing a FreeText annotation
Adds a DocumentActionListener that can handle actions bound to PDF objects. If the listener has already been added previously, this method will be a no-op. Adding null is not allowed, and will result in an exception.
Adds a DocumentListener for listening to document events. If the listener has already been added previously, this method will be a no-op. Listeners registered with this method will be unregistered automatically in .onDetach. Passing null is not allowed, and will result in an exception.
Adds a DocumentScrollListener for listening to scrolling events on the document. If the listener has already been added previously, this method will be a no-op. Listeners registered with this method will be unregistered automatically in .onDetach. Passing null is not allowed, and will result in an exception.
Adds a PdfDrawableProvider to be managed by this object. If the provider has been added previously, this method will be a no-op. Adding null is not allowed, and will result in an exception.
Register a listener to get notified when annotation mode (creation or editing) changes. This is the recommended way to listen for annotation mode changes.
Register a OnAnnotatingModeSettingsChangeListener to get notified when annotation mode settings get updated.
Registers a listener to be notified when annotations are selected or deselected.
Registers a listener to be notified when annotations are updated.
Registers a listener to be notified when content editing content changes.
Registers a listener to be notified when content editing mode changes.
Adds a OnFormElementClickedListener to get notified when form element has been clicked. If the listener has already been added previously, this method will be a no-op. Adding null is not allowed, and will result in an exception.
Adds a OnFormElementDeselectedListener to get notified when form element gets deselected. If the listener has already been added previously, this method will be a no-op. Adding null is not allowed, and will result in an exception.
Adds a OnFormElementEditingModeChangeListener to get notified when form element editing mode gets updated. If the listener has already been added previously, this method will be a no-op. Adding null is not allowed, and will result in an exception.
Adds a OnFormElementSelectedListener to get notified when form element gets selected. If the listener has already been added previously, this method will be a no-op. Adding
null is not allowed, and will result in an exception.
Adds a OnFormElementUpdatedListener to get notified when form element gets updated. If the listener has already been added previously, this method will be a no-op. Adding
null is not allowed, and will result in an exception.
Adds a OnFormElementViewUpdatedListener to get notified about form element view update events. If the listener has already been added previously, this method will be a no-op. Adding null is not allowed, and will result in an exception.
Adds a OnTextFormElementSuggestionRequestListener to get notified when a text form element requests autocomplete suggestions. If the listener has already been added previously, this method will be a no-op. Adding null is not allowed, and will result in an exception.
Adds a OnTextSelectionChangeListener, which gets notified when text selection changes in the document, such as different text is selected. If the listener has already been added previously, this method will be a no-op. Adding null is not allowed, and will result in an exception.
Adds a OnTextSelectionModeChangeListener, which gets notified when entering and exiting a text selection in the document. If the listener has already been added previously, this method will be a no-op. Adding null is not allowed, and will result in an exception.
Adds an OverlayViewProvider for adding overlay views to this fragment. If the provider has been added previously, this method will be a no-op. Adding null is not allowed, and will result in an exception.
Notifies the navigation manager that calls to setPageIndex should be added to the navigation history until endNavigation is called.
Clears all currently selected Annotations. This method may only be called on the main thread (UI thread).
Commits the page changes to the navigation history dropping everything but the very last one.
Starts the annotating mode with the last used annotation tool as the selected one.
Enter annotation creation mode on the document. Once you invoke this method, you'll get AnnotatingController (through registered OnAnnotatingModeChangeListener) which provides methods for annotation creation with a specified type. Uses default AnnotationToolVariant.
Enter annotation creation mode on the document. Once you invoke this method, you'll get AnnotatingController (through registered OnAnnotatingModeChangeListener) which provides methods for annotation creation with a specified type.
Enter annotation creation mode on the document.
Enter annotation creation mode on the document with the given annotation tool.
Enter annotation creation mode on the document with the given annotation tool and variant.
Enter annotation editing mode on the document. Once you invoke this method, you'll get AnnotatingController (through registered OnAnnotatingModeChangeListener) which provides methods for editing selected annotations. Notice: this method will not select annotation on the screen, for that use setSelectedAnnotation.
Enter annotation editing mode on the document. Once you invoke this method, you'll get AnnotatingController (through registered OnAnnotatingModeChangeListener) which provides methods for editing a selected annotation. Notice: this method will not select annotation on the screen, for that use setSelectedAnnotation.
Starts the content editing mode which allows for modifying PDF content text
Enter form editing mode on the document. Once you invoke this method, you'll get FormEditingController (through registered OnFormElementEditingModeChangeListener) which provides methods for editing a selected form element. Notice: this method will not select form element on the screen, for that use setSelectedFormElement.
Sets the current text selection. Once you invoke this method, you'll get TextSelectionController (through registered OnTextSelectionModeChangeListener) which provides methods for managing text selection actions.
Executes the given PDF action on the currently loaded document.
Exit any currently active mode on the document (annotation creation, annotation editing, text selection).
Gets the annotation overlay render strategy for the specified annotation.
Returns this fragment's audio mode manager instance for entering/leaving audio playback or recording modes.
Returns this fragment's undo manager instance for performing undo/redo operations of content edits.
Returns the loaded image document, or null if this fragment does not hold an image document.
Returns the navigation history owned by this manager.
Gets number of pages in the document.
Gets currently displayed document page.
Gets page sibling index (usable in double page mode).
Sets targetRect to contain the visible PDF rect of the given pageIndex. If the pageIndex is not visible on the screen, targetRect won't be modified and the method will return false.
Gets zoom scale at the specified page.
Hides the annotation selection popup toolbar if it is currently shown.
Invalidates the Document view
Indicates whether the displayed document is an image or not.
Notifies this fragment that the passed annotation has changed and that all the views displaying it should be updated. Calling this method before document is loaded will have no effect. If you see annotations not rendering during zooming or page transitions, you probably need to call this function.
Notifies this fragment that the passed annotations have changed and that all the views displaying it should be updated. Calling this method before document is loaded will have no effect.
Notifies layout has changed and properly updates its internal state and views. Call this when PdfFragment is embedded in a ViewGroup that has changed its size, this will schedule a layout pass of the view tree, after views have been laid out.
Called when annotation gets deselected.
The following listener methods are called after successful operation. They might be called from a background thread, be careful when accessing the UI from there
Called when annotations have been cut to the clipboard. Shows a toast notification indicating the annotations were cut.
Called when annotation gets selected.
Called when annotation gets selected.
Called when annotations have been pasted from the clipboard. Selects the pasted annotations and shows a toast notification.
Called when a device configuration change occurs while the fragment is running. Updates the layout and view coordinator to handle orientation or size changes.
Called to create and return the view hierarchy for this fragment. Creates the PDF document view with configuration settings from the theme.
Called when the view previously created by onCreateView is being destroyed. Cleans up view-related resources and listeners.
Called when the user taps / clicks on the document, not the page itself but on the side (if visible).
Called when document is successfully loaded and the document view has been laid out. This has to be called on the main thread.
Called before document will be saved. Allows cancellation of the save process.
Called if document saving has been cancelled.
Called after the document has been saved.
Called if document saving has failed.
Called whenever the document in the fragment scrolled. Values are expressed in an arbitrary unit and may change with every call. Also maxX and maxY are not guaranteed to remain the same between two calls.
Called when a user zooms a document.
Called when form element gets deselected.
Called when form element gets selected.
Called when user scrolled to a new page.
Called when user taps / clicks on the page.
Called when content of page with pageIndex has changed (for example due to annotation or form field being updated). All views displaying this page need to refresh.
Called immediately before annotation is going to be selected.
Called by the activity if it requires the fragment to save its state. Since this method can also be called when the fragment is on the backstack and has no view, this method may not rely on any views being present at the time of calling.
Called whenever the current scroll state of the document view has changed.
Called after the view has been created. Initializes the document view and starts document loading if not already started.
Re initialises DocumentView if total number of visible pages are 0. This is useful when the document is loaded but the pages are cleared for example when this is used in a ViewPager.
Removes a listener from the list of AnnotationViewsListeners.
Removes a previously added DocumentActionListener that can handle actions bound to PDF objects. Upon calling this method the listener will no longer be notified of any changes. If the listener has not been added, this method will be a no-op. Adding null is not allowed, and will result in an exception.
Removes a previously registered DocumentListener. After calling this method the documentListener will stop receiving document events. If the listener has not been added previously, this method will be a no-op. Passingnull is not allowed, and will result in an exception.
Removes a previously registered DocumentScrollListener. After calling this method the documentScrollListener will stop receiving scrolling events. If the listener has not been added previously, this method will be a no-op. Passingnull is not allowed, and will result in an exception.
Removes a previously added PdfDrawableProvider. If the provider hasn't been added previously, this method will be a no-op.
Remove a previously registered OnAnnotatingModeChangeListener.
Remove a previously registered OnAnnotatingModeSettingsChangeListener.
Removes a previously registered annotation selection listener.
Removes a previously registered annotation update listener.
Removes a previously registered content editing content change listener.
Removes a previously registered content editing mode change listener.
Removes a previously registered OnFormElementClickedListener. Upon calling this method the listener will no longer be notified of any changes. If the listener has not been added, this method will be a no-op. Adding null is not allowed,and will result in an exception.
Removes a previously registered OnFormElementDeselectedListener. Upon calling this method the listener will no longer be notified of any changes. If the listener has not been added, this method will be a no-op. Adding null is not allowed,and will result in an exception.
Removes a previously registered OnFormElementEditingModeChangeListener. Upon calling this method the listener will no longer be notified of any changes. If the listener has not been added, this method will be a no-op. Adding null is not allowed,and will result in an exception.
Removes a previously registered OnFormElementSelectedListener. Upon calling this method the listener will no longer be notified of any changes. If the listener has not been added, this method will be a no-op. Adding null is not allowed,and will result in an exception.
Removes a previously registered OnFormElementUpdatedListener. Upon calling this method the listener will no longer be notified of any changes. If the listener has not been added, this method will be a no-op. Adding null is not allowed,and will result in an exception.
Removes a previously registered OnFormElementViewUpdatedListener. Upon calling this method the listener will no longer be notified of any changes. If the listener has not been added, this method will be a no-op. Adding null is not allowed, and will result in an exception.
Removes a previously registered OnTextFormElementSuggestionRequestListener. Upon calling this method the listener will no longer be notified of any requests. If the listener has not been added, this method will be a no-op. Adding null is not allowed, and will result in an exception.
Removes a OnTextSelectionChangeListener, which gets notified when text selection changes in the document, such as different text is selected. Upon calling this method the listener will no longer be notified. If the listener has not been added, this method will be a no-op.
Removes a previously added OnTextSelectionModeChangeListener, which gets notified when entering and exiting a text selection in the document. Upon calling this method the listener will no longer be notified. If the listener has not been added, this method will be a no-op.
Removes a previously added OverlayViewProvider. If the provider hasn't been added previously, this method will be a no-op.
Scrolls to the given pdfRect, if necessary changing to the page. This will keep the current zoom level. If scrollWhenVisible is false this method will be a no-op if the pdfRect is already completely visible.
Sets the annotation overlay render strategy. This strategy defines how annotations that are displayed in overlay mode (i.e. views which are rendered as views inside the activities view hierarchy) should be rendered. By default, Nutrient uses AnnotationOverlayRenderStrategy.Strategy.PLATFORM_RENDERING for all annotations. You can override this behavior by setting a custom strategy using this method. For more information about the available render strategies please see AnnotationOverlayRenderStrategy.
Sets the custom source for the PDF file.
Sets the custom sources for the PDF file. Can be used to load a different - or reload the same - document into the Fragment. The fragment will not be destroyed by this operation.
Sets a OnDocumentLongPressListener for long press document events. Listener registered with this method will be unregistered automatically in .onDetach. Calling this method will replace any previously set listener. You may provide null to switch to the default listener.
Sets the listener that will allow you to get notified when each of the popup toolbars is prepared and ready to be displayed. This allows you to set your own items, change the appearance of the toolbar, etc.
Sets the listener notified when critical native memory pressure persists despite the SDK's automatic recovery (cache trimming, render abort and backoff). Transient pressure episodes recover silently and never invoke the listener; once it does fire, the recommended response is to release this document — finish the host activity, replace the document, or remove the fragment.
Sets the pageIndex to be displayed (0 is the first one), using our default decision on animating, which is to animate the transition if the page is next/before the current page, and not animate if further away. For custom animation control , use setPageIndex.
Sets the pageIndex to be displayed (0 is the first one). If animated is set to true, the page jump will be animated. If false, the page will be shown immediately.
Sets drawable that should be displayed instead of fragment's contents (i.e. loading throbber) until document is loaded and all visible pages are rendered.
Selects a single Annotation. This will also start annotation editing mode with selected annotation being edited.
Sets the currently selected Annotations.
Sets the currently selected FormElement.
For measurement tools, you can set and select whichever MeasurementValueConfiguration you want using this API. This will set what com.pspdfkit.annotations.measurements.Scale and com.pspdfkit.annotations.measurements.MeasurementPrecision you want to use.
Shows the annotation selection popup toolbar for the currently selected annotations. This can be used after calling .setSelectedAnnotations to programmatically display the popup toolbar. Does nothing if no annotations are selected, if the popup toolbar is disabled in the configuration, or if the page editor is not yet available.