open class PdfView : ViewGroup


A View for presenting PDF content, represented by PdfDocument.

This View supports zooming, scrolling, and flinging. Zooming is supported via pinch gesture, quick scale gesture, and double tap to zoom in or snap back to fitting the page width inside its bounds. Zoom can be changed using the zoom property, which is notably distinct from View.getScaleX / View.getScaleY. Scroll position is based on the View.getScrollX / View.getScrollY properties.

This inherits ViewGroup but does not support adding arbitrary children via addView or in a layout.

Summary

Nested types

Listener interface for handling clicks on links in a PDF document.

Listener interface to receive a callback on the UI thread when the content of the PDF document has been loaded for the first time.

Listener interface for handling form edits on a PDF Document.

Listener interface to receive callbacks when the PdfView starts and stops being affected by an external input like user touch.

Listener interface to receive updates when the currentSelection changes

Listener interface to receive changes to the viewport, i.e. the window of visible PDF content

Interface to customize the set of actions in the selection menu

Constants

const Int

The PdfView is not currently being affected by an outside input, e.g. user touch

const Int

The PdfView is currently being affected by an outside input, e.g. user touch

const Int

The PdfView is currently animating to a final position while not under outside control, e.g. settling on a final position following a fling gesture.

const Int

Vertically aligns the page to the center of the PdfView.

const Int

Vertically aligns the page to the top of the PdfView.

Public constructors

PdfView(context: Context, attrs: AttributeSet?, defStyle: Int)

Public functions

Unit

Adds the specified listener to the list of listeners that will be notified on first content load.

Unit

Adds the specified listener to the list of listeners that is notified when any form widget is updated due to an edit action on a widget e.g. click on a radio button.

Unit

Adds the specified listener to the list of listeners that will be notified of changes in state with respect to this PdfView being affected by an external input, e.g. user touch.

Unit

Adds the specified listener to the list of listeners that will be notified of selection change events.

Unit

Adds the specified listener to the list of listeners that will be notified of viewport change events.

Unit

Adds the specified listener to the chain of SelectionMenuItemPreparer.

open Unit
addView(child: View?)
open Unit
addView(child: View?, index: Int)
open Unit
addView(child: View?, params: ViewGroup.LayoutParams?)
open Unit
addView(child: View?, index: Int, params: ViewGroup.LayoutParams?)
open Unit
addView(child: View?, width: Int, height: Int)
open Unit
Unit

Clears the current selection, if one exists.

open Unit
open Boolean

Prioritizes standard keyboard shortcuts over accessibility-specific handling of certain keys.

open Boolean
open Unit
open Boolean
PointF?

Returns the View coordinate location of pdfPoint, or null if that PDF content has not been laid out yet.

Unit

Removes the specified listener from the list of listeners that will be notified on first content load.

Unit

Removes the specified listener from the list of listeners that is notified when any form widget is updated due to an edit action on the widget e.g. click on a radio button.

Unit

Removes the specified listener from the list of listeners that will be notified of changes in state with respect to this PdfView being affected by an external input, e.g. user touch.

Unit

Removes the specified listener from the list of listeners that will be notified of selection change events.

Unit

Removes the specified listener from the list of listeners that will be notified of viewport change events.

Unit

Removes the specified listener from the chain of SelectionMenuItemPreparer.

open Unit
scrollBy(x: Int, y: Int)
open Unit
scrollTo(x: Int, y: Int)
Unit
scrollToPage(pageNum: Int)

Scrolls to the 0-indexed pageNum, optionally animating the scroll

Unit

Scrolls to position, aligns vertically to center, optionally animating the scroll

Unit

Applies a set of Highlight to be drawn over this PDF.

Unit

Registers listener as the callback to be invoked when an external link in the PDF is clicked.

Unit
setOcrProvider(ocrProvider: OcrProvider?)

Sets the OcrProvider used for recognizing text in image-based PDF content.

PdfPoint?
viewToPdfPoint(viewPoint: PointF)

Returns the PdfPoint corresponding to viewPoint in View coordinates, or null if no PDF content has been laid out at viewPoint

PdfPoint?

Returns the PdfPoint corresponding to (x, y)in View coordinates, or null if no PDF content has been laid out at that point.

Protected functions

open Int
open Int
open Boolean
open Unit
open Unit
open Unit
open Unit
onDraw(canvas: Canvas)
open Unit
onFocusChanged(
    gainFocus: Boolean,
    direction: Int,
    previouslyFocusedRect: Rect?
)
open Unit
onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int)
open Unit
open Parcelable?
open Unit
onScrollChanged(l: Int, t: Int, oldl: Int, oldt: Int)
open Unit
onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int)
open Unit

Public properties

Selection?

The currently selected PDF content, as Selection, or 'null' if no content is currently selected.

Drawable
Int
Drawable
Int
Int

The first page in the viewport, including partially-visible pages.

Int

The current state of the PDF view with respect to external inputs, e.g. user touch.

@IntRange(from = 0) Int

The spacing between two horizontally adjacent pages in pixels.

Boolean

Enables / Disables the form-filling feature surface.

Boolean

Enable or disable the image-selection feature surface.

Float

The maximum scaling factor that can be applied to this View using the zoom property.

Float

The minimum scaling factor that can be applied to this View using the zoom property.

@IntRange(from = 1, to = 2) Int

The number of pages displayed side-by-side in a single row.

PdfDocument?

Supply a PdfDocument to process the PDF content for rendering

Int

Controls the vertical alignment of a page within the PdfView.

@IntRange(from = 0) Int

The spacing between vertically adjacent pages in pixels.

Int

The number of pages visible in the viewport, including partially visible pages

Float

The zoom level of this view, as a factor of the content's natural size with when 1 pixel is equal to 1 PDF point.

Inherited functions

From android.view.View
Unit
addFocusables(views: ArrayList<View>, direction: Int)
Unit
Unit
Unit
ViewPropertyAnimator
Unit
Unit
Boolean
Boolean
awakenScrollBars(startDelay: Int)
Boolean
awakenScrollBars(startDelay: Int, invalidate: Boolean)
Unit
Unit
Unit
Unit
Boolean
open Boolean
open Boolean
open Boolean
Boolean
Boolean
Unit
Unit
Unit
Boolean
Unit
Unit
Unit
Int
Int
WindowInsets
Int
Int
AccessibilityNodeInfo
open Unit
Unit
Boolean
Boolean
dispatchNestedFling(velocityX: Float, velocityY: Float, consumed: Boolean)
Boolean
dispatchNestedPreFling(velocityX: Float, velocityY: Float)
Boolean
dispatchNestedPrePerformAccessibilityAction(
    action: Int,
    arguments: Bundle?
)
Boolean
dispatchNestedPreScroll(
    dx: Int,
    dy: Int,
    consumed: IntArray?,
    offsetInWindow: IntArray?
)
Boolean
dispatchNestedScroll(
    dxConsumed: Int,
    dyConsumed: Int,
    dxUnconsumed: Int,
    dyUnconsumed: Int,
    offsetInWindow: IntArray?
)
Boolean
Unit
draw(canvas: Canvas)
Unit
OnBackInvokedDispatcher?
T
<T : View> findViewById(id: Int)
T
<T : View> findViewWithTag(tag: Any)
Boolean
View
focusSearch(direction: Int)
Unit
forceHasOverlappingRendering(hasOverlappingRendering: Boolean)
Unit
Unit
generateDisplayHash(
    hashAlgorithm: String,
    bounds: Rect?,
    executor: Executor,
    callback: DisplayHashResultCallback
)
IntArray
Boolean
getClipBounds(outRect: Rect)
Bitmap
Unit
getDrawingRect(outRect: Rect)
ArrayList<View>
getFocusables(direction: Int)
Unit
Boolean
Boolean
getGlobalVisibleRect(r: Rect, globalOffset: Point)
Unit
getHitRect(outRect: Rect)
open Int
@ViewDebug.ExportedProperty(category = "layout", mapping = [@ViewDebug.IntToString(from = 0, to = "RESOLVED_DIRECTION_LTR"), @ViewDebug.IntToString(from = 1, to = "RESOLVED_DIRECTION_RTL")])
getLayoutDirection()
Boolean
Unit
Unit
Unit
ViewParent
open ViewParent
Any
getTag(key: Int)
open Int
@ViewDebug.ExportedProperty(category = "text", mapping = [@ViewDebug.IntToString(from = 0, to = "INHERIT"), @ViewDebug.IntToString(from = 1, to = "GRAVITY"), @ViewDebug.IntToString(from = 2, to = "TEXT_START"), @ViewDebug.IntToString(from = 3, to = "TEXT_END"), @ViewDebug.IntToString(from = 4, to = "CENTER"), @ViewDebug.IntToString(from = 5, to = "VIEW_START"), @ViewDebug.IntToString(from = 6, to = "VIEW_END")])
getTextAlignment()
open Int
@ViewDebug.ExportedProperty(category = "text", mapping = [@ViewDebug.IntToString(from = 0, to = "INHERIT"), @ViewDebug.IntToString(from = 1, to = "FIRST_STRONG"), @ViewDebug.IntToString(from = 2, to = "ANY_RTL"), @ViewDebug.IntToString(from = 3, to = "LTR"), @ViewDebug.IntToString(from = 4, to = "RTL"), @ViewDebug.IntToString(from = 5, to = "LOCALE"), @ViewDebug.IntToString(from = 6, to = "FIRST_STRONG_LTR"), @ViewDebug.IntToString(from = 7, to = "FIRST_STRONG_RTL")])
getTextDirection()
Unit
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Boolean
Unit
Unit
invalidate(dirty: Rect)
Unit
invalidate(l: Int, t: Int, r: Int, b: Int)
Unit
Unit
open Boolean
open Boolean
open Boolean
open Boolean
Boolean
open View
keyboardNavigationClusterSearch(currentCluster: View, direction: Int)
Unit
measure(widthMeasureSpec: Int, heightMeasureSpec: Int)
Unit
Unit
Unit
Unit
WindowInsets
Unit
Boolean
Boolean
Unit
InputConnection
Unit
onCreateViewTranslationRequest(
    supportedFormats: IntArray,
    requestsCollector: Consumer<ViewTranslationRequest>
)
Unit
onCreateVirtualViewTranslationRequests(
    virtualIds: LongArray,
    supportedFormats: IntArray,
    requestsCollector: Consumer<ViewTranslationRequest>
)
Unit
Boolean
Unit
Unit
Boolean
Unit
Unit
Unit
Boolean
Unit
Unit
Boolean
onKeyDown(keyCode: Int, event: KeyEvent)
Boolean
onKeyLongPress(keyCode: Int, event: KeyEvent)
Boolean
onKeyMultiple(keyCode: Int, repeatCount: Int, event: KeyEvent)
Boolean
onKeyPreIme(keyCode: Int, event: KeyEvent)
Boolean
onKeyShortcut(keyCode: Int, event: KeyEvent)
Boolean
onKeyUp(keyCode: Int, event: KeyEvent)
Unit
onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int)
Unit
onOverScrolled(
    scrollX: Int,
    scrollY: Int,
    clampedX: Boolean,
    clampedY: Boolean
)
Unit
Unit
Unit
Unit
Unit
Unit
ContentInfo?
Unit
onRtlPropertiesChanged(layoutDirection: Int)
Unit
onScreenStateChanged(screenState: Int)
Unit
onScrollCaptureSearch(
    localVisibleRect: Rect,
    windowOffset: Point,
    targets: Consumer<ScrollCaptureTarget>
)
Boolean
onSetAlpha(alpha: Int)
Unit
Boolean
Unit
Unit
Unit
Unit
onVisibilityChanged(changedView: View, visibility: Int)
Unit
onWindowFocusChanged(hasWindowFocus: Boolean)
Unit
Boolean
overScrollBy(
    deltaX: Int,
    deltaY: Int,
    scrollX: Int,
    scrollY: Int,
    scrollRangeX: Int,
    scrollRangeY: Int,
    maxOverScrollX: Int,
    maxOverScrollY: Int,
    isTouchEvent: Boolean
)
Boolean
performAccessibilityAction(action: Int, arguments: Bundle?)
Boolean
Boolean
Boolean
Boolean
performHapticFeedback(feedbackConstant: Int)
Boolean
Boolean
performHapticFeedback(feedbackConstant: Int, flags: Int)
Boolean
Boolean
ContentInfo?
Unit
playSoundEffect(soundConstant: Int)
Boolean
post(action: Runnable)
Boolean
postDelayed(action: Runnable, delayMillis: Long)
Unit
Unit
postInvalidate(left: Int, top: Int, right: Int, bottom: Int)
Unit
postInvalidateDelayed(delayMilliseconds: Long)
Unit
postInvalidateDelayed(
    delayMilliseconds: Long,
    left: Int,
    top: Int,
    right: Int,
    bottom: Int
)
Unit
Unit
postInvalidateOnAnimation(left: Int, top: Int, right: Int, bottom: Int)
Unit
Unit
postOnAnimationDelayed(action: Runnable, delayMillis: Long)
Unit
Unit
Boolean
Unit
Unit
Unit
Unit
Unit
open Unit

This function is deprecated. Deprecated in Java

Boolean
Boolean
requestFocus(direction: Int)
Boolean
open Unit
Unit
Unit
Boolean
Boolean
requestRectangleOnScreen(rectangle: Rect, immediate: Boolean)
Boolean
requestRectangleOnScreen(rectangle: Rect, immediate: Boolean, source: Int)
Unit
Unit
T
<T : View> requireViewById(id: Int)
Unit
Unit
Unit
saveAttributeDataForStyleable(
    context: Context,
    styleable: IntArray,
    attrs: AttributeSet?,
    t: TypedArray,
    defStyleAttr: Int,
    defStyleRes: Int
)
Unit
Unit
scheduleDrawable(who: Drawable, what: Runnable, when: Long)
Unit
Unit
Unit
setAccessibilityDataSensitive(accessibilityDataSensitive: Int)
Unit
setAllowClickWhenDisabled(clickableWhenDisabled: Boolean)
Unit
Unit
Unit
setAutofillHints(vararg autofillHints: String)
Unit
Unit
Unit
Unit
Unit
setHandwritingBoundsOffsets(
    offsetLeft: Float,
    offsetTop: Float,
    offsetRight: Float,
    offsetBottom: Float
)
Unit
setHasTransientState(hasTransientState: Boolean)
Unit
setIsCredential(isCredential: Boolean)
Unit
setIsHandwritingDelegate(isHandwritingDelegate: Boolean)
Unit
Unit
setLayerType(layerType: Int, paint: Paint?)
Unit
setLeftTopRightBottom(left: Int, top: Int, right: Int, bottom: Int)
Unit
setMeasuredDimension(measuredWidth: Int, measuredHeight: Int)
Unit
Unit
Unit
Unit
Unit
Unit
Unit
Unit
Unit
Unit
Unit
setOnReceiveContentListener(
    mimeTypes: Array<String>?,
    listener: OnReceiveContentListener?
)
Unit
Unit
Unit
Unit
setPadding(left: Int, top: Int, right: Int, bottom: Int)
Unit
setPaddingRelative(start: Int, top: Int, end: Int, bottom: Int)
Unit
Unit
setRenderEffect(renderEffect: RenderEffect?)
Unit
Unit
setScrollIndicators(indicators: Int, mask: Int)
Unit
setTag(key: Int, tag: Any)
Unit
Unit
Unit
setWillNotCacheDrawing(willNotCacheDrawing: Boolean)
Unit
setWillNotDraw(willNotDraw: Boolean)
Boolean
Boolean
ActionMode
ActionMode
Unit
Boolean
startDrag(
    data: ClipData,
    shadowBuilder: View.DragShadowBuilder,
    myLocalState: Any,
    flags: Int
)
Boolean
startDragAndDrop(
    data: ClipData,
    shadowBuilder: View.DragShadowBuilder,
    myLocalState: Any,
    flags: Int
)
Boolean
Unit
open String
Unit
Unit
Unit
Unit
Unit
Boolean
Boolean
Boolean
From android.view.ViewGroup
Unit
Unit
addExtraDataToAccessibilityNodeInfo(
    info: AccessibilityNodeInfo,
    extraDataKey: String,
    arguments: Bundle?
)
Unit
addFocusables(views: ArrayList<View>, direction: Int, focusableMode: Int)
Unit
addKeyboardNavigationClusters(
    views: MutableCollection<View>,
    direction: Int
)
Boolean
Unit
Boolean
addViewInLayout(child: View, index: Int, params: ViewGroup.LayoutParams)
Boolean
addViewInLayout(
    child: View,
    index: Int,
    params: ViewGroup.LayoutParams,
    preventRequestLayout: Boolean
)
Unit
attachLayoutAnimationParameters(
    child: View,
    params: ViewGroup.LayoutParams,
    index: Int,
    count: Int
)
Unit
attachViewToParent(child: View, index: Int, params: ViewGroup.LayoutParams)
Unit
Boolean
Boolean
Unit
Unit
childHasTransientStateChanged(
    child: View,
    childHasTransientState: Boolean
)
Unit
Unit
Unit
Unit
Unit
debug(depth: Int)
Unit
Unit
Unit
Unit
detachViewsFromParent(start: Int, count: Int)
WindowInsets
Boolean
Unit
Unit
dispatchCreateViewTranslationRequest(
    viewIds: MutableMap<AutofillIdLongArray>,
    supportedFormats: IntArray,
    capability: TranslationCapability,
    requests: MutableList<ViewTranslationRequest>
)
Unit
Boolean
Unit
Unit
Unit
Unit
Boolean
Boolean
Boolean
Boolean
Unit
Unit
Unit
Unit
Unit
Unit
dispatchScrollCaptureSearch(
    localVisibleRect: Rect,
    windowOffset: Point,
    targets: Consumer<ScrollCaptureTarget>
)
Unit
Unit
Unit
Unit
Unit
Unit
Boolean
Boolean
Boolean
dispatchUnhandledMove(focused: View, direction: Int)
Unit
dispatchVisibilityChanged(changedView: View, visibility: Int)
Unit
Unit
Unit
WindowInsets
WindowInsetsAnimation.Bounds
Unit
Unit
Boolean
drawChild(canvas: Canvas, child: View, drawingTime: Long)
Unit
Unit
View
OnBackInvokedDispatcher?
Unit
findViewsWithText(
    outViews: ArrayList<View>,
    text: CharSequence,
    flags: Int
)
View
focusSearch(focused: View, direction: Int)
Unit
Boolean
ViewGroup.LayoutParams
ViewGroup.LayoutParams
ViewGroup.LayoutParams
View
getChildAt(index: Int)
Int
getChildDrawingOrder(drawingPosition: Int)
Int
getChildDrawingOrder(childCount: Int, drawingPosition: Int)
Boolean
Boolean
getChildVisibleRect(child: View, r: Rect, offset: Point)
Boolean
Boolean
Int
Unit
invalidateChild(child: View, dirty: Rect)
ViewParent
invalidateChildInParent(location: IntArray, dirty: Rect)
Unit
Unit
layout(l: Int, t: Int, r: Int, b: Int)
Unit
measureChild(
    child: View,
    parentWidthMeasureSpec: Int,
    parentHeightMeasureSpec: Int
)
Unit
measureChildWithMargins(
    child: View,
    parentWidthMeasureSpec: Int,
    widthUsed: Int,
    parentHeightMeasureSpec: Int,
    heightUsed: Int
)
Unit
measureChildren(widthMeasureSpec: Int, heightMeasureSpec: Int)
Unit
notifySubtreeAccessibilityStateChanged(
    child: View,
    source: View,
    changeType: Int
)
Unit
Unit
IntArray
Unit
onDescendantInvalidated(child: View, target: View)
Boolean
Boolean
Boolean
onNestedFling(
    target: View,
    velocityX: Float,
    velocityY: Float,
    consumed: Boolean
)
Boolean
onNestedPreFling(target: View, velocityX: Float, velocityY: Float)
Boolean
onNestedPrePerformAccessibilityAction(
    target: View,
    action: Int,
    args: Bundle?
)
Unit
onNestedPreScroll(target: View, dx: Int, dy: Int, consumed: IntArray)
Unit
onNestedScroll(
    target: View,
    dxConsumed: Int,
    dyConsumed: Int,
    dxUnconsumed: Int,
    dyUnconsumed: Int
)
Unit
onNestedScrollAccepted(child: View, target: View, axes: Int)
Boolean
onRequestFocusInDescendants(direction: Int, previouslyFocusedRect: Rect)
Boolean
PointerIcon
onResolvePointerIcon(event: MotionEvent, pointerIndex: Int)
Boolean
onStartNestedScroll(child: View, target: View, nestedScrollAxes: Int)
Unit
Unit
onViewAdded(child: View)
Unit
Unit
propagateRequestedFrameRate(frameRate: Float, forceOverride: Boolean)
Unit
Unit
Unit
Unit
removeDetachedView(child: View, animate: Boolean)
Unit
Unit
removeViewAt(index: Int)
Unit
Unit
removeViews(start: Int, count: Int)
Unit
removeViewsInLayout(start: Int, count: Int)
Unit
requestChildFocus(child: View, focused: View)
Boolean
requestChildRectangleOnScreen(
    child: View,
    rectangle: Rect,
    immediate: Boolean
)
Unit
Boolean
requestFocus(direction: Int, previouslyFocusedRect: Rect)
Boolean
Unit
Boolean
Unit
Unit
Unit
Unit
Unit
Unit
Boolean
Boolean
Boolean
showContextMenuForChild(originalView: View, x: Float, y: Float)
ActionMode
startActionModeForChild(
    originalView: View,
    callback: ActionMode.Callback
)
ActionMode
startActionModeForChild(
    originalView: View,
    callback: ActionMode.Callback,
    type: Int
)
Unit
Unit
Unit
Unit
From android.view.ViewParent
Boolean
requestChildRectangleOnScreen(
    child: View,
    rectangle: Rect,
    immediate: Boolean,
    source: Int
)

Inherited properties

From android.view.View
open View.AccessibilityDelegate
open Int
open AccessibilityNodeProvider
open CharSequence?
open Int
open Int
open String?
open String?
open Float
open Animation
open Matrix?
open IBinder
open MutableMap<IntInt>
open Array<String>?
AutofillId
open Int
open AutofillValue?
open Drawable
open BlendMode?
open ColorStateList?
open PorterDuff.Mode?
open Int
Int
open Float
open Int
open Float
open Rect
Boolean
ContentCaptureSession?
open CharSequence
Int
Context
open ContextMenu.ContextMenuInfo
Boolean
open Display
IntArray
open Bitmap
open Int
open Int
open Long
open Float
open Int
open Boolean
open Boolean
open Int
open Drawable
open Int
open BlendMode?
open ColorStateList?
open PorterDuff.Mode?
open Float
open Handler
open Float
open Float
open Float
open Float
open Int
open Runnable?
Boolean
Int
open Int
open Int
open Drawable?
open Drawable?
open Int
open Int
open Int
open Int
open Boolean
open Boolean
open Boolean
open Boolean
open Boolean
open Boolean
open Boolean
Boolean
open Boolean
open Boolean
open Boolean
open Boolean
open Boolean
open Boolean
Boolean
Boolean
open Boolean
Boolean
open Boolean
open Boolean
open Boolean
open Boolean
open Boolean
open Boolean
open Boolean
open Boolean
Boolean
Boolean
open Boolean
open Boolean
open Boolean
Boolean
open Boolean
open Boolean
open Boolean
open Boolean
open Boolean
open Boolean
open Boolean
open Boolean
open Boolean
Boolean
open Boolean
open Boolean
open Boolean
open Boolean
open Boolean
open Boolean
open Boolean
Boolean
open Boolean
open Boolean
Boolean
open Boolean
open Boolean
open Boolean
open Boolean
open Boolean
open KeyEvent.DispatcherState
open Int
open Int
open Int
open ViewGroup.LayoutParams
Int
open Float
open Int
open Matrix
Int
Int
Int
Int
Int
open Int
open Int
open Int
open Int
open Int
open Int
open Int
open Int
open View.OnFocusChangeListener
open Int
open ViewOutlineProvider
open Int
open Int
open Int
open Int
open Int
open Int
open Int
open Int
final ViewParent
open ViewParent
OutcomeReceiver<GetCredentialResponseGetCredentialException>?
GetCredentialRequest?
open Float
open Float
open PointerIcon
MutableList<Rect>
open Array<String>?
open Float
open Resources
Boolean
Int
open Float
open Int
open AttachedSurfaceControl?
open View
open WindowInsets
open Float
open Float
open Float
open Float
open Float
open Int
open Int
open Int
open Int
open Int
open Int
Int
Int
open Int
open Int
CharSequence?
open StateListAnimator
open Int
open Int
open CharSequence?
open MutableList<Rect>
open Int
open Any
open Int
open Int
open CharSequence?
Int
open Float
open Int
open TouchDelegate
open ArrayList<View>
open Float
open String
open Float
open Float
open Float
open Long
open Int
open Int
open Drawable?
open Drawable?
open Int
open ViewTranslationResponse?
open ViewTreeObserver
open Int
Int
open Int
open WindowId
open WindowInsetsController?
open Int
open IBinder
open Int
open Float
open Float
open Float
From android.view.ViewGroup

Constants

GESTURE_STATE_IDLE

const val GESTURE_STATE_IDLE = 0: Int

The PdfView is not currently being affected by an outside input, e.g. user touch

GESTURE_STATE_INTERACTING

const val GESTURE_STATE_INTERACTING = 1: Int

The PdfView is currently being affected by an outside input, e.g. user touch

GESTURE_STATE_SETTLING

const val GESTURE_STATE_SETTLING = 2: Int

The PdfView is currently animating to a final position while not under outside control, e.g. settling on a final position following a fling gesture.

VERTICAL_ALIGNMENT_CENTER

const val VERTICAL_ALIGNMENT_CENTER = 1: Int

Vertically aligns the page to the center of the PdfView.

This alignment is used when the page is scaled to fit the view's width, and the resulting page height is less than the view's height. The top of the page will be positioned at the center of the PdfView. If the scaled page height is greater than the height of PdfView, the top of the first page is always at the top of the view by default, and this alignment will have no effect.

VERTICAL_ALIGNMENT_TOP

const val VERTICAL_ALIGNMENT_TOP = 0: Int

Vertically aligns the page to the top of the PdfView.

This alignment is used when the page is scaled to fit the view's width, and the resulting page height is less than the view's height. The top of the page will be positioned at the top of the PdfView. If the scaled page height is greater than the height of PdfView, the top of the first page is always at the top of the view by default, and this alignment will have no effect.

Public constructors

PdfView

Added in 1.0.0-alpha19
PdfView(context: Context, attrs: AttributeSet? = null, defStyle: Int = 0)

Public functions

addOnFirstContentLoadListener

Added in 1.0.0-alpha19
fun addOnFirstContentLoadListener(
    listener: PdfView.OnFirstContentLoadListener
): Unit

Adds the specified listener to the list of listeners that will be notified on first content load.

Parameters
listener: PdfView.OnFirstContentLoadListener

The listener to add.

addOnFormWidgetInfoUpdatedListener

Added in 1.0.0-alpha19
fun addOnFormWidgetInfoUpdatedListener(
    listener: PdfView.OnFormWidgetInfoUpdatedListener
): Unit

Adds the specified listener to the list of listeners that is notified when any form widget is updated due to an edit action on a widget e.g. click on a radio button.

Parameters
listener: PdfView.OnFormWidgetInfoUpdatedListener

The listener to add

addOnGestureStateChangedListener

Added in 1.0.0-alpha19
fun addOnGestureStateChangedListener(
    listener: PdfView.OnGestureStateChangedListener
): Unit

Adds the specified listener to the list of listeners that will be notified of changes in state with respect to this PdfView being affected by an external input, e.g. user touch.

Parameters
listener: PdfView.OnGestureStateChangedListener

listener to notify when interaction state change events occur

addOnSelectionChangedListener

Added in 1.0.0-alpha19
fun addOnSelectionChangedListener(
    listener: PdfView.OnSelectionChangedListener
): Unit

Adds the specified listener to the list of listeners that will be notified of selection change events.

Parameters
listener: PdfView.OnSelectionChangedListener

listener to notify when selection change events occur

addOnViewportChangedListener

Added in 1.0.0-alpha19
fun addOnViewportChangedListener(
    listener: PdfView.OnViewportChangedListener
): Unit

Adds the specified listener to the list of listeners that will be notified of viewport change events.

Parameters
listener: PdfView.OnViewportChangedListener

listener to add

addSelectionMenuItemPreparer

Added in 1.0.0-alpha19
fun addSelectionMenuItemPreparer(
    selectionMenuItemPreparer: PdfView.SelectionMenuItemPreparer
): Unit

Adds the specified listener to the chain of SelectionMenuItemPreparer. The listener will be invoked in the order they've been added.

Parameters
selectionMenuItemPreparer: PdfView.SelectionMenuItemPreparer

: The SelectionMenuItemPreparer to add to the chain.

addView

open fun addView(child: View?): Unit

addView

open fun addView(child: View?, index: Int): Unit

addView

open fun addView(child: View?, params: ViewGroup.LayoutParams?): Unit

addView

open fun addView(child: View?, index: Int, params: ViewGroup.LayoutParams?): Unit

addView

open fun addView(child: View?, width: Int, height: Int): Unit

autofill

open fun autofill(values: SparseArray<AutofillValue>): Unit

clearCurrentSelection

Added in 1.0.0-alpha19
fun clearCurrentSelection(): Unit

Clears the current selection, if one exists. No-op if there is no current Selection

computeScroll

open fun computeScroll(): Unit

dispatchKeyEvent

open fun dispatchKeyEvent(event: KeyEvent?): Boolean

Prioritizes standard keyboard shortcuts over accessibility-specific handling of certain keys. This ensures a consistent experience for all users, where shortcuts like D-pad scrolling work irrespective of whether accessibility is enabled or not, as both externalInputManager and pdfViewAccessibilityManager are capable of handling certain key events.

onGenericMotionEvent

open fun onGenericMotionEvent(event: MotionEvent?): Boolean

onProvideAutofillVirtualStructure

open fun onProvideAutofillVirtualStructure(structure: ViewStructure?, flags: Int): Unit

onTouchEvent

open fun onTouchEvent(event: MotionEvent?): Boolean

pdfToViewPoint

Added in 1.0.0-alpha19
fun pdfToViewPoint(pdfPoint: PdfPoint): PointF?

Returns the View coordinate location of pdfPoint, or null if that PDF content has not been laid out yet.

removeOnFirstContentLoadListener

Added in 1.0.0-alpha19
fun removeOnFirstContentLoadListener(
    listener: PdfView.OnFirstContentLoadListener
): Unit

Removes the specified listener from the list of listeners that will be notified on first content load.

Parameters
listener: PdfView.OnFirstContentLoadListener

The listener to remove.

removeOnFormWidgetInfoUpdatedListener

Added in 1.0.0-alpha19
fun removeOnFormWidgetInfoUpdatedListener(
    listener: PdfView.OnFormWidgetInfoUpdatedListener
): Unit

Removes the specified listener from the list of listeners that is notified when any form widget is updated due to an edit action on the widget e.g. click on a radio button.

Parameters
listener: PdfView.OnFormWidgetInfoUpdatedListener

The listener to remove

removeOnGestureStateChangedListener

Added in 1.0.0-alpha19
fun removeOnGestureStateChangedListener(
    listener: PdfView.OnGestureStateChangedListener
): Unit

Removes the specified listener from the list of listeners that will be notified of changes in state with respect to this PdfView being affected by an external input, e.g. user touch.

Parameters
listener: PdfView.OnGestureStateChangedListener

listener to remove

removeOnSelectionChangedListener

Added in 1.0.0-alpha19
fun removeOnSelectionChangedListener(
    listener: PdfView.OnSelectionChangedListener
): Unit

Removes the specified listener from the list of listeners that will be notified of selection change events.

Parameters
listener: PdfView.OnSelectionChangedListener

listener to remove

removeOnViewportChangedListener

Added in 1.0.0-alpha19
fun removeOnViewportChangedListener(
    listener: PdfView.OnViewportChangedListener
): Unit

Removes the specified listener from the list of listeners that will be notified of viewport change events.

Parameters
listener: PdfView.OnViewportChangedListener

listener to remove

removeSelectionMenuItemPreparer

Added in 1.0.0-alpha19
fun removeSelectionMenuItemPreparer(
    selectionMenuItemPreparer: PdfView.SelectionMenuItemPreparer
): Unit

Removes the specified listener from the chain of SelectionMenuItemPreparer.

Parameters
selectionMenuItemPreparer: PdfView.SelectionMenuItemPreparer

: The SelectionMenuItemPreparer to remove from the chain.

scrollBy

open fun scrollBy(x: Int, y: Int): Unit

scrollTo

open fun scrollTo(x: Int, y: Int): Unit

scrollToPage

Added in 1.0.0-alpha19
fun scrollToPage(pageNum: Int): Unit

Scrolls to the 0-indexed pageNum, optionally animating the scroll

This View cannot scroll to a page until it knows its dimensions. If pageNum is distant from the currently-visible page in a large PDF, there may be some delay while dimensions are being loaded from the PDF.

scrollToPosition

Added in 1.0.0-alpha19
fun scrollToPosition(position: PdfPoint): Unit

Scrolls to position, aligns vertically to center, optionally animating the scroll

This View cannot scroll to a page until it knows its dimensions. If position is distant from the currently-visible page in a large PDF, there may be some delay while dimensions are being loaded from the PDF.

setHighlights

Added in 1.0.0-alpha19
fun setHighlights(highlights: List<Highlight>): Unit

Applies a set of Highlight to be drawn over this PDF. Each Highlight may be a different color. This overrides any previous highlights, there is no merging of new and previous values. highlights are defensively copied and the list or its contents may be modified after providing it here.

setLinkClickListener

Added in 1.0.0-alpha19
fun setLinkClickListener(listener: PdfView.LinkClickListener?): Unit

Registers listener as the callback to be invoked when an external link in the PDF is clicked. Supply null to clear any current listener.

setOcrProvider

Added in 1.0.0-alpha19
fun setOcrProvider(ocrProvider: OcrProvider?): Unit

Sets the OcrProvider used for recognizing text in image-based PDF content.

When set, it enables text selection within images by delegating OCR processing to the provided engine.

Parameters
ocrProvider: OcrProvider?

the OcrProvider to use for text recognition

viewToPdfPoint

Added in 1.0.0-alpha19
fun viewToPdfPoint(viewPoint: PointF): PdfPoint?

Returns the PdfPoint corresponding to viewPoint in View coordinates, or null if no PDF content has been laid out at viewPoint

viewToPdfPoint

Added in 1.0.0-alpha19
fun viewToPdfPoint(x: Float, y: Float): PdfPoint?

Returns the PdfPoint corresponding to (x, y)in View coordinates, or null if no PDF content has been laid out at that point.

Protected functions

computeHorizontalScrollRange

protected open fun computeHorizontalScrollRange(): Int

computeVerticalScrollRange

protected open fun computeVerticalScrollRange(): Int

dispatchHoverEvent

protected open fun dispatchHoverEvent(event: MotionEvent?): Boolean

onAttachedToWindow

protected open fun onAttachedToWindow(): Unit

onConfigurationChanged

protected open fun onConfigurationChanged(newConfig: Configuration?): Unit

onDetachedFromWindow

protected open fun onDetachedFromWindow(): Unit

onDraw

protected open fun onDraw(canvas: Canvas): Unit

onFocusChanged

protected open fun onFocusChanged(
    gainFocus: Boolean,
    direction: Int,
    previouslyFocusedRect: Rect?
): Unit

onLayout

protected open fun onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int): Unit

onRestoreInstanceState

protected open fun onRestoreInstanceState(state: Parcelable?): Unit

onSaveInstanceState

protected open fun onSaveInstanceState(): Parcelable?

onScrollChanged

protected open fun onScrollChanged(l: Int, t: Int, oldl: Int, oldt: Int): Unit

onSizeChanged

protected open fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int): Unit

onWindowVisibilityChanged

protected open fun onWindowVisibilityChanged(visibility: Int): Unit

Public properties

currentSelection

Added in 1.0.0-alpha19
val currentSelectionSelection?

The currently selected PDF content, as Selection, or 'null' if no content is currently selected.

fastScrollPageIndicatorBackgroundDrawable

Added in 1.0.0-alpha19
var fastScrollPageIndicatorBackgroundDrawableDrawable

fastScrollPageIndicatorMarginEnd

Added in 1.0.0-alpha19
var fastScrollPageIndicatorMarginEndInt

fastScrollVerticalThumbDrawable

Added in 1.0.0-alpha19
var fastScrollVerticalThumbDrawableDrawable

fastScrollVerticalThumbMarginEnd

Added in 1.0.0-alpha19
var fastScrollVerticalThumbMarginEndInt

firstVisiblePage

Added in 1.0.0-alpha19
val firstVisiblePageInt

The first page in the viewport, including partially-visible pages. 0-indexed.

gestureState

Added in 1.0.0-alpha19
val gestureStateInt

The current state of the PDF view with respect to external inputs, e.g. user touch. Returns one of GESTURE_STATE_IDLE, GESTURE_STATE_INTERACTING, or GESTURE_STATE_SETTLING

horizontalPageSpacing

Added in 1.0.0-alpha19
var horizontalPageSpacing: @IntRange(from = 0) Int

The spacing between two horizontally adjacent pages in pixels.

Note: This value is only relevant when pagesPerRow is set to 2.

isFormFillingEnabled

Added in 1.0.0-alpha19
var isFormFillingEnabledBoolean

Enables / Disables the form-filling feature surface.

isImageSelectionEnabled

Added in 1.0.0-alpha19
var isImageSelectionEnabledBoolean

Enable or disable the image-selection feature surface.

Important: Enabling this feature (setting to true) requires the device to run Android S+ (API Level 31 or above) with SDK Extension version 19 or higher. This requirement is due to dependencies on platform APIs introduced in that sdk-extension.

maxZoom

Added in 1.0.0-alpha19
var maxZoomFloat

The maximum scaling factor that can be applied to this View using the zoom property. This value is a multiplier relative to the content's natural size, where '1.0' represents 100% (1x) zoom (similarly '2.5' represents 250% (2.5x) zoom).

The value is automatically clamped to stay within the defined range.

minZoom

Added in 1.0.0-alpha19
var minZoomFloat

The minimum scaling factor that can be applied to this View using the zoom property. This value is a multiplier relative to the content's natural size, where '1.0' represents 100% (1x) zoom (similarly '0.5' represents 50% (0.5x) zoom).

The value is automatically clamped to stay within the defined range.

pagesPerRow

Added in 1.0.0-alpha19
var pagesPerRow: @IntRange(from = 1, to = 2) Int

The number of pages displayed side-by-side in a single row.

This property controls the layout mode and can be set to either 1 or 2.

  • 1: Displays one page per row (standard display).

  • 2: Displays two pages per row (like an open book).

Throws
IllegalArgumentException

if the value is not either 1 or 2.

pdfDocument

Added in 1.0.0-alpha19
var pdfDocumentPdfDocument?

Supply a PdfDocument to process the PDF content for rendering

verticalAlignment

Added in 1.0.0-alpha19
var verticalAlignmentInt

Controls the vertical alignment of a page within the PdfView.

This attribute aligns a page within the view when the page's height is smaller than the view's height. In this state, scrolling and panning are disabled as the entire page is visible. However, zooming in will re-enable scrolling and panning, aligning page to the top.

verticalPageSpacing

Added in 1.0.0-alpha19
var verticalPageSpacing: @IntRange(from = 0) Int

The spacing between vertically adjacent pages in pixels.

visiblePagesCount

Added in 1.0.0-alpha19
val visiblePagesCountInt

The number of pages visible in the viewport, including partially visible pages

zoom

Added in 1.0.0-alpha19
var zoomFloat

The zoom level of this view, as a factor of the content's natural size with when 1 pixel is equal to 1 PDF point. Will always be clamped within (minZoom, maxZoom)