public class PdfView extends View


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.

Summary

Nested types

public interface PdfView.LinkClickListener

Listener interface for handling clicks on links in 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

Constants

static final int

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

static final int

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

static final 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.

Public constructors

PdfView(@NonNull Context context, AttributeSet attrs, int defStyle)

Public methods

final void

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.

final void

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

final void

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

final void

Clears the current selection, if one exists.

void
boolean

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

final Selection

The currently selected PDF content, as Selection

final @NonNull Drawable
final int
final @NonNull Drawable
final int
final int

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

final int

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

final float

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

final float

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

final PdfDocument

Supply a PdfDocument to process the PDF content for rendering

final int

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

final 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.

boolean
boolean
final PointF

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

final void

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.

final void

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

final void

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

void
scrollBy(int x, int y)
void
scrollTo(int x, int y)
final void
scrollToPage(int pageNum)

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

final void

Scrolls to position, optionally animating the scroll

final void
setFastScrollPageIndicatorBackgroundDrawable(
    @NonNull Drawable fastScrollPageIndicatorBackgroundDrawable
)
final void
setFastScrollPageIndicatorMarginEnd(
    int fastScrollPageIndicatorMarginEnd
)
final void
setFastScrollVerticalThumbDrawable(
    @NonNull Drawable fastScrollVerticalThumbDrawable
)
final void
setFastScrollVerticalThumbMarginEnd(
    int fastScrollVerticalThumbMarginEnd
)
final void

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

final void

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

final void
setMaxZoom(float maxZoom)

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

final void
setMinZoom(float minZoom)

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

final void

Supply a PdfDocument to process the PDF content for rendering

final void
setZoom(float zoom)

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.

final PdfPoint

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

final PdfPoint
viewToPdfPoint(float x, float y)

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

Protected methods

int
int
boolean
void
void
void
void
void
onFocusChanged(
    boolean gainFocus,
    int direction,
    Rect previouslyFocusedRect
)
void
onLayout(boolean changed, int left, int top, int right, int bottom)
void
Parcelable
void
onScrollChanged(int l, int t, int oldl, int oldt)
void
onSizeChanged(int w, int h, int oldw, int oldh)
void
onWindowVisibilityChanged(int visibility)

Inherited methods

From android.view.View
void
void
void
void
addFocusables(@NonNull ArrayList<@NonNull View> p0, int p1, int p2)
void
void
void
void
void
@NonNull ViewPropertyAnimator
void

This method is deprecated. Deprecated in Java

void
void
boolean
boolean
boolean
awakenScrollBars(int p0, boolean p1)
void
void

This method is deprecated. Deprecated in Java

void
buildDrawingCache(boolean p0)

This method is deprecated. Deprecated in Java

void
boolean
boolean
boolean
boolean
boolean
boolean
final void
void
final void
boolean
void
void
void
void
int
int
@NonNull WindowInsets
int
int
@NonNull AccessibilityNodeInfo
void
void

This method is deprecated. Deprecated in Java

@NonNull WindowInsets
boolean
void
void
void
boolean
void
void
dispatchDrawableHotspotChanged(float p0, float p1)
void
boolean
boolean
boolean
boolean
boolean
boolean
dispatchNestedFling(float p0, float p1, boolean p2)
boolean
dispatchNestedPreFling(float p0, float p1)
boolean
boolean
dispatchNestedPreScroll(
    int p0,
    int p1,
    @Nullable int[] p2,
    @Nullable int[] p3
)
boolean
dispatchNestedScroll(int p0, int p1, int p2, int p3, @Nullable int[] p4)
void
boolean
void
void
void
void
void
void
void
dispatchSetPressed(boolean p0)
void
dispatchSetSelected(boolean p0)
void
void

This method is deprecated. Deprecated in Java

boolean
boolean
boolean
void
void
void
void
@NonNull WindowInsets
@NonNull WindowInsetsAnimation.Bounds
void

This method is deprecated. Deprecated in Java

void
void
void
drawableHotspotChanged(float p0, float p1)
void
@NonNull View
final @Nullable OnBackInvokedDispatcher
final @NonNull T
<T extends View> findViewById(int p0)
final @NonNull T
<T extends View> findViewWithTag(@NonNull Object p0)
void
findViewsWithText(
    @NonNull ArrayList<@NonNull View> p0,
    @NonNull CharSequence p1,
    int p2
)
boolean

This method is deprecated. Deprecated in Java

@NonNull View
focusSearch(int p0)
void
void
boolean
void
generateDisplayHash(
    @NonNull String p0,
    @Nullable Rect p1,
    @NonNull Executor p2,
    @NonNull DisplayHashResultCallback p3
)
@NonNull CharSequence
@NonNull View.AccessibilityDelegate
int
@NonNull AccessibilityNodeProvider
@Nullable CharSequence
int
int
@Nullable String
@Nullable String
float
@ViewDebug.ExportedProperty(category = "drawing")
getAlpha()
@NonNull Animation
@Nullable Matrix
@NonNull IBinder
@NonNull int[]
@NonNull Map<@NonNull Integer, @NonNull Integer>
@Nullable String[]
final @NonNull AutofillId
int
@Nullable AutofillValue
@NonNull Drawable
@Nullable BlendMode
@Nullable ColorStateList
@Nullable PorterDuff.Mode
int
@ViewDebug.ExportedProperty(category = "layout")
getBaseline()
final int
float
int
float
@NonNull Rect
boolean
final boolean
final @Nullable ContentCaptureSession
@NonNull CharSequence
@ViewDebug.ExportedProperty(category = "accessibility")
getContentDescription()
final int
final @NonNull Context
@NonNull ContextMenu.ContextMenuInfo
final boolean
@NonNull Display
final @NonNull int[]
@NonNull Bitmap

This method is deprecated. Deprecated in Java

@NonNull Bitmap
getDrawingCache(boolean p0)

This method is deprecated. Deprecated in Java

int

This method is deprecated. Deprecated in Java

int

This method is deprecated. Deprecated in Java

void
long
float
@ViewDebug.ExportedProperty(category = "drawing")
getElevation()
int
boolean
boolean
int
@ViewDebug.ExportedProperty(mapping = [@ViewDebug.IntToString(from = 0, to = "NOT_FOCUSABLE"), @ViewDebug.IntToString(from = 1, to = "FOCUSABLE"), @ViewDebug.IntToString(from = 16, to = "FOCUSABLE_AUTO")], category = "focus")
getFocusable()
@NonNull ArrayList<@NonNull View>
getFocusables(int p0)
void
@NonNull Drawable
int
@Nullable BlendMode
@Nullable ColorStateList
@Nullable PorterDuff.Mode
float
final boolean
boolean
@NonNull Handler
float
float
float
float
int
@Nullable Runnable
final boolean
final int
@ViewDebug.ExportedProperty(category = "layout")
getHeight()
void
int
int
@Nullable Drawable
@Nullable Drawable
int
int
@ViewDebug.ExportedProperty(category = "accessibility", mapping = [@ViewDebug.IntToString(from = 0, to = "auto"), @ViewDebug.IntToString(from = 1, to = "yes"), @ViewDebug.IntToString(from = 2, to = "no"), @ViewDebug.IntToString(from = 4, to = "noHideDescendants")])
getImportantForAccessibility()
int
@ViewDebug.ExportedProperty(mapping = [@ViewDebug.IntToString(from = 0, to = "auto"), @ViewDebug.IntToString(from = 1, to = "yes"), @ViewDebug.IntToString(from = 2, to = "no"), @ViewDebug.IntToString(from = 4, to = "yesExcludeDescendants"), @ViewDebug.IntToString(from = 8, to = "noExcludeDescendants")])
getImportantForAutofill()
int
@ViewDebug.ExportedProperty(mapping = [@ViewDebug.IntToString(from = 0, to = "auto"), @ViewDebug.IntToString(from = 1, to = "yes"), @ViewDebug.IntToString(from = 2, to = "no"), @ViewDebug.IntToString(from = 4, to = "yesExcludeDescendants"), @ViewDebug.IntToString(from = 8, to = "noExcludeDescendants")])
getImportantForContentCapture()
boolean
@NonNull KeyEvent.DispatcherState
int
@ViewDebug.ExportedProperty(category = "accessibility")
getLabelFor()
int
@ViewDebug.ExportedProperty(category = "drawing", mapping = [@ViewDebug.IntToString(from = 0, to = "NONE"), @ViewDebug.IntToString(from = 1, to = "SOFTWARE"), @ViewDebug.IntToString(from = 2, to = "HARDWARE")])
getLayerType()
int
@ViewDebug.ExportedProperty(category = "layout", mapping = [@ViewDebug.IntToString(from = 0, to = "RESOLVED_DIRECTION_LTR"), @ViewDebug.IntToString(from = 1, to = "RESOLVED_DIRECTION_RTL")])
getLayoutDirection()
@NonNull ViewGroup.LayoutParams
@ViewDebug.ExportedProperty(deepExport = true, prefix = "layout_")
getLayoutParams()
final int
float
int
final boolean
void
void
void
@NonNull Matrix
final int
final int
@ViewDebug.ExportedProperty(category = "measurement", flagMapping = [@ViewDebug.FlagToString(mask = -16777216, equals = 16777216, name = "MEASURED_STATE_TOO_SMALL")])
getMeasuredHeightAndState()
final int
final int
final int
@ViewDebug.ExportedProperty(category = "measurement", flagMapping = [@ViewDebug.FlagToString(mask = -16777216, equals = 16777216, name = "MEASURED_STATE_TOO_SMALL")])
getMeasuredWidthAndState()
int
int
int
int
int
int
int
int
@NonNull View.OnFocusChangeListener
int
@NonNull ViewOutlineProvider
int
int
@NonNull ViewOverlay
int
int
int
int
int
int
final @NonNull ViewParent
@NonNull ViewParent
final @Nullable OutcomeReceiver<@NonNull GetCredentialResponse, @NonNull GetCredentialException>
final @Nullable GetCredentialRequest
float
@ViewDebug.ExportedProperty(category = "drawing")
getPivotX()
float
@ViewDebug.ExportedProperty(category = "drawing")
getPivotY()
@NonNull PointerIcon
final @NonNull List<@NonNull Rect>
@Nullable String[]
float
@NonNull Resources
final boolean
final int
float
int
@Nullable AttachedSurfaceControl
@NonNull View
@NonNull WindowInsets
float
@ViewDebug.ExportedProperty(category = "drawing")
getRotation()
float
@ViewDebug.ExportedProperty(category = "drawing")
getRotationX()
float
@ViewDebug.ExportedProperty(category = "drawing")
getRotationY()
float
@ViewDebug.ExportedProperty(category = "drawing")
getScaleX()
float
@ViewDebug.ExportedProperty(category = "drawing")
getScaleY()
int
int
int
int
@ViewDebug.ExportedProperty(mapping = [@ViewDebug.IntToString(from = 0, to = "INSIDE_OVERLAY"), @ViewDebug.IntToString(from = 16777216, to = "INSIDE_INSET"), @ViewDebug.IntToString(from = 33554432, to = "OUTSIDE_OVERLAY"), @ViewDebug.IntToString(from = 50331648, to = "OUTSIDE_INSET")])
getScrollBarStyle()
int
int
final int
final int
int
@ViewDebug.ExportedProperty(category = "drawing")
getSolidColor()
int
final @Nullable CharSequence
@ViewDebug.ExportedProperty(category = "accessibility")
getStateDescription()
@NonNull StateListAnimator
int
int
@Nullable CharSequence
@NonNull List<@NonNull Rect>
int

This method is deprecated. Deprecated in Java

@NonNull Object
@NonNull Object
getTag(int p0)
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()
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()
@Nullable CharSequence
final int
float
int
@NonNull TouchDelegate
@NonNull ArrayList<@NonNull View>
float
@NonNull String
float
float
float
long
int
int
@Nullable Drawable
@Nullable Drawable
int
@Nullable ViewTranslationResponse
@NonNull ViewTreeObserver
int
@ViewDebug.ExportedProperty(mapping = [@ViewDebug.IntToString(from = 0, to = "VISIBLE"), @ViewDebug.IntToString(from = 4, to = "INVISIBLE"), @ViewDebug.IntToString(from = 8, to = "GONE")])
getVisibility()
final int
@ViewDebug.ExportedProperty(category = "layout")
getWidth()
int
@NonNull WindowId
@Nullable WindowInsetsController
int

This method is deprecated. Deprecated in Java

@NonNull IBinder
int
void
float
@ViewDebug.ExportedProperty(category = "drawing")
getX()
float
@ViewDebug.ExportedProperty(category = "drawing")
getY()
float
@ViewDebug.ExportedProperty(category = "drawing")
getZ()
boolean
boolean
@ViewDebug.ExportedProperty(category = "focus")
hasFocus()
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
void
void

This method is deprecated. Deprecated in Java

void
invalidate(int p0, int p1, int p2, int p3)

This method is deprecated. Deprecated in Java

void
void
boolean
boolean
boolean
boolean
boolean
boolean
boolean
final boolean
boolean
boolean
boolean
boolean

This method is deprecated. Deprecated in Java

boolean
boolean
final boolean
@ViewDebug.ExportedProperty(category = "focus")
isFocusable()
final boolean
boolean
@ViewDebug.ExportedProperty(category = "focus")
isFocused()
final boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
final boolean
final boolean
boolean
boolean
boolean
final boolean
boolean
boolean
boolean
boolean
boolean
boolean
@ViewDebug.ExportedProperty(category = "drawing")
isOpaque()
boolean
boolean
boolean
final boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
final boolean
boolean
boolean
final boolean
boolean
boolean
boolean
boolean
boolean
void
@NonNull View
void
layout(int p0, int p1, int p2, int p3)
final void
measure(int p0, int p1)
void
void
void
void
@NonNull WindowInsets
void
boolean
boolean
void
@NonNull int[]
@NonNull InputConnection
void
void
void
onDisplayHint(int p0)
boolean
void
final void
boolean
void
void
void
onHoverChanged(boolean p0)
boolean
void
void
boolean
onKeyDown(int p0, @NonNull KeyEvent p1)
boolean
boolean
onKeyMultiple(int p0, int p1, @NonNull KeyEvent p2)
boolean
onKeyPreIme(int p0, @NonNull KeyEvent p1)
boolean
boolean
onKeyUp(int p0, @NonNull KeyEvent p1)
void
onMeasure(int p0, int p1)
void
onOverScrolled(int p0, int p1, boolean p2, boolean p3)
void
void
void
void
void
void
void
@Nullable ContentInfo
@NonNull PointerIcon
void
void
void
boolean
onSetAlpha(int p0)
void
boolean
void
void
void
void
void
void

This method is deprecated. Deprecated in Java

boolean
overScrollBy(
    int p0,
    int p1,
    int p2,
    int p3,
    int p4,
    int p5,
    int p6,
    int p7,
    boolean p8
)
boolean
boolean
boolean
boolean
performContextClick(float p0, float p1)
boolean
boolean
performHapticFeedback(int p0, int p1)
boolean
boolean
performLongClick(float p0, float p1)
@Nullable ContentInfo
void
boolean
boolean
postDelayed(@NonNull Runnable p0, long p1)
void
void
postInvalidate(int p0, int p1, int p2, int p3)
void
void
postInvalidateDelayed(long p0, int p1, int p2, int p3, int p4)
void
void
postInvalidateOnAnimation(int p0, int p1, int p2, int p3)
void
void
void
void
boolean
void
void
void
void
void
void

This method is deprecated. Deprecated in Java

final boolean
final boolean
requestFocus(int p0)
boolean
requestFocus(int p0, @NonNull Rect p1)
final boolean
void
void
boolean
boolean
final void
final void
final @NonNull T
<T extends View> requireViewById(int p0)
void
boolean
void
final void
saveAttributeDataForStyleable(
    @NonNull Context p0,
    @NonNull int[] p1,
    @Nullable AttributeSet p2,
    @NonNull TypedArray p3,
    int p4,
    int p5
)
void
void
void
void
void
void
void
void
void
void
void
void
setActivated(boolean p0)
void
void
void
void
setAlpha(float p0)
void
void
void
void
void
void
void
void

This method is deprecated. Deprecated in Java

void
void
void
void
final void
setBottom(int p0)
void
void
setClickable(boolean p0)
void
void
setClipToOutline(boolean p0)
void
void
final void
void
setContextClickable(boolean p0)
void
void

This method is deprecated. Deprecated in Java

void

This method is deprecated. Deprecated in Java

void

This method is deprecated. Deprecated in Java

void
void
setElevation(float p0)
void
setEnabled(boolean p0)
void
void
void
void
setFocusable(boolean p0)
void
setFocusable(int p0)
void
void
setFocusedByDefault(boolean p0)
void
setForceDarkAllowed(boolean p0)
void
void
void
void
void
void
void
setHandwritingBoundsOffsets(float p0, float p1, float p2, float p3)
void
void
void
void
void
void
void
void
void
setHovered(boolean p0)
void
setId(int p0)
void
void
void
void
setIsCredential(boolean p0)
void
void
setKeepScreenOn(boolean p0)
void
void
setLabelFor(int p0)
void
void
setLayerType(int p0, @Nullable Paint p1)
void
void
final void
setLeft(int p0)
final void
setLeftTopRightBottom(int p0, int p1, int p2, int p3)
void
setLongClickable(boolean p0)
final void
setMeasuredDimension(int p0, int p1)
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void
void

This method is deprecated. Deprecated in Java

void
void
void
void
void
void
setPadding(int p0, int p1, int p2, int p3)
void
setPaddingRelative(int p0, int p1, int p2, int p3)
void
void
setPivotX(float p0)
void
setPivotY(float p0)
void
final void
setPreferKeepClear(boolean p0)
final void
void
setPressed(boolean p0)
void
void
final void
final void
setRight(int p0)
void
setRotation(float p0)
void
setRotationX(float p0)
void
setRotationY(float p0)
void
setSaveEnabled(boolean p0)
void
void
setScaleX(float p0)
void
setScaleY(float p0)
void
void
void
void
void
final void
void
void
setScrollContainer(boolean p0)
void
void
setScrollIndicators(int p0, int p1)
void
setScrollX(int p0)
void
setScrollY(int p0)
void
void
setSelected(boolean p0)
void
void
void
void
void
void

This method is deprecated. Deprecated in Java

void
void
setTag(int p0, @NonNull Object p1)
void
void
void
final void
setTop(int p0)
void
void
final void
void
void
setTranslationX(float p0)
void
setTranslationY(float p0)
void
setTranslationZ(float p0)
void
void
void
void
void
void
void
setVisibility(int p0)
void

This method is deprecated. Deprecated in Java

void
setWillNotDraw(boolean p0)
void
void
setX(float p0)
void
setY(float p0)
void
setZ(float p0)
boolean
boolean
showContextMenu(float p0, float p1)
@NonNull ActionMode
@NonNull ActionMode
void
final boolean
startDrag(
    @NonNull ClipData p0,
    @NonNull View.DragShadowBuilder p1,
    @NonNull Object p2,
    int p3
)

This method is deprecated. Deprecated in Java

final boolean
startDragAndDrop(
    @NonNull ClipData p0,
    @NonNull View.DragShadowBuilder p1,
    @NonNull Object p2,
    int p3
)
boolean
void
@NonNull String
void
void
void
void
final void
boolean
boolean

This method is deprecated. Deprecated in Java

boolean
@ViewDebug.ExportedProperty(category = "drawing")
willNotDraw()

Constants

GESTURE_STATE_IDLE

public static final int GESTURE_STATE_IDLE = 0

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

GESTURE_STATE_INTERACTING

public static final int GESTURE_STATE_INTERACTING = 1

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

GESTURE_STATE_SETTLING

public static final int GESTURE_STATE_SETTLING = 2

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.

Public constructors

PdfView

Added in 1.0.0-alpha10
public PdfView(@NonNull Context context, AttributeSet attrs, int defStyle)

Public methods

addOnGestureStateChangedListener

Added in 1.0.0-alpha10
public final void addOnGestureStateChangedListener(
    @NonNull PdfView.OnGestureStateChangedListener listener
)

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
@NonNull PdfView.OnGestureStateChangedListener listener

listener to notify when interaction state change events occur

addOnSelectionChangedListener

Added in 1.0.0-alpha10
public final void addOnSelectionChangedListener(
    @NonNull PdfView.OnSelectionChangedListener listener
)

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

Parameters
@NonNull PdfView.OnSelectionChangedListener listener

listener to notify when selection change events occur

addOnViewportChangedListener

Added in 1.0.0-alpha10
public final void addOnViewportChangedListener(
    @NonNull PdfView.OnViewportChangedListener listener
)

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

Parameters
@NonNull PdfView.OnViewportChangedListener listener

listener to add

clearSelection

Added in 1.0.0-alpha10
public final void clearSelection()

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

computeScroll

public void computeScroll()

dispatchKeyEvent

public boolean dispatchKeyEvent(KeyEvent event)

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.

getCurrentSelection

Added in 1.0.0-alpha10
public final Selection getCurrentSelection()

The currently selected PDF content, as Selection

getFastScrollPageIndicatorBackgroundDrawable

Added in 1.0.0-alpha10
public final @NonNull Drawable getFastScrollPageIndicatorBackgroundDrawable()

getFastScrollPageIndicatorMarginEnd

Added in 1.0.0-alpha10
public final int getFastScrollPageIndicatorMarginEnd()

getFastScrollVerticalThumbDrawable

Added in 1.0.0-alpha10
public final @NonNull Drawable getFastScrollVerticalThumbDrawable()

getFastScrollVerticalThumbMarginEnd

Added in 1.0.0-alpha10
public final int getFastScrollVerticalThumbMarginEnd()

getFirstVisiblePage

Added in 1.0.0-alpha10
public final int getFirstVisiblePage()

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

getGestureState

Added in 1.0.0-alpha10
public final int getGestureState()

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

getMaxZoom

Added in 1.0.0-alpha10
public final float getMaxZoom()

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

getMinZoom

Added in 1.0.0-alpha10
public final float getMinZoom()

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

getPdfDocument

Added in 1.0.0-alpha10
public final PdfDocument getPdfDocument()

Supply a PdfDocument to process the PDF content for rendering

getVisiblePagesCount

Added in 1.0.0-alpha10
public final int getVisiblePagesCount()

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

getZoom

Added in 1.0.0-alpha10
public final float getZoom()

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)

onGenericMotionEvent

public boolean onGenericMotionEvent(MotionEvent event)

onTouchEvent

public boolean onTouchEvent(MotionEvent event)

pdfToViewPoint

Added in 1.0.0-alpha10
public final PointF pdfToViewPoint(@NonNull PdfPoint pdfPoint)

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

removeOnGestureStateChangedListener

Added in 1.0.0-alpha10
public final void removeOnGestureStateChangedListener(
    @NonNull PdfView.OnGestureStateChangedListener listener
)

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
@NonNull PdfView.OnGestureStateChangedListener listener

listener to remove

removeOnSelectionChangedListener

Added in 1.0.0-alpha10
public final void removeOnSelectionChangedListener(
    @NonNull PdfView.OnSelectionChangedListener listener
)

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

Parameters
@NonNull PdfView.OnSelectionChangedListener listener

listener to remove

removeOnViewportChangedListener

Added in 1.0.0-alpha10
public final void removeOnViewportChangedListener(
    @NonNull PdfView.OnViewportChangedListener listener
)

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

Parameters
@NonNull PdfView.OnViewportChangedListener listener

listener to remove

scrollBy

public void scrollBy(int x, int y)

scrollTo

public void scrollTo(int x, int y)

scrollToPage

Added in 1.0.0-alpha10
public final void scrollToPage(int pageNum)

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-alpha10
public final void scrollToPosition(@NonNull PdfPoint position)

Scrolls to position, 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.

setFastScrollPageIndicatorBackgroundDrawable

Added in 1.0.0-alpha10
public final void setFastScrollPageIndicatorBackgroundDrawable(
    @NonNull Drawable fastScrollPageIndicatorBackgroundDrawable
)

setFastScrollPageIndicatorMarginEnd

Added in 1.0.0-alpha10
public final void setFastScrollPageIndicatorMarginEnd(
    int fastScrollPageIndicatorMarginEnd
)

setFastScrollVerticalThumbDrawable

Added in 1.0.0-alpha10
public final void setFastScrollVerticalThumbDrawable(
    @NonNull Drawable fastScrollVerticalThumbDrawable
)

setFastScrollVerticalThumbMarginEnd

Added in 1.0.0-alpha10
public final void setFastScrollVerticalThumbMarginEnd(
    int fastScrollVerticalThumbMarginEnd
)

setHighlights

Added in 1.0.0-alpha10
public final void setHighlights(@NonNull List<@NonNull Highlight> highlights)

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-alpha10
public final void setLinkClickListener(PdfView.LinkClickListener listener)

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

setMaxZoom

Added in 1.0.0-alpha10
public final void setMaxZoom(float maxZoom)

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

setMinZoom

Added in 1.0.0-alpha10
public final void setMinZoom(float minZoom)

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

setPdfDocument

Added in 1.0.0-alpha10
public final void setPdfDocument(PdfDocument pdfDocument)

Supply a PdfDocument to process the PDF content for rendering

setZoom

Added in 1.0.0-alpha10
public final void setZoom(float zoom)

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)

viewToPdfPoint

Added in 1.0.0-alpha10
public final PdfPoint viewToPdfPoint(@NonNull PointF viewPoint)

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-alpha10
public final PdfPoint viewToPdfPoint(float x, float y)

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

Protected methods

computeHorizontalScrollRange

protected int computeHorizontalScrollRange()

computeVerticalScrollRange

protected int computeVerticalScrollRange()

dispatchHoverEvent

protected boolean dispatchHoverEvent(MotionEvent event)

onAttachedToWindow

protected void onAttachedToWindow()

onConfigurationChanged

protected void onConfigurationChanged(Configuration newConfig)

onDetachedFromWindow

protected void onDetachedFromWindow()

onDraw

protected void onDraw(@NonNull Canvas canvas)

onFocusChanged

protected void onFocusChanged(
    boolean gainFocus,
    int direction,
    Rect previouslyFocusedRect
)

onLayout

protected void onLayout(boolean changed, int left, int top, int right, int bottom)

onRestoreInstanceState

protected void onRestoreInstanceState(Parcelable state)

onSaveInstanceState

protected Parcelable onSaveInstanceState()

onScrollChanged

protected void onScrollChanged(int l, int t, int oldl, int oldt)

onSizeChanged

protected void onSizeChanged(int w, int h, int oldw, int oldh)

onWindowVisibilityChanged

protected void onWindowVisibilityChanged(int visibility)