Pdf Fragment
open class PdfFragment : Fragment, DocumentListener, DocumentScrollListener, PdfDrawableManager, AnnotationManager, ContentEditingManager, FormManager, TextSelectionManager, SpecialModeManager, PageNavigator, AnnotationManager.OnAnnotationSelectedListener, AnnotationManager.OnAnnotationDeselectedListener, ActionResolver, FormManager.OnFormElementSelectedListener, FormManager.OnFormElementDeselectedListener, DocumentSaver.DocumentSaveListener, CopyPasteManagerClient
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
Properties
Link copied to clipboard
Link copied to clipboard
Default zoom scale.
Link copied to clipboard
Link copied to clipboard
Key for storing the last viewed page index inside the DocumentDataStore of the loaded document.
Link copied to clipboard
If the fragment is created from an image document source, the loaded image document will be stored here.
Link copied to clipboard
Indicates whether the document view is enabled right now, if it's disabled, scrolling and zooming is not possible.
Link copied to clipboard
Indicates whether UI is enabled right now.
Link copied to clipboard
Measurement Scale management
Link copied to clipboard
Navigation history to jump between pages when clicking links.
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Currently used custom signature storage.
Functions
Link copied to clipboard
open fun addAnnotationToPage(@NonNull annotation: Annotation, selectImmediately: Boolean, @Nullable completeAction: Runnable)
Adds annotation to page asynchronously, refreshing rendering in all UI components.
Link copied to clipboard
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
Link copied to clipboard
Adds a DocumentActionListener that can handle actions bound to PDF objects.
Link copied to clipboard
Adds a DocumentListener for listening to document events.
Link copied to clipboard
Adds a DocumentScrollListener for listening to scrolling events on the document.
Link copied to clipboard
Adds a PdfDrawableProvider to be managed by this object.
Link copied to clipboard
open fun addOnAnnotationCreationModeChangeListener(@NonNull listener: AnnotationManager.OnAnnotationCreationModeChangeListener)
Register a OnAnnotationCreationModeChangeListener to get notified when annotation creation mode gets updated.
Link copied to clipboard
open fun addOnAnnotationCreationModeSettingsChangeListener(@NonNull listener: AnnotationManager.OnAnnotationCreationModeSettingsChangeListener)
Register a OnAnnotationCreationModeSettingsChangeListener to get notified when annotation creation settings get updated.
Link copied to clipboard
open fun addOnAnnotationDeselectedListener(@NonNull listener: AnnotationManager.OnAnnotationDeselectedListener)
Register a OnAnnotationDeselectedListener to get notified when annotation gets deselected.
Link copied to clipboard
open fun addOnAnnotationEditingModeChangeListener(@NonNull listener: AnnotationManager.OnAnnotationEditingModeChangeListener)
Register a OnAnnotationEditingModeChangeListener to get notified when annotation editing mode gets updated.
Link copied to clipboard
open fun addOnAnnotationSelectedListener(@NonNull listener: AnnotationManager.OnAnnotationSelectedListener)
Register a OnAnnotationSelectedListener to get notified when annotation gets selected.
Link copied to clipboard
open fun addOnAnnotationUpdatedListener(@NonNull listener: AnnotationProvider.OnAnnotationUpdatedListener)
Register a AnnotationProvider.OnAnnotationUpdatedListener to get notified when annotation gets updated.
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun addOnFormElementClickedListener(@NonNull listener: FormManager.OnFormElementClickedListener)
Adds a OnFormElementClickedListener to get notified when form element has been clicked.
Link copied to clipboard
open fun addOnFormElementDeselectedListener(@NonNull listener: FormManager.OnFormElementDeselectedListener)
Adds a OnFormElementDeselectedListener to get notified when form element gets deselected.
Link copied to clipboard
open fun addOnFormElementEditingModeChangeListener(@NonNull listener: FormManager.OnFormElementEditingModeChangeListener)
Adds a OnFormElementEditingModeChangeListener to get notified when form element editing mode gets updated.
Link copied to clipboard
open fun addOnFormElementSelectedListener(@NonNull listener: FormManager.OnFormElementSelectedListener)
Adds a OnFormElementSelectedListener to get notified when form element gets selected.
Link copied to clipboard
open fun addOnFormElementUpdatedListener(@NonNull listener: FormManager.OnFormElementUpdatedListener)
Adds a OnFormElementUpdatedListener to get notified when form element gets updated.
Link copied to clipboard
open fun addOnFormElementViewUpdatedListener(@NonNull listener: FormManager.OnFormElementViewUpdatedListener)
Adds a OnFormElementViewUpdatedListener to get notified about form element view update events.
Link copied to clipboard
open fun addOnTextSelectionChangeListener(@NonNull listener: TextSelectionManager.OnTextSelectionChangeListener)
Adds a OnTextSelectionChangeListener, which gets notified when text selection changes in the document, such as different text is selected.
Link copied to clipboard
open fun addOnTextSelectionModeChangeListener(@NonNull listener: TextSelectionManager.OnTextSelectionModeChangeListener)
Adds a OnTextSelectionModeChangeListener, which gets notified when entering and exiting a text selection in the document.
Link copied to clipboard
Adds an OverlayViewProvider for adding overlay views to this fragment.
Link copied to clipboard
Notifies the navigation manager that calls to setPageIndex should be added to the navigation history until endNavigation is called.
Link copied to clipboard
Clears all currently selected Annotations.
Link copied to clipboard
Commits the page changes to the navigation history dropping everything but the very last one.
Link copied to clipboard
Starts the annotation creation mode with the last used annotation tool as the selected one.
open fun enterAnnotationCreationMode(@NonNull annotationTool: AnnotationTool, @NonNull annotationToolVariant: AnnotationToolVariant)
Enter annotation creation mode on the document.
Link copied to clipboard
Enter annotation editing mode on the document.
Link copied to clipboard
Starts the content editing mode which allows for modifying PDF content text
Link copied to clipboard
Enter form editing mode on the document.
Link copied to clipboard
Sets the current text selection.
Link copied to clipboard
Executes the given PDF
action
on the currently loaded document.Link copied to clipboard
Exit any currently active mode on the document (annotation creation, annotation editing, text selection).
Link copied to clipboard
Returns the active annotation tool.
Link copied to clipboard
Returns the variant of the active annotation tool variant (if any).
Link copied to clipboard
Returns annotation configuration registry with annotation configuration for supported annotation types and/or tools.
Link copied to clipboard
Link copied to clipboard
Returns manager for annotation preferences.
Link copied to clipboard
Returns this fragment's audio mode manager instance for entering/leaving audio playback or recording modes.
Link copied to clipboard
Gets the background color of the fragment.
Link copied to clipboard
Returns content editing fill color configuration Note: This method must be called after views are created (after onCreateView).
Link copied to clipboard
Returns manager for content editing preferences.
Link copied to clipboard
Returns the current content editing state.
Link copied to clipboard
Returns this fragment's undo manager instance for performing undo/redo operations of content edits.
Link copied to clipboard
Gets the loaded document.
Link copied to clipboard
Returns the InternalPdfFragmentApi.
Link copied to clipboard
Gets annotations that should be rendered as overlays.
Link copied to clipboard
Gets annotation types that should be rendered as overlays.
Link copied to clipboard
Gets number of pages in the document.
Link copied to clipboard
Gets currently displayed document page.
Link copied to clipboard
Returns currently set password view for the fragment.
Link copied to clipboard
Link copied to clipboard
Returns a list of currently selected annotations, or an empty list if no annotations were selected.
Link copied to clipboard
Returns currently selected form element.
Link copied to clipboard
Gets page sibling index (usable in double page mode).
Link copied to clipboard
Returns the current text selection.
Link copied to clipboard
Returns this fragment's undo manager instance for performing undo/redo operations of annotation edits.
Link copied to clipboard
Returns the ViewProjection for transforming between the view coordinates and PDF coordinates.
Link copied to clipboard
Fetch the list of pages currently visible on the screen.
Link copied to clipboard
Link copied to clipboard
Gets zoom scale at the specified page.
Link copied to clipboard
Indicates whether the displayed document is an image or not.
Link copied to clipboard
Returns
true
if any of the special modes is active.Link copied to clipboard
Returns redaction annotation preview mode,
false
by default.Link copied to clipboard
Indicates whether the scrolling is enabled, or not.
Link copied to clipboard
Indicates whether the zooming is enabled, or not.
Link copied to clipboard
open fun newImageInstance(@NonNull documentUri: Uri, @NonNull configuration: PdfConfiguration): PdfFragment
open fun newImageInstance(@NonNull source: DocumentSource, @NonNull configuration: PdfConfiguration): PdfFragment
open fun newImageInstance(@NonNull source: DataProvider, @NonNull configuration: PdfConfiguration): PdfFragment
Creates and returns a new Fragment to display a converted PDF document from a supported image format.
Link copied to clipboard
open fun newInstance(@NonNull documentUri: Uri, @NonNull configuration: PdfConfiguration): PdfFragment
open fun newInstance(@NonNull documentUri: Uri, @Nullable password: String, @NonNull configuration: PdfConfiguration): PdfFragment
open fun newInstance(@NonNull documentUri: Uri, @Nullable password: String, @Nullable contentSignature: String, @NonNull configuration: PdfConfiguration): PdfFragment
Creates and returns a new Fragment to display a PDF document.
open fun newInstance(@NonNull document: PdfDocument, @NonNull configuration: PdfConfiguration): PdfFragment
Creates and returns a new Fragment to display a PDF document from an already opened instance.
open fun newInstance(@NonNull fragment: PdfFragment, @NonNull configuration: PdfConfiguration): PdfFragment
Creates and returns a new Fragment to display a PDF document from an PdfFragment.
open fun newInstance(@NonNull documentUris: List<Uri>, @NonNull configuration: PdfConfiguration): PdfFragment
open fun newInstance(@NonNull documentUris: List<Uri>, @Nullable documentPasswords: List<String>, @NonNull configuration: PdfConfiguration): PdfFragment
open fun newInstance(@NonNull documentUris: List<Uri>, @Nullable documentPasswords: List<String>, @Nullable documentContentSignatures: List<String>, @NonNull configuration: PdfConfiguration): PdfFragment
Creates and returns a new Fragment to display passed list of PDF documents as a single compound document.
open fun newInstance(@NonNull source: DataProvider, @Nullable password: String, @NonNull configuration: PdfConfiguration): PdfFragment
Creates and returns a new Fragment to display a PDF document from a custom data source.
open fun newInstance(@NonNull source: DataProvider, @Nullable password: String, @Nullable contentSignature: String, @NonNull configuration: PdfConfiguration): PdfFragment
Creates and returns a new Fragment to display a PDF document from a custom data source
Link copied to clipboard
open fun newInstanceFromDocumentSources(@NonNull sources: List<DocumentSource>, @NonNull configuration: PdfConfiguration): PdfFragment
Creates and returns a new Fragment to display a PDF document from the given DocumentSources.
Link copied to clipboard
open fun newInstanceFromSources(@NonNull sources: List<DataProvider>, @NonNull configuration: PdfConfiguration): PdfFragment
open fun newInstanceFromSources(@NonNull sources: List<DataProvider>, @Nullable passwords: List<String>, @NonNull configuration: PdfConfiguration): PdfFragment
open fun newInstanceFromSources(@NonNull sources: List<DataProvider>, @Nullable passwords: List<String>, @Nullable contentSignatures: List<String>, @NonNull configuration: PdfConfiguration): PdfFragment
Creates and returns a new Fragment to display a PDF document from a custom data source as a compound document.
Link copied to clipboard
Notifies this fragment that the passed annotation has changed and that all the views displaying it should be updated.
Link copied to clipboard
Notifies this fragment that the passed annotations have changed and that all the views displaying it should be updated.
Link copied to clipboard
Notifies layout has changed and properly updates its internal state and views.
Link copied to clipboard
Called when annotation gets deselected.
Link copied to clipboard
The following listener methods are called after successful operation.
Link copied to clipboard
Link copied to clipboard
Called when annotation gets selected.
Link copied to clipboard
open fun onAnnotationSelectionFinished(@NonNull annotations: List<Annotation>, annotationCreated: Boolean)
Called when annotation gets selected.
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun onCreateView(@NonNull inflater: LayoutInflater, @Nullable container: ViewGroup, @Nullable savedInstanceState: Bundle): View
Link copied to clipboard
Link copied to clipboard
Called when the user taps / clicks on the document, not the page itself but on the side (if visible).
Link copied to clipboard
Called when document is successfully loaded and the document view has been laid out.
Link copied to clipboard
Called if document loading has failed.
Link copied to clipboard
open fun onDocumentSave(@NonNull document: PdfDocument, @NonNull saveOptions: DocumentSaveOptions): Boolean
Called before document will be saved.
Link copied to clipboard
Called if document saving has been cancelled.
Link copied to clipboard
Called after the document has been saved.
Link copied to clipboard
Called if document saving has failed.
Link copied to clipboard
Link copied to clipboard
open fun onDocumentZoomed(@NonNull document: PdfDocument, @IntRange(from = 0 ) pageIndex: Int, scaleFactor: Float)
Called when a user zooms a document.
Link copied to clipboard
Called when form element gets deselected.
Link copied to clipboard
Called when form element gets selected.
Link copied to clipboard
Link copied to clipboard
Called when user scrolled to a new page.
Link copied to clipboard
open fun onPageClick(@NonNull document: PdfDocument, @IntRange(from = 0 ) pageIndex: Int, @Nullable event: MotionEvent, @Nullable pagePosition: PointF, @Nullable clickedAnnotation: Annotation): Boolean
Called when user taps / clicks on the page.
Link copied to clipboard
Called when content of page with pageIndex has changed (for example due to annotation or form field being updated).
Link copied to clipboard
open fun onPrepareAnnotationSelection(@NonNull controller: AnnotationSelectionController, @NonNull annotation: Annotation, annotationCreated: Boolean): Boolean
Called immediately before annotation is going to be selected.
Link copied to clipboard
Called by the activity if it requires the fragment to save its state.
Link copied to clipboard
Called whenever the current scroll state of the document view has changed.
Link copied to clipboard
Link copied to clipboard
Re initialises DocumentView if total number of visible pages are 0.
Link copied to clipboard
Removes a listener from the list of AnnotationViewsListeners.
Link copied to clipboard
Removes a previously added DocumentActionListener that can handle actions bound to PDF objects.
Link copied to clipboard
Removes a previously registered DocumentListener.
Link copied to clipboard
Removes a previously registered DocumentScrollListener.
Link copied to clipboard
Removes a previously added PdfDrawableProvider.
Link copied to clipboard
open fun removeOnAnnotationCreationModeChangeListener(@NonNull listener: AnnotationManager.OnAnnotationCreationModeChangeListener)
Remove a previously registered OnAnnotationCreationModeChangeListener.
Link copied to clipboard
open fun removeOnAnnotationCreationModeSettingsChangeListener(@NonNull listener: AnnotationManager.OnAnnotationCreationModeSettingsChangeListener)
Remove a previously registered OnAnnotationCreationModeSettingsChangeListener.
Link copied to clipboard
open fun removeOnAnnotationDeselectedListener(@NonNull listener: AnnotationManager.OnAnnotationDeselectedListener)
Remove a previously registered OnAnnotationDeselectedListener.
Link copied to clipboard
open fun removeOnAnnotationEditingModeChangeListener(@NonNull listener: AnnotationManager.OnAnnotationEditingModeChangeListener)
Remove a previously registered OnAnnotationEditingModeChangeListener.
Link copied to clipboard
open fun removeOnAnnotationSelectedListener(@NonNull listener: AnnotationManager.OnAnnotationSelectedListener)
Remove a previously registered OnAnnotationSelectedListener.
Link copied to clipboard
open fun removeOnAnnotationUpdatedListener(@NonNull listener: AnnotationProvider.OnAnnotationUpdatedListener)
Remove a previously registered AnnotationProvider.OnAnnotationUpdatedListener.
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun removeOnFormElementClickedListener(@NonNull listener: FormManager.OnFormElementClickedListener)
Removes a previously registered OnFormElementClickedListener.
Link copied to clipboard
open fun removeOnFormElementDeselectedListener(@NonNull listener: FormManager.OnFormElementDeselectedListener)
Removes a previously registered OnFormElementDeselectedListener.
Link copied to clipboard
open fun removeOnFormElementEditingModeChangeListener(@NonNull listener: FormManager.OnFormElementEditingModeChangeListener)
Removes a previously registered OnFormElementEditingModeChangeListener.
Link copied to clipboard
open fun removeOnFormElementSelectedListener(@NonNull listener: FormManager.OnFormElementSelectedListener)
Removes a previously registered OnFormElementSelectedListener.
Link copied to clipboard
open fun removeOnFormElementUpdatedListener(@NonNull listener: FormManager.OnFormElementUpdatedListener)
Removes a previously registered OnFormElementUpdatedListener.
Link copied to clipboard
open fun removeOnFormElementViewUpdatedListener(@NonNull listener: FormManager.OnFormElementViewUpdatedListener)
Removes a previously registered OnFormElementViewUpdatedListener.
Link copied to clipboard
open fun removeOnTextSelectionChangeListener(@NonNull listener: TextSelectionManager.OnTextSelectionChangeListener)
Removes a OnTextSelectionChangeListener, which gets notified when text selection changes in the document, such as different text is selected.
Link copied to clipboard
open fun removeOnTextSelectionModeChangeListener(@NonNull listener: TextSelectionManager.OnTextSelectionModeChangeListener)
Removes a previously added OnTextSelectionModeChangeListener, which gets notified when entering and exiting a text selection in the document.
Link copied to clipboard
Removes a previously added OverlayViewProvider.
Link copied to clipboard
open fun setAnnotationOverlayRenderStrategy(@Nullable overlayRenderStrategy: AnnotationOverlayRenderStrategy)
Sets the annotation overlay render strategy.
Link copied to clipboard
Sets the background color of the fragment.
Link copied to clipboard
Sets the custom source for the PDF file.
Link copied to clipboard
Sets the custom sources for the PDF file.
Link copied to clipboard
Sets a OnDocumentLongPressListener for long press document events.
Link copied to clipboard
Sets the listener that will allow you to get notified when each of the popup toolbars is prepared and ready to be displayed.
Link copied to clipboard
Sets annotations that should be rendered as overlays.
Link copied to clipboard
Sets annotation types that should be rendered as overlays.
Link copied to clipboard
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.Sets the
pageIndex
to be displayed (0 is the first one).Link copied to clipboard
Sets drawable that should be displayed instead of fragment's contents (i.e.
Link copied to clipboard
Sets password view to be used for the password-protected documents.
Link copied to clipboard
Sets redaction annotations preview as redacted.
Link copied to clipboard
Enables/disabled the scrolling performed by the user.
Link copied to clipboard
Selects a single Annotation.
Link copied to clipboard
Sets the currently selected Annotations.
Link copied to clipboard
Sets the currently selected FormElement.
Link copied to clipboard
open fun setSelectedMeasurementValueConfiguration(@NonNull configuration: MeasurementValueConfiguration)
For measurement tools, you can set and select whichever MeasurementValueConfiguration you want using this API.
Link copied to clipboard
Enables/disabled the zooming performed by the user.