public class

PDFViewCtrl

extends ViewGroup
java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ com.pdftron.pdf.PDFViewCtrl

Class Overview

PDFViewCtrl is derived from android.view.ViewGroup and encapsulates a rich set of functionalities for interactive viewing of PDF documents.

PDFViewCtrl makes use of PDFTron's PDFNet library that is compiled as a native library to ensure real-time viewing experience. It provides a comprehensive set of functionalities, including multi-threaded rendering, PDF rendering settings, scrolling, zooming, page navigation, different page viewing modes, coordinates conversion, text selection, text search, etc. In addition, PDFViewCtrl also allows for extension to accommodate a user's specific needs, which can be achieved in one of the following two ways:

  1. Derive from PDFViewCtrl and override its functions such as onMeasure(int, int), onDraw(Canvas), onScroll(MotionEvent, MotionEvent, float, float), etc. However, note that since PDFViewCtrl implements these functions, it is necessary to call PDFViewCtrl's implementations first.

  2. The recommended way is to use PDFViewCtrl's PDFViewCtrl.ToolManager interface. This interface provides a way for users to interact with PDFViewCtrl, including customizing responses to gestures and drawing extra contents on top of the PDF content. In fact, PDFNet SDK also ships with a separate library (Tools), that is programmed via this interface. This library utilizes functions offered by PDFNet and implements several ready-to-use UI modules such as annotation editing, text selection, text search, page navigation, etc.

Summary

Nested Classes
interface PDFViewCtrl.ActionCompletedListener Callback interface invoked when an action is completed  
enum PDFViewCtrl.ConversionState An enum represents document conversion state  
interface PDFViewCtrl.DocumentDownloadListener Used for receiving updates from document downloading, which can be started by openUrlAsync(String, String, String, HTTPRequestOptions)  
interface PDFViewCtrl.DocumentLoadListener Used for receiving notifications about the document state. 
enum PDFViewCtrl.DownloadState An enum represents document download state  
interface PDFViewCtrl.ErrorReportListener Used for receiving error reports in case an error is encountered during page rendering. 
class PDFViewCtrl.HTTPRequestOptions Class for customizing network requests. 
class PDFViewCtrl.LinkInfo A class that holds information for a link. 
interface PDFViewCtrl.OnCanvasSizeChangeListener Used for tracking current canvas size changes  
enum PDFViewCtrl.OverPrintMode Overprint mode. 
interface PDFViewCtrl.PageChangeListener Used for receiving notifications in UI thread when the current page changes. 
enum PDFViewCtrl.PageChangeState State of page changes. 
enum PDFViewCtrl.PagePresentationMode Page presentation mode  
enum PDFViewCtrl.PageViewMode Page view mode  
enum PDFViewCtrl.PriorEventMode Prior event mode  
interface PDFViewCtrl.RenderingListener Used for receiving notifications of the start and end of the rendering of the client area. 
class PDFViewCtrl.Selection Class that represents the current text selection by PDFViewCtrl. 
interface PDFViewCtrl.TextSearchListener Used for receiving notifications in UI thread during the process of text search. 
enum PDFViewCtrl.TextSearchResult Text search result state  
enum PDFViewCtrl.TextSelectionMode Text selection mode  
interface PDFViewCtrl.ThumbAsyncListener Used for receiving events from a request for thumbnails. 
interface PDFViewCtrl.ToolManager Tool manager interface that is used for creating tools. 
interface PDFViewCtrl.UniversalDocumentConversionListener Used for receiving updates from universal document conversion when document are opened by by openUniversalDocument(DocumentConversion)
interface PDFViewCtrl.UniversalDocumentProgressIndicatorListener Used for receiving notifications of the current blank page whose content generation is in progress. 
enum PDFViewCtrl.ZoomLimitMode Zoom limit mode. 
Constants
double SCROLL_ZOOM_FACTOR
[Expand]
Inherited Constants
From class android.view.ViewGroup
From class android.view.View
Fields
public static int DEFAULT_BG_COLOR
public static int DEFAULT_DARK_BG_COLOR
protected PDFDoc mDoc
protected SecondaryFileFilter mDocumentConversionFilter
[Expand]
Inherited Fields
From class android.view.View
Public Constructors
PDFViewCtrl(Context context, AttributeSet attrs)
Constructor that is called when inflating a view from XML.
PDFViewCtrl(Context context, AttributeSet attrs, int defStyle)
Perform inflation from XML and apply a class-specific base style.
Public Methods
void addDocumentDownloadListener(PDFViewCtrl.DocumentDownloadListener listener)
Adds the document download listener.
void addDocumentLoadListener(PDFViewCtrl.DocumentLoadListener listener)
Adds the document load listener.
void addOnCanvasSizeChangeListener(PDFViewCtrl.OnCanvasSizeChangeListener listener)
Add a listener that will be called when the canvas size of the view change due to layout processing.
void addPageChangeListener(PDFViewCtrl.PageChangeListener listener)
Add the page change listener
void addThumbAsyncListener(PDFViewCtrl.ThumbAsyncListener listener)
Adds a listener to get events from getThumbAsync(int).
void addUniversalDocumentConversionListener(PDFViewCtrl.UniversalDocumentConversionListener listener)
Adds the document conversion listener
boolean canGotoNextPage()
Checks if can set the current page to the next page.
boolean canGotoPreviousPage()
Checks if can set the current page to the previous page.
boolean canScrollHorizontally(int direction)
void cancelAllThumbRequests()
Cancels all thumbnail requests initiated by getThumbAsync(int).
void cancelFindText()
Cancels the current text search thread, if exists.
void cancelRendering()
Cancels the rendering thread, if running.
void cancelRenderingAsync()
void clearSelection()
Removes all text PDFViewCtrl.Selection.
void clearThumbCache()
Clear the thumbnail cache.
void closeDoc()
Closes the current document.
void closeTool()
Closes the current tool.
void computeScroll()
The overloaded implementation of computeScroll().
double[] convCanvasPtToPagePt(double x, double y, int page_num)
Converts a point in canvas space to the specified page space.
double[] convCanvasPtToPagePt(double x, double y)
Converts a point in canvas space to the current page space.
double[] convCanvasPtToScreenPt(double x, double y, int pageNumber)
Converts a point expressed in canvas space to a point in screen space.
double[] convCanvasPtToScreenPt(double x, double y)
Converts a point expressed in canvas space to a point in screen space.
double[] convHorizontalScrollingPtToPagePt(double x, double y, int page_num)
double[] convPagePtToCanvasPt(double x, double y, int page_num)
Converts a point in the specified page space to canvas space.
double[] convPagePtToCanvasPt(double x, double y)
Converts a point in the current page space to canvas space.
double[] convPagePtToHorizonalScrollingPt(double x, double y, int page_num)
Converts a point from a page space to horizontal scrollable region space.
double[] convPagePtToHorizontalScrollingPt(double x, double y, int page_num)
Converts a point from a page space to horizontal scrollable region space.
double[] convPagePtToScreenPt(double x, double y, int page_num)
Converts a point from a page space to a point in screen space.
double[] convScreenPtToCanvasPt(double x, double y, int pageNumber)
Converts a point expressed in screen space to a point in (PDF) canvas space.
double[] convScreenPtToCanvasPt(double x, double y)
Converts a point expressed in screen space to a point in (PDF) canvas space.
double[] convScreenPtToPagePt(double x, double y, int page_num)
Converts a point expressed in screen space to a point on a page space.
double[] convScreenPtToPagePt(double x, double y)
Converts a point expressed in screen space to a point on a page space.
void destroy()
Should be called in android.app.Activity.onDestroy() to destroy PDFViewCtrl and clean up memory and used resources.
void docLock(boolean cancel_rendering)
Locks the PDFDoc instance used by PDFViewCtrl.
void docLockRead()
Locks the PDFDoc instance used by PDFViewCtrl for reading.
boolean docTryLock(int milliseconds)
Try acquiring a write lock on the currently open document, waiting no longer than specified number of milliseconds.
boolean docTryLockRead(int milliseconds)
Try acquiring a read lock on the current document, waiting no longer than specified number of milliseconds.
boolean docUnlock()
Unlocks the PDFDoc instance used by PDFViewCtrl and restarts the rendering thread if it was canceled by calling docLock(boolean).
boolean docUnlockRead()
Removes the read lock from the PDFDoc instance used by PDFViewCtrl.
void enableAnnotationLayer()
Enable separate rendering layer for annotations.
ExternalAnnotManager enableExternalAnnotManager(String author_name)
void enableUndoRedo()
Enable Undo/Redo in this PDFview.
void executeAction(ActionParameter action_param)
Executes the action.
void executeAction(Action action)
Executes the action.
void findText(String search_str, boolean match_case, boolean match_whole_word, boolean search_up, boolean reg_exp, int page_num)
Searches asynchronously, starting from the current page, for the given text.
void findText(String search_str, boolean match_case, boolean match_whole_word, boolean search_up, boolean reg_exp)
Searches asynchronously, starting from the current page, for the given text.
long[] getAllCanvasPixelSizes()
Returns the size of the scrollable spaces for all canvases.
int getAnnotTypeUnder(double x, double y)
Gets annotation type at the given point
Annot getAnnotationAt(int x, int y)
Gets the annotation at the (x, y) position expressed in screen coordinates.
Annot getAnnotationAt(int x, int y, double distanceThreshold, double minimumLineWeight)
Gets the annotation at the (x, y) position expressed in screen coordinates.
ArrayList<Annot> getAnnotationListAt(int x1, int y1, int x2, int y2)
Gets the list of annotations at line (x1, y1, x2, y2) expressed in screen coordinates
CurvePainter getAnnotationPainter(int page_num, long annot_key)
ArrayList<Annot> getAnnotationsOnPage(int page_num)
Gets the list of annotations on a given page.
double getCanvasHeight()
Returns the height of Zoomed PDF Canvas Space.
double getCanvasWidth()
Returns the width of Zoomed PDF Canvas Space.
int getClientBackgroundColor()
Gets the background color of the client area.
int getColorPostProcessMode()
void getContentSize(int[] size)
Gets the size of the actual content in the current canvas meaning all pages, as well as gaps and padding set by setPageSpacing
int getCurCanvasId()
PointF getCurrentMousePosition()
int getCurrentPage()
Gets the current page number.
Matrix2D getDeviceTransform(int page_num)
Gets the device transformation matrix.
Matrix2D getDeviceTransform()
Gets the device transformation matrix.
boolean getDirectionalLockEnabled()
int getDisplayCutoutBottom()
Gets the bottom display cutout height
int getDisplayCutoutTop()
Gets the top display cutout height
PDFDoc getDoc()
Gets the current PDF document.
ExternalAnnotManager getExternalAnnotManager()
Gets the external annot manager belonging to this PDFViewCtrl
int getHScrollPos()
Gets the current horizontal scroll position.
PDFViewCtrl.LinkInfo getLinkAt(int x, int y)
Gets the link info at a given point, specified in screen space.
boolean getLongPressEnabled()
Gets if PdfViewCtrl can read long press event
String getNextRedoInfo()
Returns any meta-data associated with the next sate in the undo/redo chain.
String getNextUndoInfo()
Returns any meta-data associated with the previous sate in the undo/redo chain.
Context getOCGContext()
Gets the OCG context.
int getPageBox()
Gets the box used by PDFViewCtrl for rasterizing.
int getPageCount()
Gets the page count.
int getPageNumberFromScreenPt(double x, double y)
Gets the number of the page on which the specified point in screen space.
PDFViewCtrl.PagePresentationMode getPagePresentationMode()
Gets the current page presentation mode.
Rect getPageRectForAnnot(Annot annot, int page_num)
Gets the annotation bounding box in page coordinates
PDFViewCtrl.PageViewMode getPageRefViewMode()
Gets the reference page view mode.
int getPageRotation()
Gets the current rotation applied to all pages in PDFViewCtrl.
Matrix getPageSlidingCanvasTransform()
Gets the extra transformation matrix applied to the android.graphics.Canvas object used by PDFViewCtrl during page sliding.
PDFViewCtrl.PageViewMode getPageViewMode()
Gets the current page viewing mode.
ColorPt getPostProcessedColor(ColorPt cp)
Convert a color based on the defined post processing transformation in setColorPostProcessMapFile(Filter).
PDFViewCtrl.PageViewMode getPreferredViewMode()
Gets the preferred view mode when maintain zoom level is enabled
boolean getProgressiveRendering()
Checks if progressive rendering is used.
boolean getRightToLeftLanguage()
Checks if PDFViewCtrl thinks the content in the viewed PDF document reads from right to left.
Rect getScreenRectForAnnot(Annot annot, int page_num)
Gets the annotation bounding box in screen coordinates
int getScrollOffsetForCanvasId(int canvasId)
int getScrollXOffsetInTools(int pageNum)
int getScrollYOffsetInTools(int pageNum)
PDFViewCtrl.Selection getSelection(int page)
Gets the text PDFViewCtrl.Selection on a given page.
int getSelectionBeginPage()
Returns the first page number that has text PDFViewCtrl.Selection on it.
int getSelectionEndPage()
Returns the last page number that has text PDFViewCtrl.Selection on it.
int getSlidingScrollY()
void getThumbAsync(int page_num)
This will request a thumbnail for the given page number.
PDFViewCtrl.ToolManager getToolManager()
Gets the PDFViewCtrl.ToolManager instance used by PDFViewCtrl.
int getVScrollPos()
Gets the current vertical scroll position.
int getViewCanvasHeight()
Returns the height of PDFViewCtrl Canvas space.
int getViewCanvasWidth()
Returns the width of PDFViewCtrl Canvas space.
int[] getVisiblePages()
Gets an array with the pages currently visible on the screen.
int[] getVisiblePagesInTransition()
Gets an array with the pages currently visible on the screen.
double getZoom()
Gets the current zoom factor.
boolean getZoomEnabled()
double getZoomForViewMode(PDFViewCtrl.PageViewMode viewMode)
Calculates the zoom for the current view if it was currently in the view mode set by setPageViewMode(PageViewMode) with viewMode
boolean gotoFirstPage()
Sets the current page to the first page.
boolean gotoLastPage()
Sets the current page to the last page.
void gotoNextPage(boolean animation)
boolean gotoNextPage()
Sets the current page to the next page.
boolean gotoPreviousPage()
Sets the current page to the previous page.
void gotoPreviousPage(boolean animation)
boolean hasSelection()
Checks if there is any text PDFViewCtrl.Selection.
boolean hasSelectionOnPage(int page)
Checks if there is any text PDFViewCtrl.Selection on a given page.
void hideAnnotation(Annot annot)
Disable rendering of a particular annotation.
boolean isAnnotationLayerEnabled()
boolean isContinuousPagePresentationMode(PDFViewCtrl.PagePresentationMode mode)
Utility function that checks if the page presentation mode is continuous.
boolean isCurrentSlidingCanvas(int pageNum)
boolean isFacingPagePresentationMode(PDFViewCtrl.PagePresentationMode mode)
Utility function that checks if the page presentation mode is facing.
boolean isFinishedRendering(boolean visible_region_only)
Checks if the rendering thread finishes or the current visible region has been fully rendered.
boolean isFinishedRendering()
Checks if the rendering thread has finished.
boolean isHardwareAccelerated()
Checks if PDFViewCtrl is hardware accelerated.
boolean isMaintainZoomEnabled()
boolean isSlidingWhileZoomed()
Gets whether the viewer is currently in horizontal page transition mode while the current canvas is zoomed in before the sliding happens
boolean isThereTextInRect(double x1, double y1, double x2, double y2)
Checks if in the given region there is any text.
boolean isUndoRedoEnabled()
boolean isZoomingInAddingAnnotationEnabled()
Rect jumpToAnnotWithID(String annotId)
void onConfigurationChanged(Configuration newConfig)
Call this method to trigger the Tools' onConfigurationChanged event.
boolean onGenericMotionEvent(MotionEvent event)
The overloaded implementation of onGenericMotionEvent(MotionEvent).
boolean onKeyUp(int keyCode, KeyEvent event)
Notified when a key was released.
boolean onTouchEvent(MotionEvent event)
The overloaded implementation of android.view.onTouchEvent().
DocumentConversion openNonPDFUri(Uri fileUri, ConversionOptions options)
Utility function for opening a non-PDF document for display.
PDFDoc openPDFUri(Uri fileUri, String password, String cachePath, PDFViewCtrl.HTTPRequestOptions httpRequestOptions)
Utility function for opening a PDF document for display.
PDFDoc openPDFUri(Uri fileUri, String password)
Utility function for opening a PDF document for display.
void openUniversalDocument(DocumentConversion conversion)
Sets the PDF document to be displayed.
void openUrlAsync(String url, String cachePdf, String password, PDFViewCtrl.HTTPRequestOptions options)
Sets the PDF document, from a URL, that is to be displayed.
void pause()
Should be called in android.app.Activity.onPause() to pause PDFViewCtrl.
void postCustomEvent(Object obj)
Posts a message to cause onCustomEvent(Object) to be called in the next main message loop.
void prepareAnnotsForMouse(int pageNum, double distanceThreshold, double minimumLineWeight)
Requests for preparing annotations of the given page.
void prepareAnnotsForMouse(int pageNum)
Requests for preparing annotations of the given page.
void prepareWords(int pageNum)
Requests for preparing words of the given page.
void purgeMemory()
Call this method to lower PDFViewCtrl's memory consumption, such as in Activity.onLowMemory().
void purgeMemoryDueToOOM()
it is a good practice in your code to catch OutOfMemoryError exception and then call this method.
String redo()
Go to the next state in the undo/redo chain.
void refreshAndUpdate(ViewChangeCollection view_change)
Helper function that will refresh annotation and/or field appearances if needed, and then render modified page areas, all based on the contents of the view_change parameter.
void removeDocumentDownloadListener(PDFViewCtrl.DocumentDownloadListener listener)
Removes the document download listener.
void removeDocumentLoadListener(PDFViewCtrl.DocumentLoadListener listener)
Removes the document load listener.
void removeOnCanvasSizeChangeListener(PDFViewCtrl.OnCanvasSizeChangeListener listener)
Removes the canvas size change listener.
void removePageChangeListener(PDFViewCtrl.PageChangeListener listener)
Remove Page change listener
void removeThumbAsyncListener(PDFViewCtrl.ThumbAsyncListener listener)
Removes thumb async listener.
void removeUniversalDocumentConversionListener(PDFViewCtrl.UniversalDocumentConversionListener listener)
Removes the document conversion listener
void requestLayout()
Overloaded version of android.view.View.requestLayout().
void requestRendering()
Requests that PDFViewCtrl start rendering, if necessary.
void resume()
Should be called in android.app.Activity.onResume() to resume PDFViewCtrl.
void revertAllChanges()
Returns to the initial state in the undo/redo chain
void rotateClockwise()
Rotates all pages in the document 90 degrees clockwise.
void rotateCounterClockwise()
Rotates all pages in the document 90 degrees counter-clockwise.
void scrollBy(int dx, int dy)
Overloaded implementation of android.view.View.scrollBy().
void scrollTo(int x, int y)
Overloaded implementation of android.view.View.scrollTo().
boolean select(double x1, double y1, double x2, double y2)
Selects text within the given region using the current text selection mode.
boolean select(double x1, double y1, int page1, double x2, double y2, int page2)
Selects text using structural mode.
void selectAll()
Selects all the text in the document.
boolean selectAndJumpWithHighlights(Highlights highlights)
Selects texts identified by Highlights.
boolean selectByRect(double x1, double y1, double x2, double y2)
Selects text within the given region using rectangular selection mode.
boolean selectByStructWithSmartSnapping(double x1, double y1, double x2, double y2)
Selects text within the given region using structural text selection mode and with smart snapping.
boolean selectByStructWithSnapping(double x1, double y1, double x2, double y2, boolean snap_to_start, boolean snap_to_end)
Selects text within the given region using the current text selection mode with defined snap-to-start and snap-to-end modes.
boolean selectWithHighlights(Highlights highlights)
Selects texts identified by Highlights.
boolean selectWithSelection(PDFViewCtrl.Selection sel)
Selects texts identified by Selection.
void setActionCompletedListener(PDFViewCtrl.ActionCompletedListener listener)
Sets action completed listener.
void setAntiAliasing(boolean enable_aa)
Enables or disables anti-aliasing.
void setBuiltInPageSlidingAnimationDuration(int animationDuration)
Sets the parameter of built-in page turning effect.
void setBuiltInPageSlidingEnabled(boolean enabled)
Enables or disables the built-in page turning animation effect (sliding) when it is under non-continuous page presentation mode (setPagePresentationMode(PagePresentationMode)).
void setBuiltInPageSlidingState(boolean state)
Sets the current state of page slider.
void setBuiltInPageSlidingThreshSpeed(int fling_dp_per_second)
Sets the parameter of built-in page turning effect.
void setBuiltInZoomAnimationDuration(int animationDuration)
Sets the parameter of zoom animation effect.
void setCaching(boolean enabled)
Enables or disables caching.
void setClientBackgroundColor(int r, int g, int b, boolean transparent)
Sets the background color of the client area.
void setColorPostProcessColors(int whiteColor, int blackColor)
Sets the color post processing transformation.
void setColorPostProcessMapFile(Filter image_file_contents)
Sets the color post processing transformation.
void setColorPostProcessMode(int mode)
Sets the color post processing transformation.
boolean setCurrentPage(int page_num)
Goes to the specified page.
void setDebug(boolean debug)
void setDefaultPageColor(int c)
Sets the default 'paper' color used to draw background of each page.
void setDefaultPageColor(int r, int g, int b)
Sets the default 'paper' color used to draw background of each page.
void setDevicePixelDensity(double dpi, double scale_factor)
Sets device dpi
void setDirectionalLockEnabled(boolean enabled)
void setDisplayCutout(int top, int bottom)
Sets the display cutout
void setDoc(PDFDoc doc)
Sets the PDF document to be displayed.
void setDrawAnnotations(boolean render_annots)
Enables or disables annotation and forms rendering.
void setErrorReportListener(PDFViewCtrl.ErrorReportListener listener)
Sets the error report listener.
void setGamma(double exp)
Sets the gamma factor used for anti-aliased rendering.
void setHScrollPos(int pos)
Sets the horizontal scroll position.
void setHighlightFields(boolean highlight_fields)
Enable or disable highlighting form fields.
void setHorizontalAlign(int align)
Sets the horizontal alignment used for rendering pages within the view.
void setImageSmoothing(boolean smoothing)
Sets if image smoothing is used.
void setInteractionEnabled(boolean enabled)
Enable or disable user input for PDFViewCtrl.
void setLongPressEnabled(boolean enable)
Sets if pdfViewCtrl can dispatch long press event
void setMaintainZoomEnabled(boolean enabled)
void setMinimumRefZoomForMaximumZoomLimit(double required_zoom)
Sets the minimum ref zoom used for calculating the maximum zoom limit when using relative zoom limits.
void setNextOnLayoutAdjustments(int extra_scroll_x, int extra_scroll_y, boolean animateZoomLimitsIfNecessary)
Adjusts the position of PDFViewCtrl content.
void setOCGContext(Context ctx)
Sets the Optional Content Group (OCG) context that should be used when viewing the document.
void setOverprint(PDFViewCtrl.OverPrintMode overprint)
Enables or disables support for overprint.
void setPageBorderVisibility(boolean borderVisibility)
Enables or disables drawing of a thin border around each page.
void setPageBox(int region)
Selects the PageBox to rasterize.
void setPagePresentationMode(PDFViewCtrl.PagePresentationMode mode)
Sets the page presentation mode.
void setPageRefViewMode(PDFViewCtrl.PageViewMode mode)
Sets the reference page view mode.
void setPageSpacing(int horiz_col_space, int vert_col_space, int horiz_pad, int vert_pad)
Sets the padding for PDFViewCtrl, as well as vertical and horizontal padding and column spacing between adjacent pages in the view.
void setPageSpacingDP(int horiz_col_space, int vert_col_space, int horiz_pad, int vert_pad)
Sets the vertical and horizontal padding and column spacing between adjacent pages in the view.
void setPageTransparencyGrid(boolean trans_grid_visible)
Enables or disables the transparency grid (check board pattern) to reflect page transparency.
void setPageViewMode(PDFViewCtrl.PageViewMode mode)
Sets the page viewing mode.
void setPageViewMode(PDFViewCtrl.PageViewMode mode, int x, int y, boolean animate)
void setPathHinting(boolean path_hinting)
Enable or disable path hinting.
void setPreferredViewMode(PDFViewCtrl.PageViewMode viewMode)
Sets the preferred view mode when maintain zoom level is enabled.
void setProgressiveRendering(boolean progressive)
Enables or disables progressive rendering.
void setProgressiveRendering(boolean progressive, int delay_ms, int interval_ms)
Enables or disables progressive rendering and sets the initial delay and interval in milliseconds.
void setRelativeZoomLimits(PDFViewCtrl.PageViewMode refViewMode, double min_zoom, double max_zoom)
Sets the minimum and maximum zoom bounds of PDFViewCtrl relative to ref_view_mode

Note: See note at setZoomLimits(ZoomLimitMode, double, double) for explanation of relative zoom limits.

void setRenderedContentCacheSize(long allowed_max)
Sets the suggested memory size of the rendered content.
void setRenderingListener(PDFViewCtrl.RenderingListener listener)
Sets the rendering listener.
void setRightToLeftLanguage(boolean flag)
Tells PDFViewCtrl the content in the viewed PDF document reads from right to left.
void setTextSearchListener(PDFViewCtrl.TextSearchListener listener)
Sets the text search listener.
void setTextSelectionMode(PDFViewCtrl.TextSelectionMode mode)
Sets the selection mode used for text highlighting.
void setThinLineAdjustment(boolean pixel_grid_fit, boolean stroke_adjust)
Sets thin line adjustment parameters.
void setToolManager(PDFViewCtrl.ToolManager mgr)
Sets the PDFViewCtrl.ToolManager instance used by PDFViewCtrl.
void setUniversalDocumentProgressIndicatorListener(PDFViewCtrl.UniversalDocumentProgressIndicatorListener listener)
Sets the Universal Document progress listener
void setUrlExtraction(boolean enabled)
Enables or disables URL extraction.
void setVScrollPos(int pos)
Sets the vertical scroll position.
void setVerticalAlign(int align)
Sets the vertical alignment used for rendering pages within the view.
static void setViewerCache(SDFDoc document, int max_cache_size, boolean on_disk)
Sets the cache parameters of the page cache on disk (which caches content streams and mipmapped images) for this specific document.
boolean setZoom(double zoom)
Sets the zoom factor and re-render.
boolean setZoom(double zoom, boolean use_snapshot)
Sets the zoom factor and re-render.
boolean setZoom(int x, int y, double zoom)
Sets the zoom factor and re-render using the given coordinate (x,y) as a zoom center.
boolean setZoom(int x, int y, double zoom, boolean use_snapshot)
Sets the zoom factor and re-render using the given coordinate (x,y) as a zoom center.
boolean setZoom(int x, int y, double zoom, boolean use_snapshot, boolean animate)
void setZoomEnabled(boolean enable)
void setZoomLimits(PDFViewCtrl.ZoomLimitMode zoomLimitMode, double min_zoom, double max_zoom)
Sets the minimum and maximum zoom bounds of PDFViewCtrl.
void setZoomingInAddingAnnotationEnabled(boolean enabled)
void setupThumbnails(boolean use_embedded, boolean generate_at_runtime, boolean use_disk_cache, int thumb_max_side_length, long max_abs_cache_size, double max_perc_cache_size)
Specify the different thumbnail settings for the viewer.
void showAnnotation(Annot annot)
Enable rendering of a particular annotation.
boolean showRect(int page_num, Rect rect)
Adjusts the viewing area to fit a rectangle on a specified page.
boolean smartZoom(int x, int y, boolean animate)
boolean smartZoom(int x, int y)
Sets the zoom factor to a new value using the given pixel coordinate (x,y) to find an intersecting paragraph.
PointF snapToNearestInDoc(double x, double y)
Returns the point within the document geometry that is closest to another arbitrary point in screen space
String takeUndoSnapshot(String meta_info)
Creates a new state at the top of the undo/redo chain by taking a snapshot.
boolean turnPageInNonContinuousMode(int currentPage, boolean nextPage)
Turn to next or previous page in non-continuous mode when at the edge if possible
String undo()
Return to the previous state in the undo/redo chain.
void update(Annot annot, int page_num)
Redraws the area covered with a given annotation.
void update(boolean all)
Redraws the contents.
void update(Rect rec)
Redraws the given area in the client space.
void update(Field field)
Redraws all instances (Widgets) of the field.
void update()
Redraws the contents of the visible region.
void updateOCGContext()
This method is deprecated. Updated the current Optional Content Group (OCG) context associated with this PDFViewCtrl. This call might be helpful after, for example, a stamp has been added to the document.
void updatePageLayout()
Updates the page layout within the view.
void waitForRendering(int milliseconds)
Waits about specified milliseconds or until the visible region is done rendering, whichever is less.
void waitForRendering()
Waits about 1500 milliseconds or until the visible region is done rendering, whichever is less.
boolean wereAnnotsForMousePrepared(int pageNum)
Checks if annotations of the given page have been prepared.
boolean wereWordsPrepared(int pageNum)
Checks if words of the given page have been prepared.
Protected Methods
int computeHorizontalScrollRange()
The overloaded implementation of android.view.computeHorizontalScrollRange().
int computeVerticalScrollRange()
The overloaded implementation of android.view.computeVerticalScrollRange().
void finalize()
The overloaded implementation of java.lang.Object.finalize().
boolean onDoubleTap(MotionEvent e)
Notified when a double-tap occurs.
boolean onDoubleTapEvent(MotionEvent e)
Notified when an event within a double-tap gesture occurs, including the down, move, and up events.
boolean onDown(MotionEvent e)
Notified when a tap occurs with the down MotionEvent that triggered it.
void onDraw(Canvas canvas)
The overloaded implementation of android.view.View.onDraw().
boolean onFling(MotionEvent e1, MotionEvent e2, float x_vel, float y_vel)
Notified when a fling event occurs with a scroll event.
void onFlingStop()
Notified when a fling motion stops.
void onLayout(boolean changed, int l, int t, int r, int b)
The overloaded implementation of android.view.View.onLayout().
void onLongPress(MotionEvent e)
Notified when a long press occurs with the initial on down MotionEvent that triggered it.
void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
The overloaded implementation of android.view.View.onMeasure().
boolean onScale(ScaleGestureDetector detector)
Responds to scaling events for a gesture in progress.
boolean onScaleBegin(ScaleGestureDetector detector)
Responds to the beginning of a scaling gesture.
void onScaleEnd(ScaleGestureDetector detector)
Responds to the end of a scale gesture.
boolean onScroll(MotionEvent e1, MotionEvent e2, float x_dist, float y_dist)
Notified when a scroll event occurs with a scroll event.
void onScrollChanged(int l, int t, int oldl, int oldt)
Called in response to an internal scroll in PDFViewCtrl.
void onShowPress(MotionEvent e)
The user has performed a down MotionEvent and not performed a move or up yet.
boolean onSingleTapConfirmed(MotionEvent e)
Notified when a single-tap occurs.
boolean onSingleTapUp(MotionEvent e)
Notified when a tap occurs with the up MotionEvent that triggered it.
void onSizeChanged(int w, int h, int oldw, int oldh)
The overloaded implementation of android.view.View.onSizeChanged().
boolean onUp(MotionEvent e, PDFViewCtrl.PriorEventMode priorEventMode)
Notified when an up event occurs with the up MotionEvent that triggered it.
[Expand]
Inherited Methods
From class android.view.ViewGroup
From class android.view.View
From class java.lang.Object
From interface android.graphics.drawable.Drawable.Callback
From interface android.view.KeyEvent.Callback
From interface android.view.ViewManager
From interface android.view.ViewParent
From interface android.view.accessibility.AccessibilityEventSource

Constants

public static final double SCROLL_ZOOM_FACTOR

Constant Value: 1.5

Fields

public static int DEFAULT_BG_COLOR

public static int DEFAULT_DARK_BG_COLOR

protected PDFDoc mDoc

protected SecondaryFileFilter mDocumentConversionFilter

Public Constructors

public PDFViewCtrl (Context context, AttributeSet attrs)

Constructor that is called when inflating a view from XML. This is called when a view is being constructed from an XML file, supplying attributes that were specified in the XML file. This version uses a default style of 0, so the only attribute values applied are those in the Context's Theme and the given AttributeSet.

Parameters
context The Context the view is running in, through which it can access the current theme, resources, etc.
attrs The attributes of the XML tag that is inflating the view.

public PDFViewCtrl (Context context, AttributeSet attrs, int defStyle)

Perform inflation from XML and apply a class-specific base style. This constructor of View allows subclasses to use their own base style when they are inflating. For example, a Button class's constructor would call this version of the super class constructor and supply R.attr.buttonStyle for defStyle; this allows the theme's button style to modify all of the base view attributes (in particular its background) as well as the Button class's attributes.

Parameters
context The Context the view is running in, through which it can access the current theme, resources, etc.
attrs The attributes of the XML tag that is inflating the view.
defStyle The default style to apply to this view. If 0, no style will be applied (beyond what is included in the theme). This may either be an attribute resource, whose value will be retrieved from the current theme, or an explicit style resource.

Public Methods

public void addDocumentDownloadListener (PDFViewCtrl.DocumentDownloadListener listener)

Adds the document download listener.

public void addDocumentLoadListener (PDFViewCtrl.DocumentLoadListener listener)

Adds the document load listener.

public void addOnCanvasSizeChangeListener (PDFViewCtrl.OnCanvasSizeChangeListener listener)

Add a listener that will be called when the canvas size of the view change due to layout processing.

Parameters
listener The listener that will be called when layout bounds change.

public void addPageChangeListener (PDFViewCtrl.PageChangeListener listener)

Add the page change listener

public void addThumbAsyncListener (PDFViewCtrl.ThumbAsyncListener listener)

Adds a listener to get events from getThumbAsync(int).

public void addUniversalDocumentConversionListener (PDFViewCtrl.UniversalDocumentConversionListener listener)

Adds the document conversion listener

public boolean canGotoNextPage ()

Checks if can set the current page to the next page.

Returns
  • true if can turn page, false otherwise.

public boolean canGotoPreviousPage ()

Checks if can set the current page to the previous page.

Returns
  • true if can turn page, false otherwise.

public boolean canScrollHorizontally (int direction)

public void cancelAllThumbRequests ()

Cancels all thumbnail requests initiated by getThumbAsync(int).

public void cancelFindText ()

Cancels the current text search thread, if exists. Note that this function does not block the current thread (the cancel notification can be caught using the PDFViewCtrl.TextSearchListener.

public void cancelRendering ()

Cancels the rendering thread, if running.

public void cancelRenderingAsync ()

public void clearSelection ()

Removes all text PDFViewCtrl.Selection.

public void clearThumbCache ()

public void closeDoc ()

Closes the current document.

Note: This method will try to acquire a write lock internally. This way, make sure you are not holding any read locks on the document, otherwise an exception will be thrown. See docLock(boolean) and docLockRead() for more info.

public void closeTool ()

Closes the current tool. This causes the tool's onClose() function to be called. A tool implementation should take this opportunity to stop any ongoing thread and clean up resources.

public void computeScroll ()

The overloaded implementation of computeScroll().

public double[] convCanvasPtToPagePt (double x, double y, int page_num)

Converts a point in canvas space to the specified page space.

Note: For space details, please refer to convScreenPtToCanvasPt(double, double).

Parameters
x x coordinate of the input point
y y coordinate in the input point
page_num the page number for the page used as the origin of the destination coordinate system. Pages are indexed starting from one.
Returns
  • Converted point in page space.

public double[] convCanvasPtToPagePt (double x, double y)

Converts a point in canvas space to the current page space.

Note: For space details, please refer to convScreenPtToCanvasPt(double, double).

Parameters
x x coordinate of the input point
y y coordinate in the input point
Returns
  • Converted point in page space.

public double[] convCanvasPtToScreenPt (double x, double y, int pageNumber)

Converts a point expressed in canvas space to a point in screen space.

Note: For space details, please refer to convScreenPtToCanvasPt(double, double).

Parameters
x x coordinate of the input point
y y coordinate in the input point
pageNumber The page number whose canvas to use (only applies in non continuous modes). Default is current page.
Returns
  • Converted point in screen space.

public double[] convCanvasPtToScreenPt (double x, double y)

Converts a point expressed in canvas space to a point in screen space.

Note: For space details, please refer to convScreenPtToCanvasPt(double, double).

Parameters
x x coordinate of the input point
y y coordinate in the input point
Returns
  • Converted point in screen space.

public double[] convHorizontalScrollingPtToPagePt (double x, double y, int page_num)

public double[] convPagePtToCanvasPt (double x, double y, int page_num)

Converts a point in the specified page space to canvas space.

Note: For space details, please refer to convScreenPtToCanvasPt(double, double).

Parameters
x x coordinate of the input point
y y coordinate in the input point
page_num the page number for the page used as the origin of the destination coordinate system. Pages are indexed starting from one.
Returns
  • Converted point in canvas space.

public double[] convPagePtToCanvasPt (double x, double y)

Converts a point in the current page space to canvas space.

Note: For space details, please refer to convScreenPtToCanvasPt(double, double).

Parameters
x x coordinate of the input point
y y coordinate in the input point
Returns
  • Converted point in canvas space.

public double[] convPagePtToHorizonalScrollingPt (double x, double y, int page_num)

Converts a point from a page space to horizontal scrollable region space.

Note: For space details, please refer to convScreenPtToCanvasPt(double, double).

Parameters
x x coordinate of the input point
y y coordinate in the input point
page_num the page number for the page used as the origin of the destination coordinate system. Pages are indexed starting from one.
Returns
  • Converted point in horizontal scrollable space.

public double[] convPagePtToHorizontalScrollingPt (double x, double y, int page_num)

Converts a point from a page space to horizontal scrollable region space.

Note: For space details, please refer to convScreenPtToCanvasPt(double, double).

Parameters
x x coordinate of the input point
y y coordinate in the input point
page_num the page number for the page used as the origin of the destination coordinate system. Pages are indexed starting from one.
Returns
  • Converted point in horizontal scrollable space.

public double[] convPagePtToScreenPt (double x, double y, int page_num)

Converts a point from a page space to a point in screen space.

Note: For space details, please refer to convScreenPtToCanvasPt(double, double).

Parameters
x x coordinate of the input point
y y coordinate in the input point
page_num the page number for the page used as the origin of the destination coordinate system. Pages are indexed starting from one.
Returns
  • Converted point in screen space.

public double[] convScreenPtToCanvasPt (double x, double y, int pageNumber)

Converts a point expressed in screen space to a point in (PDF) canvas space.

Parameters
x x coordinate of the input point
y y coordinate in the input point
pageNumber The page number whose canvas to use (only applies in non continuous modes). Default is current page.
Returns
  • Converted point in canvas space.

public double[] convScreenPtToCanvasPt (double x, double y)

Converts a point expressed in screen space to a point in (PDF) canvas space.

When converting points, PDFViewCtrl may refer to the following spaces:

  • Screen Space is the virtual area occupied by PDFViewCtrl on a device, originated at its upper-left corner. Note that this space can extend beyond the visible region. Screen Space is in the same scale with the dimensions of android.view.View;
  • Page Space is defined by a PDF page itself, originated at the lower-left corner. Unlike Screen Space, it is independent of how the page is viewed; namely, it does't change with the zoom factor, the scroll position, and etc.
  • (PDF) Canvas Space is defined as the smallest axis-aligned rectangle surrounding all the pages in continuous page presentation mode, or the current page(s) in non-continuous page presentation mode. For example, PagePresentationMode.FACING_CONT will make a wider but shorter Canvas Space than what PagePresentationMode.SINGLE_CONT will do. Note that PDF Canvas Space is in the same scale of Page Space and also independent of zoom factor, scroll position, etc. For simplicity, PDF Canvas Space is referenced to as Canvas Space.
  • Zoomed PDF Canvas Space is similar to PDF Canvas space, but after it is scaled by the current zoom factor, and page gaps are added between pages.
  • View Canvas Space is the virtual region occupied by the android.graphics.Canvas object, the one passed in through the onDraw(Canvas) method. Note that View Canvas Space is in general different from Canvas Space. For example, when PDFViewCtrl is zoomed out so that all the pages are visible, View Canvas Space will be larger than Canvas Space.

For example, if you want to know the coordinates of the upper-left corner of the Canvas Space in the Screen space, you can simply use convCanvasPtToScreenPt(0,0). If you want to calculate the coordinates of the lower-left corner of page 1 in the Screen Space, you can use convPagePtToScreenPt(0, 0, 1). Or if you just want to know the coordinates of the upper left corner of the Screen Space in View Canvas Space, it is simply (getScrollX(), getScrollY()).

Parameters
x x coordinate of the input point
y y coordinate in the input point
Returns
  • Converted point in canvas space.

public double[] convScreenPtToPagePt (double x, double y, int page_num)

Converts a point expressed in screen space to a point on a page space.

Note: For space details, please refer to convScreenPtToCanvasPt(double, double).

Parameters
x x coordinate of the input point
y y coordinate in the input point
page_num the page number for the page used as the origin of the destination coordinate system. Pages are indexed starting from one.
Returns
  • Converted point in page space.

public double[] convScreenPtToPagePt (double x, double y)

Converts a point expressed in screen space to a point on a page space.

Note: For space details, please refer to convScreenPtToCanvasPt(double, double).

Parameters
x x coordinate of the input point
y y coordinate in the input point
Returns
  • Converted point in page space.

public void destroy ()

Should be called in android.app.Activity.onDestroy() to destroy PDFViewCtrl and clean up memory and used resources.

public void docLock (boolean cancel_rendering)

Locks the PDFDoc instance used by PDFViewCtrl.

Simultaneous access to a PDFDoc instance is not allowed. Since PDFViewCtrl renders a PDFDoc in a rendering thread, UI access to the same PDFDoc instance should lock the document first and then unlock docUnlock() it afterwards. Threads attempting to access the document will wait in suspended state until the thread that owns the lock calls docUnlock().

Parameters
cancel_rendering If true, rendering thread is canceled first before trying to lock the document. This ensures a quick return from this function. Otherwise, this function can halt the UI and the app may be unresponsive before the rendering thread finishes. If the rendering thread is canceled, unlocking the document docUnlock() will restart the rendering thread.
Throws
PDFNetException PDFNet exception

public void docLockRead ()

Locks the PDFDoc instance used by PDFViewCtrl for reading.

Locks the the currently open document to prevent competing write threads (using docLock(boolean)) from accessing the document at the same time. Other reader threads however, will be allowed to access the document. Threads attempting to obtain write access to the document will wait in suspended state until the thread that owns the lock calls docUnlockRead().

Note: To avoid deadlocks obtaining a write lock while holding a read lock is not permitted and will throw an exception. If this situation is encountered please either unlock the read lock before the write lock is obtained or acquire a write lock (rather than read lock) in the first place.

Throws
PDFNetException PDFNet exception

public boolean docTryLock (int milliseconds)

Try acquiring a write lock on the currently open document, waiting no longer than specified number of milliseconds.

Returns
  • true if the lock was successfully acquired, false otherwise.
Throws
PDFNetException PDFNet exception

public boolean docTryLockRead (int milliseconds)

Try acquiring a read lock on the current document, waiting no longer than specified number of milliseconds.

Returns
  • true if the document is locked for multi-threaded access, false otherwise.
Throws
PDFNetException PDFNet exception

public boolean docUnlock ()

Unlocks the PDFDoc instance used by PDFViewCtrl and restarts the rendering thread if it was canceled by calling docLock(boolean).

public boolean docUnlockRead ()

Removes the read lock from the PDFDoc instance used by PDFViewCtrl.

public void enableAnnotationLayer ()

Enable separate rendering layer for annotations. Once enabled, can no longer disable in the same session.

public ExternalAnnotManager enableExternalAnnotManager (String author_name)

public void enableUndoRedo ()

Enable Undo/Redo in this PDFview.

Note: Undo/Redo works only if the document is saved incrementally (refer to save(Filter, long) for example)

Throws
PDFNetException PDFNet exception

public void executeAction (ActionParameter action_param)

Executes the action.

public void executeAction (Action action)

Executes the action.

public void findText (String search_str, boolean match_case, boolean match_whole_word, boolean search_up, boolean reg_exp, int page_num)

Searches asynchronously, starting from the current page, for the given text. PDFViewCtrl automatically scrolls to the position so that the found text is visible. Note that users can retrieve the geometric information of the found text from PDFViewCtrl.Selection for highlighting in PDFViewCtrl and other purposes.

Since the search is done asynchronously, the user must use the TextSearchListener to listen for search events. Even if the listener is null, upon completion PDFViewCtrl will still scroll to the position where the text was found. The listener can be set using setTextSearchListener(TextSearchListener).

Calling this function again will automatically cancels any ongoing text search thread and searches from the previous location. This method also automatically wraps around the document.

Note: This method should be called in UI thread.

Parameters
search_str the text to search for
match_case indicates if it is case sensitive
match_whole_word indicates if it matches an entire word only
search_up indicates if it searches upward
reg_exp indicates if it uses regular expressions. For more details about the regular expression syntax, please refer to Regular Expression Syntax.
page_num indicates the page to start searching on

public void findText (String search_str, boolean match_case, boolean match_whole_word, boolean search_up, boolean reg_exp)

Searches asynchronously, starting from the current page, for the given text. PDFViewCtrl automatically scrolls to the position so that the found text is visible. Note that users can retrieve the geometric information of the found text from PDFViewCtrl.Selection for highlighting in PDFViewCtrl and other purposes.

Since the search is done asynchronously, the user must use the TextSearchListener to listen for search events. Even if the listener is null, upon completion PDFViewCtrl will still scroll to the position where the text was found. The listener can be set using setTextSearchListener(TextSearchListener).

Calling this function again will automatically cancels any ongoing text search thread and searches from the previous location. This method also automatically wraps around the document.

Note: This method should be called in UI thread.

Parameters
search_str the text to search for
match_case indicates if it is case sensitive
match_whole_word indicates if it matches an entire word only
search_up indicates if it searches upward
reg_exp indicates if it uses regular expressions. For more details about the regular expression syntax, please refer to Regular Expression Syntax.

public long[] getAllCanvasPixelSizes ()

Returns the size of the scrollable spaces for all canvases. for N canvases, returns a vector of 3*N numbers in the form [canvas_id_1, width_1, height_1 ... canvas_id_N, width_N, height_N]

public int getAnnotTypeUnder (double x, double y)

Gets annotation type at the given point

Parameters
x x coordinate of the input point
y y coordinate in the input point
Returns
  • annotation type

public Annot getAnnotationAt (int x, int y)

Gets the annotation at the (x, y) position expressed in screen coordinates.

Note: For details about screen space, please refer to convScreenPtToCanvasPt(double, double).

Parameters
x x coordinate of the screen point
y y coordinate of the screen point
Returns
  • The annotation found. If no annotation was found, it returns a null pointer.

public Annot getAnnotationAt (int x, int y, double distanceThreshold, double minimumLineWeight)

Gets the annotation at the (x, y) position expressed in screen coordinates.

Parameters
x x coordinate of the screen point
y y coordinate of the screen point
distanceThreshold Maximum distance from the point (x, y) to the annotation for the annot to be considered a hit (in dp).
minimumLineWeight For very thin lines, it is almost impossible to hit the actual line. This specifies a minimum line thickness (in screen coordinates) for the purpose of calculating whether a point is inside the annotation or not (in dp).
Returns
  • The annotation closest to the point. If no annotation was found, it returns a null pointer.

public ArrayList<Annot> getAnnotationListAt (int x1, int y1, int x2, int y2)

Gets the list of annotations at line (x1, y1, x2, y2) expressed in screen coordinates

Parameters
x1 x coordinate of the screen point at one of the end points of the line
y1 y coordinate of the screen point at one of the end points of the line
x2 x coordinate of the screen point at another end point of the line
y2 y coordinate of the screen point at another end point of the line
Returns
  • the list of annotations at line (x1, y1, x2, y2).

public CurvePainter getAnnotationPainter (int page_num, long annot_key)

public ArrayList<Annot> getAnnotationsOnPage (int page_num)

Gets the list of annotations on a given page.

Parameters
page_num The page number, where 1 is the first page.
Returns
  • the list of annotations on a given page.

public double getCanvasHeight ()

Returns the height of Zoomed PDF Canvas Space. For more details, please refer to the documentation of convScreenPtToCanvasPt(double, double).

public double getCanvasWidth ()

Returns the width of Zoomed PDF Canvas Space. For more details, please refer to the documentation of convScreenPtToCanvasPt(double, double).

public int getClientBackgroundColor ()

Gets the background color of the client area.

Returns
  • the background color

public int getColorPostProcessMode ()

Returns
  • the current color post processing mode.

public void getContentSize (int[] size)

Gets the size of the actual content in the current canvas meaning all pages, as well as gaps and padding set by setPageSpacing

Parameters
size - returns with at index 0 and height at index 1

public int getCurCanvasId ()

public PointF getCurrentMousePosition ()

public int getCurrentPage ()

Gets the current page number.

Note: Page number starts from 1.

public Matrix2D getDeviceTransform (int page_num)

Gets the device transformation matrix.

Parameters
page_num the page number for the page used as the origin of the destination coordinate system. Pages are indexed starting from one.
Returns
  • the device transformation matrix. The device transformation matrix maps the page coordinate system to screen (or device) coordinate system.

public Matrix2D getDeviceTransform ()

Gets the device transformation matrix.

Note: To obtain a transformation matrix that maps screen coordinates to page coordinates, you can invert the device matrix. For example:

 Matrix2D scr2page(pdfView.getDeviceTransform());
 scr2page.inverse();
 
 

Returns
  • the device transformation matrix. The device transformation matrix maps the page coordinate system to screen (or device) coordinate system.

public boolean getDirectionalLockEnabled ()

public int getDisplayCutoutBottom ()

Gets the bottom display cutout height

public int getDisplayCutoutTop ()

Gets the top display cutout height

public PDFDoc getDoc ()

Gets the current PDF document.

public ExternalAnnotManager getExternalAnnotManager ()

Gets the external annot manager belonging to this PDFViewCtrl

Throws
PDFNetException PDFNet Exception
NullPointerException

public int getHScrollPos ()

Gets the current horizontal scroll position. The returned value is expressed in the canvas coordinate system.

Note: This call is the same as View.getScrollX() if maintain zoom feature is disabled, otherwise, is the scroll offset within the current canvas

Returns
  • the current horizontal scroll position

public PDFViewCtrl.LinkInfo getLinkAt (int x, int y)

Gets the link info at a given point, specified in screen space.

Note: To get valid links, setUrlExtraction(boolean) must be set to true before opening the document.

Parameters
x the x position in screen space
y the y position in screen space
Returns
  • the PDFViewCtrl.LinkInfo object with the link information or null if no link is found in the queried location.

public boolean getLongPressEnabled ()

Gets if PdfViewCtrl can read long press event

Returns
  • true if PdfViewCtrl can read long press event, false otherwise

public String getNextRedoInfo ()

Returns any meta-data associated with the next sate in the undo/redo chain.

Returns
  • meta-data associated with the next sate in the undo/redo chain.
Throws
PDFNetException PDFNet exception

public String getNextUndoInfo ()

Returns any meta-data associated with the previous sate in the undo/redo chain.

Returns
  • meta-data associated with the previous sate in the undo/redo chain.
Throws
PDFNetException PDFNet exception

public Context getOCGContext ()

Gets the OCG context.

Returns
  • the Optional Content Group (OCG) context associated with this PDFViewCtrl, or null if there is no OCG context associated with the view. If there is an OCG context associated with the view, optional content (such as PDF layers) will be selectively rendered based on the states of optional content groups in the given context.
Throws
PDFNetException PDFNet exception

public int getPageBox ()

Gets the box used by PDFViewCtrl for rasterizing.

Returns
  • the page box used to rasterize. See setPageBox(int) for more information on the return values.

public int getPageCount ()

Gets the page count.

NOTE: call PDFDoc.getPageCount() instead if any document pages are changed and updatePageLayout has not yet been called

Returns
  • the total number of pages in the document.

public int getPageNumberFromScreenPt (double x, double y)

Gets the number of the page on which the specified point in screen space.

Note: For space details, please refer to convScreenPtToCanvasPt(double, double).

Parameters
x x coordinate of the input point
y y coordinate of the input point
Returns
  • the page number

public PDFViewCtrl.PagePresentationMode getPagePresentationMode ()

Gets the current page presentation mode.

Returns

public Rect getPageRectForAnnot (Annot annot, int page_num)

Gets the annotation bounding box in page coordinates

Parameters
annot target annotation
page_num the page number where the annotation is on
Returns
  • The page rect for annotation

public PDFViewCtrl.PageViewMode getPageRefViewMode ()

Gets the reference page view mode. See more details about reference page view mode in setPageRefViewMode(PageViewMode).

public int getPageRotation ()

Gets the current rotation applied to all pages in PDFViewCtrl.

Returns

public Matrix getPageSlidingCanvasTransform ()

Gets the extra transformation matrix applied to the android.graphics.Canvas object used by PDFViewCtrl during page sliding.

Note: This matrix is normally identity except that when the built-in page sliding is in process. If it is desirable to draw contents that do not move during the sliding process, the inverse of this matrix can be temporarily applied to the Canvas to offset its effect.

Returns
  • the transformation matrix

public PDFViewCtrl.PageViewMode getPageViewMode ()

Gets the current page viewing mode.

Returns

public ColorPt getPostProcessedColor (ColorPt cp)

Convert a color based on the defined post processing transformation in setColorPostProcessMapFile(Filter).

Parameters
cp the color to be converted
Returns
  • the output color after applying post processing transformation on the input color

public PDFViewCtrl.PageViewMode getPreferredViewMode ()

Gets the preferred view mode when maintain zoom level is enabled

public boolean getProgressiveRendering ()

Checks if progressive rendering is used.

public boolean getRightToLeftLanguage ()

Checks if PDFViewCtrl thinks the content in the viewed PDF document reads from right to left.

public Rect getScreenRectForAnnot (Annot annot, int page_num)

Gets the annotation bounding box in screen coordinates

Parameters
annot target annotation
page_num the page number where the annotation is on
Returns
  • The screen rect for annotation

public int getScrollOffsetForCanvasId (int canvasId)

public int getScrollXOffsetInTools (int pageNum)

public int getScrollYOffsetInTools (int pageNum)

public PDFViewCtrl.Selection getSelection (int page)

Gets the text PDFViewCtrl.Selection on a given page.

Parameters
page the number of the given page
Returns
  • the current text selection for the given page

public int getSelectionBeginPage ()

Returns the first page number that has text PDFViewCtrl.Selection on it. Useful when there are selections on multiple pages at the same time.

public int getSelectionEndPage ()

Returns the last page number that has text PDFViewCtrl.Selection on it. Useful when there are selections on multiple pages at the same time.

public int getSlidingScrollY ()

public void getThumbAsync (int page_num)

This will request a thumbnail for the given page number.

When the thumbnail is ready, the onThumbReceived(int, int[], int, int) event will be raised with the finished thumbnail. If multiple requests are made, the thumbnail requests will be processed starting with the last request. The exception is that the current thumbnail being rendered will always finish.

It is recommended to cancel all thumbnail requests once they are not needed any more, using cancelAllThumbRequests().

If caching is enabled, this request will be much faster once the thumb has been rendered once. You can enable caching by using setViewerCache(com.pdftron.sdf.SDFDoc, int, boolean) and setDefaultDiskCachingEnabled(boolean).

Parameters
page_num the page which we want to receive a thumbnail for

public PDFViewCtrl.ToolManager getToolManager ()

Gets the PDFViewCtrl.ToolManager instance used by PDFViewCtrl. By default, there is no tool manager used by PDFViewCtrl.

public int getVScrollPos ()

Gets the current vertical scroll position. The returned value is expressed in the canvas coordinate system.

Note: This call is the same as View.getScrollY() if maintain zoom feature is disabled, otherwise, is the scroll offset within the current canvas

Returns
  • the current vertical scroll position

public int getViewCanvasHeight ()

Returns the height of PDFViewCtrl Canvas space. For more details, please refer to the documentation of convScreenPtToCanvasPt(double, double).

public int getViewCanvasWidth ()

Returns the width of PDFViewCtrl Canvas space. For more details, please refer to the documentation of convScreenPtToCanvasPt(double, double).

public int[] getVisiblePages ()

Gets an array with the pages currently visible on the screen.

Returns
  • an array of the pages currently visible on the screen.

public int[] getVisiblePagesInTransition ()

Gets an array with the pages currently visible on the screen. While in horizontal page sliding mode, this method will also return the adjacent pages.

Returns
  • an array with the pages currently visible on the screen including adjacent pages.

public double getZoom ()

Gets the current zoom factor.

public boolean getZoomEnabled ()

public double getZoomForViewMode (PDFViewCtrl.PageViewMode viewMode)

Calculates the zoom for the current view if it was currently in the view mode set by setPageViewMode(PageViewMode) with viewMode

Parameters
viewMode The reference page view mode to set.
Returns
Throws
PDFNetException PDFNet exception

public boolean gotoFirstPage ()

Sets the current page to the first page.

Returns
  • true if successful, false otherwise.

public boolean gotoLastPage ()

Sets the current page to the last page.

Returns
  • true if successful, false otherwise.

public void gotoNextPage (boolean animation)

public boolean gotoNextPage ()

Sets the current page to the next page.

Returns
  • true if successful, false otherwise.

public boolean gotoPreviousPage ()

Sets the current page to the previous page.

Returns
  • true if successful, false otherwise.

public void gotoPreviousPage (boolean animation)

public boolean hasSelection ()

Checks if there is any text PDFViewCtrl.Selection.

Returns
  • true if there is selection, false otherwise.

public boolean hasSelectionOnPage (int page)

Checks if there is any text PDFViewCtrl.Selection on a given page.

Parameters
page the page number of the given page
Returns
  • true if the given page has any text selection on it.

public void hideAnnotation (Annot annot)

Disable rendering of a particular annotation. This does not change the annotation itself, just how it is displayed in this viewer instance.

Parameters
annot The annotation object to cease drawing for.

public boolean isAnnotationLayerEnabled ()

public boolean isContinuousPagePresentationMode (PDFViewCtrl.PagePresentationMode mode)

Utility function that checks if the page presentation mode is continuous.

public boolean isCurrentSlidingCanvas (int pageNum)

public boolean isFacingPagePresentationMode (PDFViewCtrl.PagePresentationMode mode)

Utility function that checks if the page presentation mode is facing.

public boolean isFinishedRendering (boolean visible_region_only)

Checks if the rendering thread finishes or the current visible region has been fully rendered.

Note: Since PDFViewCtrl might pre-render invisible regions, the rendering thread might still be ongoing even if the current visible region has been rendered. If visible_region_only parameter is set to true, this function only checks if the visible region has been rendered, regardless if the rendering thread is ongoing.

public boolean isFinishedRendering ()

Checks if the rendering thread has finished.

public boolean isHardwareAccelerated ()

Checks if PDFViewCtrl is hardware accelerated.

public boolean isMaintainZoomEnabled ()

public boolean isSlidingWhileZoomed ()

Gets whether the viewer is currently in horizontal page transition mode while the current canvas is zoomed in before the sliding happens

Returns
  • whether sliding while zoomed

public boolean isThereTextInRect (double x1, double y1, double x2, double y2)

Checks if in the given region there is any text. Point (x1, y1) is the start selection point and point (x2, y2) is the end selection point. The points are defined in screen space.

Returns
  • true if there is a text in the given rectangle, false otherwise

public boolean isUndoRedoEnabled ()

Returns
  • true if undo/redo is enabled in PDFView; false otherwise

public boolean isZoomingInAddingAnnotationEnabled ()

public Rect jumpToAnnotWithID (String annotId)

Parameters
annotId the annotation id to jump to
Returns
  • screen rect if success

public void onConfigurationChanged (Configuration newConfig)

Call this method to trigger the Tools' onConfigurationChanged event.

Parameters
newConfig the new device configuration

public boolean onGenericMotionEvent (MotionEvent event)

The overloaded implementation of onGenericMotionEvent(MotionEvent).

public boolean onKeyUp (int keyCode, KeyEvent event)

Notified when a key was released.

Parameters
keyCode A key code that represents the button pressed, from android.view.KeyEvent.
event The KeyEvent object that defines the button action.
Returns
  • Return true to prevent this event from being propagated further, or false to indicate that you have not handled this event and it should continue to be propagated.

public boolean onTouchEvent (MotionEvent event)

The overloaded implementation of android.view.onTouchEvent().

public DocumentConversion openNonPDFUri (Uri fileUri, ConversionOptions options)

Utility function for opening a non-PDF document for display.

Parameters
fileUri the file uri, can be a content uri, or a storage file uri
options conversion options
Returns
Throws
FileNotFoundException
PDFNetException

public PDFDoc openPDFUri (Uri fileUri, String password, String cachePath, PDFViewCtrl.HTTPRequestOptions httpRequestOptions)

Utility function for opening a PDF document for display.

Parameters
fileUri the file uri, can be a content uri, a storage file uri or HTTP/HTTPS link
password the file password
cachePath the cache location if file is opened with HTTP/HTTPS link
httpRequestOptions the PDFViewCtrl.HTTPRequestOptions if file is opened with HTTP/HTTPS link
Returns
  • null if opened from HTTP/HTTPS URL; return PDFDoc if successfully opened the PDF from File or Content URI
Throws
PDFNetException PDFNet exception
FileNotFoundException File not found exception

public PDFDoc openPDFUri (Uri fileUri, String password)

Utility function for opening a PDF document for display. Use openPDFUri(Uri, String, String, HTTPRequestOptions) if you need to cache file opened with HTTP/HTTPS link

Parameters
fileUri the file uri, can be a content uri, a storage file uri or HTTP/HTTPS link
password the file password
Returns
  • null if opened from HTTP/HTTPS URL; return PDFDoc if successfully opened the PDF from File or Content URI
Throws
PDFNetException PDFNet exception
FileNotFoundException File not found exception

public void openUniversalDocument (DocumentConversion conversion)

Sets the PDF document to be displayed.

Note: This method acquires a write lock on the current document, so the document must be unlocked when this method is called or an exception will be thrown.

public void openUrlAsync (String url, String cachePdf, String password, PDFViewCtrl.HTTPRequestOptions options)

Sets the PDF document, from a URL, that is to be displayed. If successful, PDFViewCtrl will download the PDF document and display it. If the PDF file is linearized, PDFViewCtrl will download it incrementally while displaying it; otherwise, PDFViewCtrl will show blank pages until the entire document is downloaded.

Since this function starts the actual download work in a worker thread, it returns quickly to avoid blocking UI. addDocumentDownloadListener(DocumentDownloadListener) can be used to listen to the download result, e.g., FAILED.

Note:

Parameters
url the URL of the document to open. It supports HTTP and HTTPS.
cachePdf This function will use downloaded data to construct a PDF in this location. If null or blank, the PDF will be stored in a temporary location. If the path points to the result of a previous call to this function for this particular URL, then PDFViewCtrl will resume that download. This should be a full (non-relative) path.

Note that if disk caching is disabled this file will not be used.

password the password used to open the document
options HTTP request options to use with every HTTP request, may be null

public void pause ()

Should be called in android.app.Activity.onPause() to pause PDFViewCtrl.

Note: This method simply stops the current ongoing rendering thread, text search thread, and tool.

public void postCustomEvent (Object obj)

Posts a message to cause onCustomEvent(Object) to be called in the next main message loop. This is useful if a Tool needs to be called by PDFViewCtrl in the main message loop without a touch event being triggered.

Parameters
obj An Object that can be passed back in onCustomEvent(Object) function.

public void prepareAnnotsForMouse (int pageNum, double distanceThreshold, double minimumLineWeight)

Requests for preparing annotations of the given page.

Note: Annotations are going to be prepared asynchronously

Parameters
pageNum page number
distanceThreshold Maximum distance from the point (x, y) to the annotation for the annot to be considered a hit (in dp). see getAnnotationAt(int, int, double, double)
minimumLineWeight For very thin lines, it is almost impossible to hit the actual line. This specifies a minimum line thickness (in screen coordinates) for the purpose of calculating whether a point is inside the annotation or not (in dp). see getAnnotationAt(int, int, double, double)

public void prepareAnnotsForMouse (int pageNum)

Requests for preparing annotations of the given page.

Note: Annotations are going to be prepared asynchronously

Parameters
pageNum page number

public void prepareWords (int pageNum)

Requests for preparing words of the given page.

Note: Words are going to be prepared asynchronously

Parameters
pageNum page number

public void purgeMemory ()

Call this method to lower PDFViewCtrl's memory consumption, such as in Activity.onLowMemory().

Note that onLowMemory() is called when a user is running too many applications and the OS needs to recover the memory from them. Exceeding your own application's VM heap quota does NOT cause onLowMemory() to be called. For this sake, it is a good practice in your code to catch OutOfMemoryError exception and then call this method.

public void purgeMemoryDueToOOM ()

it is a good practice in your code to catch OutOfMemoryError exception and then call this method.

public String redo ()

Go to the next state in the undo/redo chain. Returns any meta-data associated with that state.

Returns
  • meta-data associated with the current state in the undo/redo chain after redoing one state.
Throws
PDFNetException PDFNet exception

public void refreshAndUpdate (ViewChangeCollection view_change)

Helper function that will refresh annotation and/or field appearances if needed, and then render modified page areas, all based on the contents of the view_change parameter.

Parameters
view_change contains all the updated fields and rectangles.
Throws
PDFNetException PDFNet exception

public void removeDocumentDownloadListener (PDFViewCtrl.DocumentDownloadListener listener)

Removes the document download listener.

public void removeDocumentLoadListener (PDFViewCtrl.DocumentLoadListener listener)

Removes the document load listener.

public void removeOnCanvasSizeChangeListener (PDFViewCtrl.OnCanvasSizeChangeListener listener)

Removes the canvas size change listener.

public void removePageChangeListener (PDFViewCtrl.PageChangeListener listener)

Remove Page change listener

Parameters
listener listener

public void removeThumbAsyncListener (PDFViewCtrl.ThumbAsyncListener listener)

Removes thumb async listener.

public void removeUniversalDocumentConversionListener (PDFViewCtrl.UniversalDocumentConversionListener listener)

Removes the document conversion listener

public void requestLayout ()

Overloaded version of android.view.View.requestLayout(). Call this when something has changed which has invalidated the layout of this view. This will schedule a layout pass of the view tree.

public void requestRendering ()

Requests that PDFViewCtrl start rendering, if necessary.

Note: invalidate() simply causes the window to be repainted at the system level. It does not make PDFViewCtrl to render anything new. requestRendering() tells PDFViewCtrl to check if there are regions (both visible and invisible) that have not been rendered; if so a background rendering thread will be started. This function should be called if cancelRendering() was called to stop the ongoing rendering thread. update() tells PDFViewCtrl to discard the rendered content and start a rendering thread. This function should be used if the content of the PDF is modified.

public void resume ()

Should be called in android.app.Activity.onResume() to resume PDFViewCtrl.

Note: This method simply starts the rendering thread to ensure the PDF content is available for viewing.

public void revertAllChanges ()

Returns to the initial state in the undo/redo chain

Throws
PDFNetException PDFNet exception

public void rotateClockwise ()

Rotates all pages in the document 90 degrees clockwise.

Note: After calling this method you must also update the page layout. See updatePageLayout() for more information.

public void rotateCounterClockwise ()

Rotates all pages in the document 90 degrees counter-clockwise.

Note: After calling this method you must also update the page layout. See updatePageLayout() for more information.

public void scrollBy (int dx, int dy)

Overloaded implementation of android.view.View.scrollBy(). It moves the scroll position of PDFViewCtrl, if it is in a continuous page presentation mode.

Parameters
dx the amount of pixels to scroll by horizontally
dy the amount of pixels to scroll by vertically

public void scrollTo (int x, int y)

Overloaded implementation of android.view.View.scrollTo(). It sets the scroll position of PDFViewCtrl, if it is in a continuous page presentation mode.

Parameters
x the x position to scroll to.
y the y position to scroll to.

public boolean select (double x1, double y1, double x2, double y2)

Selects text within the given region using the current text selection mode. Point (x1, y1) is the start selection point and point (x2, y2) is the end selection point. The points are defined in screen space.

Returns
  • true if some text was selected, false otherwise.

public boolean select (double x1, double y1, int page1, double x2, double y2, int page2)

Selects text using structural mode. Point (x1, y1) is the start selection point on page 'page1' and point (x2, y2) is the end selection point on page 'page2'.

Returns
  • true if some text was selected, false otherwise.

public void selectAll ()

Selects all the text in the document.

public boolean selectAndJumpWithHighlights (Highlights highlights)

Selects texts identified by Highlights. Also scroll to the Highlights if selected.

Parameters
highlights the Highlights to be selected
Returns
  • true if some text was selected, false otherwise.

public boolean selectByRect (double x1, double y1, double x2, double y2)

Selects text within the given region using rectangular selection mode. Point (x1, y1) is the start selection point and point (x2, y2) is the end selection point. The points are defined in screen space.

Returns
  • true if some text was selected, false otherwise.

public boolean selectByStructWithSmartSnapping (double x1, double y1, double x2, double y2)

Selects text within the given region using structural text selection mode and with smart snapping. Point (x1, y1) is the start selection point and point (x2, y2) is the end selection point. The points are defined in screen space.

Note: The internal state of text selection having snapping information is cleared when calling #ClearSelection(long)

Returns
  • true if some text was selected, false otherwise.

public boolean selectByStructWithSnapping (double x1, double y1, double x2, double y2, boolean snap_to_start, boolean snap_to_end)

Selects text within the given region using the current text selection mode with defined snap-to-start and snap-to-end modes.

Parameters
x1 two points (screen coordinates, origin located at the upper-left corner of this view)
y1 two points (screen coordinates, origin located at the upper-left corner of this view)
x2 two points (screen coordinates, origin located at the upper-left corner of this view)
y2 two points (screen coordinates, origin located at the upper-left corner of this view) defining the opposite corners of a selection rectangle.
snap_to_start if selected text should contain the whole word at start of selection points.
snap_to_end if selected text should contain the whole word at end of selection points.
Returns
  • true if some text was selected, false otherwise.

public boolean selectWithHighlights (Highlights highlights)

Selects texts identified by Highlights.

Parameters
highlights the Highlights to be selected
Returns
  • true if some text was selected, false otherwise.

public boolean selectWithSelection (PDFViewCtrl.Selection sel)

Selects texts identified by Selection.

Parameters
sel the Selection to be selected
Returns
  • true if some text was selected, false otherwise.

public void setActionCompletedListener (PDFViewCtrl.ActionCompletedListener listener)

Sets action completed listener.

public void setAntiAliasing (boolean enable_aa)

Enables or disables anti-aliasing. Anti-aliasing is enabled by default.

public void setBuiltInPageSlidingAnimationDuration (int animationDuration)

Sets the parameter of built-in page turning effect.

Parameters
animationDuration This parameter sets the total animation duration of a fling event. The default value is android.R.integer.config_longAnimTime.

public void setBuiltInPageSlidingEnabled (boolean enabled)

Enables or disables the built-in page turning animation effect (sliding) when it is under non-continuous page presentation mode (setPagePresentationMode(PagePresentationMode)). Page turning is triggered by fling and scroll events when the current page reaches its boundary.

public void setBuiltInPageSlidingState (boolean state)

Sets the current state of page slider.

Parameters
state true if sliding functionality is on, false otherwise. If page sliding is not enabled through setBuiltInPageSlidingEnabled(boolean), this method will be no-op.

public void setBuiltInPageSlidingThreshSpeed (int fling_dp_per_second)

Sets the parameter of built-in page turning effect.

Parameters
fling_dp_per_second This parameter sets the lowest speed of a fling event, in device independent pixel per second, that could trigger the built-in page turning effect. The default value is 1000.

public void setBuiltInZoomAnimationDuration (int animationDuration)

Sets the parameter of zoom animation effect.

Parameters
animationDuration This parameter sets the total animation duration of a zoom event if animate is set to true. See smartZoom(int, int, boolean) , setZoom(int, int, double, boolean, boolean) and setPageViewMode(PageViewMode, int, int, boolean) The default value is android.R.integer.config_shortAnimTime.

public void setCaching (boolean enabled)

Enables or disables caching. When caching is enabled, PDFViewCtrl may store certain PDF contents, e.g., images, fonts, in memory for fast repeated accessing. By default, caching is disabled.

public void setClientBackgroundColor (int r, int g, int b, boolean transparent)

Sets the background color of the client area.

Parameters
r red component of the background color
g green component of the background color
b blue component of the background color
transparent if true, the client region is transparent

public void setColorPostProcessColors (int whiteColor, int blackColor)

Sets the color post processing transformation. This transform is applied to the rasterized bitmap as the final step in the rasterization process, and is applied directly to the resulting bitmap (disregarding any color space information). Color post processing only supported for RGBA output.

This mode will map the brightness of the original rasterized bitmap to a gradient between whiteColor and blackColor

Parameters
whiteColor the white color of page
blackColor the black color of page

public void setColorPostProcessMapFile (Filter image_file_contents)

Sets the color post processing transformation. This transform is applied to the rasterized bitmap as the final step in the rasterization process, and is applied directly to the resulting bitmap (disregarding any color space information). Color post processing only supported for RGBA output.

This mode will map the brightness of the original rasterized bitmap to a gradient in image_file_contents from left to right

Parameters
image_file_contents is a filter with image file contents

public void setColorPostProcessMode (int mode)

Sets the color post processing transformation. This transform is applied to the rasterized bitmap as the final step in the rasterization process, and is applied directly to the resulting bitmap (disregarding any color space information). Color post processing only supported for RGBA output.

Parameters
mode is the specific transform to be applied

public boolean setCurrentPage (int page_num)

Goes to the specified page.

Parameters
page_num specified page number
Returns
  • true if successful, false otherwise.

public void setDebug (boolean debug)

public void setDefaultPageColor (int c)

Sets the default 'paper' color used to draw background of each page.

Parameters
c the color

public void setDefaultPageColor (int r, int g, int b)

Sets the default 'paper' color used to draw background of each page.

Parameters
r red component of the color
g green component of the color
b blue component of the color

public void setDevicePixelDensity (double dpi, double scale_factor)

Sets device dpi

Parameters
dpi the device density
scale_factor the scale factor

public void setDirectionalLockEnabled (boolean enabled)

public void setDisplayCutout (int top, int bottom)

Sets the display cutout

Parameters
top the top cutout height
bottom the bottom cutout height

public void setDoc (PDFDoc doc)

Sets the PDF document to be displayed.

Note: This method acquires a write lock on the current document, so the document must be unlocked when this method is called or an exception will be thrown.

public void setDrawAnnotations (boolean render_annots)

Enables or disables annotation and forms rendering. By default, all annotations and form fields are rendered.

public void setErrorReportListener (PDFViewCtrl.ErrorReportListener listener)

Sets the error report listener.

public void setGamma (double exp)

Sets the gamma factor used for anti-aliased rendering.

Gamma correction can be used to improve the quality of anti-aliased image output and can (to some extent) decrease the appearance common anti-aliasing artifacts (such as pixel width lines between polygons).

Parameters
exp is the exponent value of gamma function. Typical values are in the range from 0.1 to 3.

public void setHScrollPos (int pos)

Sets the horizontal scroll position. The position should be a number in the range between 0 and getCanvasWidth(). The 'pos' parameter is expressed in the canvas coordinate system.

Note: This call is the same as View.setScrollX().

Parameters
pos the new horizontal scroll position

public void setHighlightFields (boolean highlight_fields)

Enable or disable highlighting form fields. Default is disabled.

Parameters
highlight_fields true to highlight, false otherwise.

public void setHorizontalAlign (int align)

Sets the horizontal alignment used for rendering pages within the view.

Parameters
align an integer specifying the horizontal alignment. Depending of whether align is positive, negative, or zero, pages will be right, left or center aligned:
  • align < 0:pages are left aligned
  • align == 0: pages are centered
  • align > 0: pages are right aligned

public void setImageSmoothing (boolean smoothing)

Sets if image smoothing is used. By default, image smoothing is disabled.

public void setInteractionEnabled (boolean enabled)

Enable or disable user input for PDFViewCtrl.

public void setLongPressEnabled (boolean enable)

Sets if pdfViewCtrl can dispatch long press event

Parameters
enable true to make pdfViewCtrl able to read long press event, false otherwise

public void setMaintainZoomEnabled (boolean enabled)

public void setMinimumRefZoomForMaximumZoomLimit (double required_zoom)

Sets the minimum ref zoom used for calculating the maximum zoom limit when using relative zoom limits. That is, if the reference zoom limit is less than required_zoom, then required_zoom will be used for the purposes of setting the max zoom limit.

Note: See note at setZoomLimits(ZoomLimitMode, double, double) for explanation of relative zoom limits.

Parameters
required_zoom The minimum ref zoom

public void setNextOnLayoutAdjustments (int extra_scroll_x, int extra_scroll_y, boolean animateZoomLimitsIfNecessary)

Adjusts the position of PDFViewCtrl content.

Parameters
extra_scroll_x Scroll by this amount in x direction after resizing of PDFViewCtrl
extra_scroll_y Scroll by this amount in y direction after resizing of PDFViewCtrl
animateZoomLimitsIfNecessary Whether to animate if zoom limit is hit

public void setOCGContext (Context ctx)

Sets the Optional Content Group (OCG) context that should be used when viewing the document. This function can be used to change the current OCG context. Optional content (such as PDF layers) will be selectively rendered based on the states of optional content groups in the given context.

Note: Unlike setOCGContext(com.pdftron.pdf.ocg.Context), this method copies the given context. As a result, in order to modify the state of OCG groups in the curent context use getOCGContext() to obtain the currently selected content and then modify states.

Parameters
ctx Optional Content Group (OCG) context, or null if the rasterizer should render all content on the page.
Throws
PDFNetException PDFNet exception

public void setOverprint (PDFViewCtrl.OverPrintMode overprint)

Enables or disables support for overprint. Overprint is a device dependent feature and the results will vary depending on the output color space and supported colorants (i.e. CMYK, CMYK+spot, RGB, etc). By default overprint is disabled for efficient viewing.

Parameters
overprint the overprint mode.

public void setPageBorderVisibility (boolean borderVisibility)

Enables or disables drawing of a thin border around each page.

Parameters
borderVisibility If true, the border will be visible.

public void setPageBox (int region)

Selects the PageBox to rasterize. PDFViewCtrl will clip pages according to their PageBox as selected here.

Parameters
region the region to be used for clipping. Possible values are:

public void setPagePresentationMode (PDFViewCtrl.PagePresentationMode mode)

Sets the page presentation mode.

Parameters
mode the new page presentation mode.

public void setPageRefViewMode (PDFViewCtrl.PageViewMode mode)

Sets the reference page view mode. In a non-continuous page presentation mode, the reference page view mode is used to determine the page view mode upon a page change event. For example, if the reference page view mode is set to FIT_WIDTH, the new page coming in will be displayed with width-fit mode. Default value is FIT_PAGE.

Parameters
mode The reference page view mode to set.

public void setPageSpacing (int horiz_col_space, int vert_col_space, int horiz_pad, int vert_pad)

Sets the padding for PDFViewCtrl, as well as vertical and horizontal padding and column spacing between adjacent pages in the view.

Parameters
horiz_col_space horizontal column spacing (represented in pixels) between adjacent pages in the view. Default is 3.
vert_col_space vertical column spacing (represented in pixels) between adjacent pages in the view. Default is 3.
horiz_pad horizontal padding (represented in pixels) on the left and right side of the view. Default is 0.
vert_pad vertical padding (represented in pixels) on the top and bottom side of the view. Default is 0.

public void setPageSpacingDP (int horiz_col_space, int vert_col_space, int horiz_pad, int vert_pad)

Sets the vertical and horizontal padding and column spacing between adjacent pages in the view.

Parameters
horiz_col_space horizontal column spacing (represented in DP) between adjacent pages in the view. Default is 3 pixels.
vert_col_space vertical column spacing (represented in DP) between adjacent pages in the view. Default is 3 pixels.
horiz_pad horizontal padding (represented in DP) on the left and right side of the view. Default is 0 pixels.
vert_pad vertical padding (represented in DP) on the top and bottom side of the view. Default is 0 pixels.

public void setPageTransparencyGrid (boolean trans_grid_visible)

Enables or disables the transparency grid (check board pattern) to reflect page transparency.

Parameters
trans_grid_visible if true, the grid is turned on.

public void setPageViewMode (PDFViewCtrl.PageViewMode mode)

Sets the page viewing mode. The page viewing mode takes effect when it is set, open a new document, or double click.

Note: If you call setPageViewMode(newMode) and the current mode is different than newMode, the control will trigger a request layout and you might see a flickering.

Parameters
mode the new page viewing mode.

public void setPageViewMode (PDFViewCtrl.PageViewMode mode, int x, int y, boolean animate)

public void setPathHinting (boolean path_hinting)

Enable or disable path hinting.

Parameters
path_hinting if true path hinting is enabled. Path hinting is used to slightly adjust paths in order to avoid or alleviate artifacts of hair line cracks between certain graphical elements. This option is turned on by default.

public void setPreferredViewMode (PDFViewCtrl.PageViewMode viewMode)

Sets the preferred view mode when maintain zoom level is enabled.

public void setProgressiveRendering (boolean progressive)

Enables or disables progressive rendering. By default, progressive rendering is enabled.

Parameters
progressive If true, progressive rendering is enabled; otherwise, it is disabled.

public void setProgressiveRendering (boolean progressive, int delay_ms, int interval_ms)

Enables or disables progressive rendering and sets the initial delay and interval in milliseconds. By default, progressive rendering is enabled, initial delay is 2000 ms and interval is 750 ms.

Parameters
progressive If true, progressive rendering is enabled; otherwise, it is disabled.
delay_ms The initial delay in milliseconds of starting progressive rendering. This might be desirable due to the use of thumb nail views. Only effective if progressive is true.
interval_ms The interval in milliseconds between two consecutive progressive updates. Only effective if progressive is true.

public void setRelativeZoomLimits (PDFViewCtrl.PageViewMode refViewMode, double min_zoom, double max_zoom)

Sets the minimum and maximum zoom bounds of PDFViewCtrl relative to ref_view_mode

Note: See note at setZoomLimits(ZoomLimitMode, double, double) for explanation of relative zoom limits.

Parameters
refViewMode The reference page view mode to set.
min_zoom the minimum zoom bound
max_zoom the maximum zoom bound

public void setRenderedContentCacheSize (long allowed_max)

Sets the suggested memory size of the rendered content.

PDFViewCtrl keeps invisible content in order to achieve smoother viewing experience; however, this increases memory usage. Android sets an upper bound on the VM heap size allowed for an app. By default, PDFViewCtrl is set to use a quarter of that amount for keeping visible and invisible content. Based on the memory footprint of your app, you may want to customize it.

The following code shows a sample usage of this function:

 long allowed_max = Runtime.getRuntime().maxMemory() / (1024 * 1024);
 setRenderedContentCacheSize((long) (allowed_max * 0.25)); //should NOT use close to allowed_max
 
 

Note: If you want to minimize the heap memory usage at the cost of viewing experience quality, you can set allowed_max to 0 and PDFViewCtrl will not keep any invisible content. Also note that this function only controls the memory usage of VM heap size by PDFViewCtrl, but not the native memory that PDFViewCtrl might use.

On Android 3.0 and above, you can increase the allowed heap size of an app by setting android:largeHeap="true" in the app's manifest file.

Parameters
allowed_max the allowed heap memory usage in MB

public void setRenderingListener (PDFViewCtrl.RenderingListener listener)

Sets the rendering listener.

public void setRightToLeftLanguage (boolean flag)

Tells PDFViewCtrl the content in the viewed PDF document reads from right to left.

public void setTextSearchListener (PDFViewCtrl.TextSearchListener listener)

Sets the text search listener.

public void setTextSelectionMode (PDFViewCtrl.TextSelectionMode mode)

Sets the selection mode used for text highlighting.

Parameters
mode the text selection mode.

public void setThinLineAdjustment (boolean pixel_grid_fit, boolean stroke_adjust)

Sets thin line adjustment parameters.

Parameters
pixel_grid_fit If true (horizontal/vertical) thin lines will be snapped to integer pixel positions. This helps make thin lines look sharper and clearer. This option is turned off by default and it only works if path hinting is enabled.
stroke_adjust If true auto stroke adjustment is enabled. Currently, this would make lines with sub-pixel width to be one-pixel wide. This option is turned on by default.

public void setToolManager (PDFViewCtrl.ToolManager mgr)

Sets the PDFViewCtrl.ToolManager instance used by PDFViewCtrl. By default, there is no tool manager used by PDFViewCtrl.

public void setUniversalDocumentProgressIndicatorListener (PDFViewCtrl.UniversalDocumentProgressIndicatorListener listener)

Sets the Universal Document progress listener

public void setUrlExtraction (boolean enabled)

Enables or disables URL extraction. By default URL extraction is disabled.

Note: If set to enabled when the document is already opened, it may not find links on pages that were already rendered. It is suggested to set this flag before opening the document.

Parameters
enabled if true, URL extraction is enabled; false otherwise.

public void setVScrollPos (int pos)

Sets the vertical scroll position. The position should be a number in the range between 0 and getCanvasHeight(). The 'pos' parameter is expressed in the canvas coordinate system.

Note: This call is the same as View.setScrollY().

Parameters
pos the new vertical scroll position

public void setVerticalAlign (int align)

Sets the vertical alignment used for rendering pages within the view.

Parameters
align an integer specifying the vertical alignment. Depending of whether align is positive, negative, or zero, pages will be bottom, top or center aligned:
  • align < 0: pages are top aligned
  • align == 0: pages are centered
  • align > 0: pages are bottom aligned

public static void setViewerCache (SDFDoc document, int max_cache_size, boolean on_disk)

Sets the cache parameters of the page cache on disk (which caches content streams and mipmapped images) for this specific document. These parameters will override the default cache parameters set by PDFNet.setViewerCache(). Note that if this function is called after the document has been rasterized, it has no effect.

Note: Setting max_cache_size to zero will disable the cache. Also, once this cache is used, setCaching(boolean) will be ineffective.

Parameters
max_cache_size The maximum size, in bytes, of the entire document's page cache. The maximum cache size is 100 MB.
on_disk Whether or not store the cache on disk.
Throws
PDFNetException PDFNet exception

public boolean setZoom (double zoom)

Sets the zoom factor and re-render. This function zooms to the center of the screen region.

Note: This function is similar to setZoom(double, boolean), but with the second parameter being false.

Parameters
zoom New zoom factor used to display the page content.
Returns
  • true if successful, false otherwise.

public boolean setZoom (double zoom, boolean use_snapshot)

Sets the zoom factor and re-render. This function zooms to the center of the screen region.

Parameters
zoom New zoom factor used to display the page content.
use_snapshot If true, PDFViewCtrl takes a snapshot of the current client area and shows it before the content after zooming is ready.
Returns
  • true if successful, false otherwise.

public boolean setZoom (int x, int y, double zoom)

Sets the zoom factor and re-render using the given coordinate (x,y) as a zoom center.

The zoom center (x,y) is represented in the screen space, whose origin is at the upper-left corner of the screen region.

Note: This function is similar to setZoom(int, int, double, boolean), but with the last parameter being false.

Parameters
x The horizontal coordinate of the center in screen space.
y The vertical coordinate of the center in screen space.
zoom New zoom factor used to display the page content.
Returns
  • true if successful, false otherwise.

public boolean setZoom (int x, int y, double zoom, boolean use_snapshot)

Sets the zoom factor and re-render using the given coordinate (x,y) as a zoom center.

The zoom center (x,y) is represented in the screen space, whose origin is at the upper-left corner of the screen region.

Parameters
x The horizontal coordinate of the center in screen space.
y The vertical coordinate of the center in screen space.
zoom New zoom factor used to display the page content.
use_snapshot If true, PDFViewCtrl takes a snapshot of the current client area and shows it before the content after zooming is ready.
Returns
  • true if successful, false otherwise.

public boolean setZoom (int x, int y, double zoom, boolean use_snapshot, boolean animate)

public void setZoomEnabled (boolean enable)

public void setZoomLimits (PDFViewCtrl.ZoomLimitMode zoomLimitMode, double min_zoom, double max_zoom)

Sets the minimum and maximum zoom bounds of PDFViewCtrl.

Note: If RELATIVE is used, min_zoom and max_zoom are relative to the zoom level when the current page is displayed in the mode set by setPageRefViewMode(PageViewMode). For instance, if min_zoom = 1.0 and max_zoom = 3, it means that the minimum zoom allowed by PDFViewCtrl is the same as the zoom when a page is fit and the maximum zoom allowed is three times that when the page is fit. PDFViewCtrl limits the minimum zoom bound to 0.01 and the maximum zoom bound to 500.0.

Parameters
zoomLimitMode Defines how the minimum and maximum zoom bounds are used.
min_zoom the minimum zoom bound
max_zoom the maximum zoom bound

public void setZoomingInAddingAnnotationEnabled (boolean enabled)

public void setupThumbnails (boolean use_embedded, boolean generate_at_runtime, boolean use_disk_cache, int thumb_max_side_length, long max_abs_cache_size, double max_perc_cache_size)

Specify the different thumbnail settings for the viewer.

Thumbnail view is used before a PDF page is fully rendered. If generate_at_runtime is enabled, PDFViewCtrl generates thumbnail views at runtime. If a PDF file already contains the thumbnail views, runtime thumb view generation can be turned off, which is more efficient.

If generate_at_runtime is enabled, the thumb_max_side_length will be used as a reference to calculate the thumbnail resolution.

Note: High values of thumb_max_side_length will require more heap memory from the VM, and this can lead to some 'out of memory exceptions' due to the nature of the core and how bitmaps are natively managed by Android. You may want to configure your application to use a larger heap in the manifest file if you need to push this setting to higher values.

Parameters
use_embedded Enables or disables using thumbnails embedded in the PDF document as a preview of the rendered page. Default is enabled.
generate_at_runtime Enables or disables generating thumbnails at runtime. Default is enabled.
use_disk_cache Enables or disables caching thumbnails in a temporary disk file. Default is disabled.
thumb_max_side_length The maximum size, in pixels, of a dimension of generated thumbnails. Pass zero to use the default internal value. Default value is 0.
max_abs_cache_size The absolute maximum size on disk, in bytes, for the temporary thumbnail cache. Default value is 200 MB.
max_perc_cache_size The maximum percentage of free disk space, in the range 0 - 1.0, that the cache can take up. Default is 0.4 (40%).

public void showAnnotation (Annot annot)

Enable rendering of a particular annotation. Only has an effect if HideAnnotation() has previously been called on the same annot.

Parameters
annot The annotation object to resume rendering.

public boolean showRect (int page_num, Rect rect)

Adjusts the viewing area to fit a rectangle on a specified page. Rectangle must be specified in page space. This will adjust current page and zoom appropriately.

Parameters
page_num specified page number
rect the rectangle to fit in
Returns
  • true if successful, false otherwise.

public boolean smartZoom (int x, int y, boolean animate)

public boolean smartZoom (int x, int y)

Sets the zoom factor to a new value using the given pixel coordinate (x,y) to find an intersecting paragraph.

The width of the paragraph helps to determine the zoom value, center of the paragraph is used as a zoom center. Paragraph has to contain more than one line and be wider than 1/5th of a page width. When performing a smart zoom would not significantly change the zoom level, it will be ignored.

The zoom center (x,y) is represented in the screen space, whose origin is at the upper-left corner of the screen region.

Parameters
x the horizontal coordinate to look for a text block.
y the vertical coordinate to look for a text block.
Returns
  • true if successful, false if no zoom was performed.

public PointF snapToNearestInDoc (double x, double y)

Returns the point within the document geometry that is closest to another arbitrary point in screen space

Parameters
x x coordinate of the screen point
y y coordinate of the screen point
Returns
  • snapped point in screen space.

public String takeUndoSnapshot (String meta_info)

Creates a new state at the top of the undo/redo chain by taking a snapshot.

Parameters
meta_info meta-data to be attached to this new state.
Throws
PDFNetException PDFNet exception

public boolean turnPageInNonContinuousMode (int currentPage, boolean nextPage)

Turn to next or previous page in non-continuous mode when at the edge if possible

Parameters
currentPage current page
nextPage true if turn to next page, false if turn to previous page
Returns
  • whether page is turned

public String undo ()

Return to the previous state in the undo/redo chain. Returns any meta-data associated with that state.

Returns
  • meta-data associated with the current state in the undo/redo chain after undoing one state.
Throws
PDFNetException PDFNet exception

public void update (Annot annot, int page_num)

Redraws the area covered with a given annotation.

Parameters
annot the annotation whose occupied region is to be updated
page_num the number of the page that the annotation belongs to

public void update (boolean all)

Redraws the contents.

Parameters
all if true, all the rendered contents are discarded and re-rendered; otherwise, only the visible region will be re-rendered.

public void update (Rect rec)

Redraws the given area in the client space.

Note: For details about client space, please refer to convScreenPtToCanvasPt(double, double).

Parameters
rec the rectangle specifying the given area

public void update (Field field)

Redraws all instances (Widgets) of the field.

Parameters
field the field for which to update all occurances

public void update ()

Redraws the contents of the visible region.

public void updateOCGContext ()

This method is deprecated.
Updated the current Optional Content Group (OCG) context associated with this PDFViewCtrl. This call might be helpful after, for example, a stamp has been added to the document.

Throws
PDFNetException PDFNet exception

public void updatePageLayout ()

Updates the page layout within the view. This function must be called after document page sequence is modified (such as when a page is being added to or removed from a document) or after changes to page dimensions (e.g. after a page is rotated or resized).

public void waitForRendering (int milliseconds)

Waits about specified milliseconds or until the visible region is done rendering, whichever is less.

Note: When PDFViewCtrl has to re-render its visible region, say after update() is called, it might be desirable to call this method so that before onDraw(Canvas) is called by OS, the new content will already be ready. This helps to avoid flickering.

If docUnlock() also has to be called, it should be called before this function.

Parameters
milliseconds milli-seconds to wait up to

public void waitForRendering ()

Waits about 1500 milliseconds or until the visible region is done rendering, whichever is less. Please refer to waitForRendering(int) for more details.

public boolean wereAnnotsForMousePrepared (int pageNum)

Checks if annotations of the given page have been prepared.

Parameters
pageNum page number
Returns
  • true if annotations have been prepared, false otherwise

public boolean wereWordsPrepared (int pageNum)

Checks if words of the given page have been prepared.

Parameters
pageNum page number
Returns
  • true if words has been prepared, false otherwise

Protected Methods

protected int computeHorizontalScrollRange ()

The overloaded implementation of android.view.computeHorizontalScrollRange().

protected int computeVerticalScrollRange ()

The overloaded implementation of android.view.computeVerticalScrollRange().

protected void finalize ()

The overloaded implementation of java.lang.Object.finalize(). Internally it calls destroy().

Throws
Throwable

protected boolean onDoubleTap (MotionEvent e)

Notified when a double-tap occurs.

Note: PDFViewCtrl zooms in/out during this event. A tool (through the PDFViewCtrl.ToolManager interface) can return true in the corresponding function to bypass PDFViewCtrl's such behavior.

Parameters
e The down motion event of the first tap of the double-tap.
Returns
  • true if the event was handled, false otherwise.

protected boolean onDoubleTapEvent (MotionEvent e)

Notified when an event within a double-tap gesture occurs, including the down, move, and up events.

Parameters
e The motion event that occurred during the double-tap gesture.
Returns
  • true if the event was handled, false otherwise.

protected boolean onDown (MotionEvent e)

Notified when a tap occurs with the down MotionEvent that triggered it. This will be triggered immediately for every down event. All other events should be preceded by this.

Note: PDFViewCtrl uses this event to stop the ongoing fling motion (this behavior cannot be bypassed by the PDFViewCtrl.ToolManager interface).

Parameters
e the down motion event
Returns
  • true if the event was handled, false otherwise.

protected void onDraw (Canvas canvas)

The overloaded implementation of android.view.View.onDraw(). This is where PDFViewCtrl puts the rendered PDF contents on screen. At the end of this function, it also calls onDraw(android.graphics.Canvas, android.graphics.Matrix) to render a tool's content on top, if exists.

protected boolean onFling (MotionEvent e1, MotionEvent e2, float x_vel, float y_vel)

Notified when a fling event occurs with a scroll event.

Note: PDFViewCtrl flings during this event. You can return true in the onUp(MotionEvent, PriorEventMode) function, where prior event type is FLING, to bypass PDFViewCtrl's such behavior.

Parameters
e1 The first down motion event that started the fling.
e2 The move motion event that triggered the current onFling.
x_vel The velocity of this fling measured in pixels per second along the x axis.
y_vel The velocity of this fling measured in pixels per second along the y axis.
Returns
  • true if the event was handled, false otherwise.

protected void onFlingStop ()

Notified when a fling motion stops.

protected void onLayout (boolean changed, int l, int t, int r, int b)

The overloaded implementation of android.view.View.onLayout().

protected void onLongPress (MotionEvent e)

Notified when a long press occurs with the initial on down MotionEvent that triggered it.

Parameters
e The initial on down motion event that started the long press.

protected void onMeasure (int widthMeasureSpec, int heightMeasureSpec)

The overloaded implementation of android.view.View.onMeasure().

protected boolean onScale (ScaleGestureDetector detector)

Responds to scaling events for a gesture in progress. Reported by pointer motion.

Note: PDFViewCtrl zooms in the function. In order to bypass this behavior, a tool (through the PDFViewCtrl.ToolManager interface) can return true in its onScaleBegin(ScaleGestureDetector) function.

Parameters
detector The detector reporting the event - use this to retrieve extended info about event state.
Returns
  • Whether or not the detector should consider this event as handled. If an event was not handled, the detector will continue to accumulate movement until an event is handled. This can be useful if an application, for example, only wants to update scaling factors if the change is greater than 0.01.

protected boolean onScaleBegin (ScaleGestureDetector detector)

Responds to the beginning of a scaling gesture. Reported by new pointers going down.

Note: PDFViewCtrl sets up certain internal states and zooms and finishes in the subsequent onScale(ScaleGestureDetector) and onScaleEnd(ScaleGestureDetector) functions, respectively. A tool (through the PDFViewCtrl.ToolManager interface) can return true in the corresponding function to bypass PDFViewCtrl's such behavior. However, the tool has to bypass this function in order to bypass the subsequent two functions, which can not be bypassed individually.

Parameters
detector The detector reporting the event - use this to retrieve extended info about event state.
Returns
  • Whether or not the detector should continue recognizing this gesture. For example, if a gesture is beginning with a focal point outside of a region where it makes sense, onScaleBegin() may return false to ignore the rest of the gesture.

protected void onScaleEnd (ScaleGestureDetector detector)

Responds to the end of a scale gesture. Reported by existing pointers going up. Once a scale has ended, getFocusX() and getFocusY() will return the location of the pointer remaining on the screen.

Note: PDFViewCtrl finishes zooming in the function. In order to bypass this behavior, a tool (through the PDFViewCtrl.ToolManager interface) can return true in its onScaleBegin(ScaleGestureDetector) function.

Parameters
detector The detector reporting the event - use this to retrieve extended info about event state.

protected boolean onScroll (MotionEvent e1, MotionEvent e2, float x_dist, float y_dist)

Notified when a scroll event occurs with a scroll event.

Note: PDFViewCtrl scrolls in the function. In order to bypass this behavior, a tool (through the PDFViewCtrl.ToolManager interface) can return true in its corresponding function.

Parameters
e1 The first down motion event that started the scrolling.
e2 The move motion event that triggered the current onScroll.
x_dist The distance along the X axis that has been scrolled since the last call to onScroll. This is NOT the distance between e1 and e2.
y_dist The distance along the Y axis that has been scrolled since the last call to onScroll. This is NOT the distance between e1 and e2.
Returns
  • true if the event was handled, false otherwise.

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

Called in response to an internal scroll in PDFViewCtrl. This can be used to detect PDFViewCtrl is scrolling after a fling, for example.

Parameters
l current horizontal scroll origin
t current vertical scroll origin
oldl previous horizontal scroll origin
oldt previous vertical scroll origin

protected void onShowPress (MotionEvent e)

The user has performed a down MotionEvent and not performed a move or up yet. This event is commonly used to provide visual feedback to the user to let them know that their action has been recognized i.e. highlight an element.

Parameters
e The down motion event.

protected boolean onSingleTapConfirmed (MotionEvent e)

Notified when a single-tap occurs. Unlike onSingleTapUp(MotionEvent), this will only be called after the detector is confident that the user's first tap is not followed by a second tap leading to a double-tap gesture.

Parameters
e The down motion event of the single-tap.
Returns
  • true if the event was handled, false otherwise.

protected boolean onSingleTapUp (MotionEvent e)

Notified when a tap occurs with the up MotionEvent that triggered it.

Parameters
e The down motion event of the single-tap.
Returns
  • true if the event was handled, false otherwise.

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

The overloaded implementation of android.view.View.onSizeChanged().

protected boolean onUp (MotionEvent e, PDFViewCtrl.PriorEventMode priorEventMode)

Notified when an up event occurs with the up MotionEvent that triggered it.

Parameters
e The up motion event.
priorEventMode indicates the prior event type.
Returns
  • true if the event was handled, false otherwise.