public class

PDFViewCtrl

extends JComponent
implements __Delete Scrollable
java.lang.Object
   ↳ java.awt.Component
     ↳ java.awt.Container
       ↳ javax.swing.JComponent
         ↳ com.pdftron.pdf.PDFViewCtrl

Class Overview

PDFViewCtrl is a utility class that can be used for interactive rendering of PDF documents.

In .NET environment PDFViewCtrl is derived from System.Windows.Forms.Control and it can be used like a regular form (see PDFViewForm.cs in PDFView sample for C# for a concrete example).

PDFViewCtrl implements some essential features such as double-buffering, multi-threaded rendering, scrolling, zooming, and page navigation that are essential in interactive rendering applications (e.g. in client PDF viewing and editing applications).

PDFView defines several coordinate spaces and it is important to understand their differences:

  • Page Space refers to the space in which a PDF page is defined. It is determined by a page itself and the origin is at the lower-left corner of the page. Note that Page Space is independent of how a page is viewed in PDFView and each page has its own Page space.
  • Canvas Space refers to the tightest axis-aligned bounding box of all the pages given the current page presentation mode in PDFView. For example, if the page presentation mode is SINGLE_CONTINUOUS, all the pages are arranged vertically with one page in each row, and therefore the Canvas Space is rectangle with possibly large height value. For this reason, Canvas Space is also, like Page Space, independent of the zoom factor. Also note that since PDFView adds gaps between adjacent pages, the Canvas Space is larger than the space occupied by all the pages. The origin of the Canvas Space is located at the upper-left corner.
  • Screen Space (or Client Space) is the space occupied by PDFView and its origin is at the upper-left corner. Note that the virtual size of this space can extend beyond the visible region.
  • Scrollable Space is the virtual space within which PDFView can scroll. It is determined by the Canvas Space and the current zoom factor. Roughly speaking, the dimensions of the Scrollable Space is the dimensions of the Canvas Space timed by the zoom. Therefore, a large zoom factor will result in a larger Scrollable region given the same Canvas region. For this reason, Scrollable Space might also be referred to as Zoomed Canvas Space. Note that since PDFView adds gaps between pages in Canvas Space and these gaps are not scaled when rendered, the scrollable range is not exactly what the zoom factor times the Canvas range. For functions such as setHScrollPos(), setVScrollPos(), getCanvasHeight(), and getCanvasWidth(), it is the Scrollable Space that is involved.

Summary

Nested Classes
enum PDFViewCtrl.ColorPostprocessMode  
class PDFViewCtrl.LinkInfo A class that holds information for a link. 
enum PDFViewCtrl.PagePresentationMode PagePresentationMode lists common modes of presenting PDF pages. 
enum PDFViewCtrl.PageViewMode PageViewMode lists common modes of viewing PDF pages. 
class PDFViewCtrl.Selection A class representing the current text selection. 
Constants
int e_custom PDFViewCtrl class supports a number of 'built-in' tool modes.
int e_facing This constant is deprecated. use FACING instead.
int e_facing_continuous This constant is deprecated. use FACING_CONTINUOUS instead.
int e_facing_continuous_cover This constant is deprecated. use FACING_CONTINUOUS_COVER instead.
int e_facing_cover This constant is deprecated. use FACING_COVER instead.
int e_fit_height This constant is deprecated. use FIT_HEIGHT instead.
int e_fit_page This constant is deprecated. use FIT_PAGE instead.
int e_fit_width This constant is deprecated. use FIT_WIDTH instead.
int e_pan The Constant e_pan.
int e_postprocess_invert This constant is deprecated. use INVERT instead.
int e_postprocess_none This constant is deprecated. use NONE instead.
int e_single_continuous This constant is deprecated. use SINGLE_CONTINUOUS instead.
int e_single_page This constant is deprecated. use SINGLE_PAGE instead.
int e_text_rect_select The Constant e_text_rect_select.
int e_text_struct_select The Constant e_text_struct_select.
int e_zoom This constant is deprecated. use ZOOM instead.
[Expand]
Inherited Constants
From class javax.swing.JComponent
From class java.awt.Component
From interface java.awt.image.ImageObserver
Public Constructors
PDFViewCtrl()
PDFViewCtrl constructor.
PDFViewCtrl(int preferred_width)
Instantiates a new PDFViewCtrl.
Public Methods
int GetSelectionBeginPage()
this method returns the first page number that has text selection on it.
int GetSelectionEndPage()
this method returns the last page number that has text selection on it.
boolean HasSelectionOnPage(int page)
Checks for selection on page.
void cancelAllThumbRequests()
void cancelRendering()
Cancels rendering in progress.
void cancelRenderingAsync()
Cancels rendering in progress and returns immediately, potentially before rendering has actually stopped.
void clearSelection()
Remove any text selection.
Point2D.Double convCanvasPtToPagePt(double x, double y, int page_num)
Convert a point in canvas space to a point in a page space.
Point2D.Double convCanvasPtToPagePt(double x, double y)
Convert a point expressed in canvas space to a point in the current page space.
Point2D.Double convCanvasPtToScreenPt(double x, double y)
Convert a point expressed in canvas space to a point in screen space.
Point2D.Double convPagePtToCanvasPt(double x, double y, int page_num)
Convert a point in page space to a point in canvas space.
Point2D.Double convPagePtToCanvasPt(double x, double y)
Convert a point in a page space to a point in canvas space.
Point2D.Double convPagePtToScreenPt(double x, double y)
Convert a point from a page space to screen space.
Point2D.Double convPagePtToScreenPt(double x, double y, int page_num)
Convert a point from a page space to a point in screen space.
Point2D.Double convScreenPtToCanvasPt(double x, double y)
Convert a point expressed in screen space to a point in canvas space.
Point2D.Double convScreenPtToPagePt(double x, double y, int page_num)
Convert a point expressed in screen space to a point in a page space.
Point2D.Double convScreenPtToPagePt(double x, double y)
Convert a point expressed in screen space to the current page space.
void destroy()
Frees the native memory of the object.
void docLock(boolean cancel_thread)
Acquires a write lock on the currently open document, optionally canceling all threads accessing the document.
void docLockRead()
Locks the currently open document to prevent competing write threads (using Lock()) from accessing the document at the same time.
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.
void docUnlock()
Releases the write lock from the currently open document.
void docUnlockRead()
Releases the read lock from the currently open document.
void enableUndoRedo()
Enable Undo/Redo in this PDFview.
void findTextAsync(String search_str, boolean match_case, boolean match_whole_word, boolean search_up, boolean reg_exp)
Selects text by searching for a given string of text asynchronously, and calling a user callback upon completion
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.
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 *
Annot[] getAnnotationsOnPage(int page_num)
Gets the list of annotations on a given page.
int getBufferHeight()
Get the width of the rendering buffer in pixels.
int getBufferStride()
Get the stride of the rendering buffer in pixels.
int getBufferWidth()
Get the width of the rendering buffer in pixels.
double getCanvasHeight()
Returns the height of the scrollable space.
double getCanvasWidth()
Returns the width of the scrollable space.
int getColorPostProcessMode()
int getCurrentPage()
Get the current page.
Matrix2D getDeviceTransform(int page_num)
Get the device transform matrix
Matrix2D getDeviceTransform()
Get the device transformation matrix

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

PDFDoc getDoc()
Get the document.
ExternalAnnotManager getExternalAnnotManager(String author_name)
Get the external annot manager belonging to this PDFViewCtrl
int getH()
double getHScrollPos()
int getHeight()
PDFViewCtrl.LinkInfo getLinkAt(int x, int y)
Gets the link info at a given point, specified in client space.
String getNextRedoInfo()
Returns any meta-data associated with the next sate in the undo chain.
String getNextUndoInfo()
Returns any meta-data associated with the previous sate in the undo chain.
Context getOCGContext()
Get the oCG context.
int getPageCount()
Get the page count.
int getPageNumberFromScreenPt(double x, double y)
Get the page number from screen pt.
int getPagePresentationMode()
Get the page presentation mode.
int getPageViewMode()
Get the page view mode.
Dimension getPreferredScrollableViewportSize()
Dimension getPreferredSize()
int getRotation()
Get the rotation.
Rect getScreenRectForAnnot(Annot annot, int page_num)
Gets annotation bounding box in screen points

int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction)
boolean getScrollableTracksViewportHeight()
boolean getScrollableTracksViewportWidth()
int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction)
PDFViewCtrl.Selection getSelection(int page)
Get the selection.
Dimension getSize(Dimension rv)
void getThumbAsync(int page_num, ThumbAsyncHandler proc, Object data)
int getToolMode()
Get the tool mode.
int getV()
double getVScrollPos()
PDFViewScrollPane getViewPane()
int getWidth()
double getZoom()
Get the current zoom factor.
boolean gotoFirstPage()
Set the current page to the first page in the document.
boolean gotoLastPage()
Set the current page to the last page in the document.
boolean gotoNextPage()
Set the current page to the next page in the document.
boolean gotoPreviousPage()
Set the current page to the previous page in the document.
boolean hasSelection()
Checks for selection.
void hideAnnotation(Annot annot)
Disable rendering of a particular annotation.
void invalidateRect(Rect rect)
Invalidate rect.
void invalidateRect()
The InvalidateRect function adds a rectangle to the buffer/window update region.
boolean isFinishedRendering()
void onScroll(int pix_dx, int pix_dy)
Scrolls the contents of the rendering buffer 'pix_dx' horizontally and 'pix_dy' vertically.
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 revertAllChanges()
Determine whether this DocumentConversion has progress reporting capability.
void rotateClockwise()
Rotates all pages in the document 90 degrees clockwise.
void rotateCounterClockwise()
Rotates all pages in the document 90 degrees counter-clockwise.
void scrollRectToVisible(Rectangle r)
void selectAll()
Selects all text on the page.
boolean selectByHighlights(Highlights hlts)
Selects texts by Highlights.
boolean selectByRect(double x1, double y1, double x2, double y2)
Selects all words that intersect the given selection rectangle.
boolean selectBySelection(PDFViewCtrl.Selection sel)
Selects texts by PDFViewCtrl.Selection.
boolean selectByStruct(double x1, double y1, double x2, double y2)
Selects text taking into account page logical structure.
void setAntiAliasing(boolean enable_aa)
Enable or disable anti-aliasing.
void setBackground(Color c)
Set the default background color used to paint the area surrounding each page.
void setBackgroundColor(byte r, byte g, byte b)
Set the default background color used to paint the area surrounding each page.
void setCaching(boolean enabled)
Enables or disables caching.
void setColorPostProcessMode(int mode)
This method is deprecated. use #setColorPostprocessMode()ColorPostprocessMode instead. Set 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.
void setColorPostProcessMode(PDFViewCtrl.ColorPostprocessMode mode)
Set the color post processing transformation.
boolean setCurrentPage(int page_num)
Set the current page to the given page.
void setCurrentPageProc(CurrentPageProc curr_pagenum_proc, Object data)
Set the callback function (i.e.
void setDefaultPageColor(byte r, byte g, byte b)
Set the default 'paper' color used to draw background of each page.
void setDefaultPageColor(Color c)
Set the default 'paper' color used to draw background of each page.
void setDevicePixelDensity(double dpi, double scale_factor)
Set device DPI, and scale factor.
void setDoc(PDFDoc doc)
Associates this PDFViewCtrl with a given PDF document.
void setDrawAnnotations(boolean render_annots)
Enable or disable annotation and forms rendering.
void setErrorReportProc(ErrorReportProc error_proc, Object data)
Set the error report process
void setFindTextHandler(FindTextProc proc, Object data)
Set the callback function (i.e.
void setGamma(double exp)
Set the gamma factor used for anti-aliased rendering.
void setH(int h)
void setHScrollPos(double pos)
Sets the horizontal scroll position in the scrollable space..
void setHighlightFields(boolean highlight_fields)
Enable or disable highlighting form fields.
void setHorizontalAlign(int align)
Set the horizontal alignment used for rendering pages within the view.
void setImageSmoothing(boolean smoothing_enabled)
Set the image smoothing.
void setImageSmoothing()
Enable or disable image smoothing.
void setOCGContext(Context ctx)
Set the Optional Content Group (OCG) context that should be used when viewing the document.
void setOverprint(int op)
Enable or disable support for overprint.
void setPageBorderVisibility(boolean border_visible)
Enables or disables drawing of a thin border around each page.
void setPagePresentationMode(PDFViewCtrl.PagePresentationMode mode)
Set the current page presentation mode.
void setPagePresentationMode(int mode)
This method is deprecated. use setPagePresentationMode(PagePresentationMode) instead. Set the current page presentation mode.
void setPageSpacing(int horiz_col_space, int vert_col_space, int horiz_pad, int vert_pad)
Set 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)
Set the page viewing mode.
void setPageViewMode(int mode)
This method is deprecated. use setPageViewMode(PageViewMode) instead. Set the page viewing mode.

Note: The default PageView mode is e_fit_width.

void setPathHinting(boolean enable_ph)
Enable or disable path hinting.
void setPreferredSize(int width, int height)
Set the preferred size.
void setPreferredSize(Dimension d)
void setProgressiveRendering(boolean is_progressive)
Enables or disables progressive rendering in PDFViewCtrl.
void setRasterizer(boolean builtin_rasterizer)
Set the core graphics library used for rasterization and rendering.
void setRequestRenderInWorkerThreadProc(RequestRenderInWorkerThreadProc render_worker_proc, Object data)
Sets the RequestRenderInWorkerThread Callback
void setSnappingMode(int mode_flags)
Set the point snapping mode for the SnapToNearestInDoc method.
void setThinLineAdjustment(boolean pixel_grid_fit, boolean stroke_adjust)
Set thin line adjustment parameters.
void setToolMode(int mode)
Set the new tool mode (such as pan, text select, etc).
void setUrlExtraction(boolean enabled)
Enables or disables URL extraction.
void setV(int v)
void setVScrollPos(double pos)
Sets the vertical scroll position in the scrollable space..
void setVerticalAlign(int align)
Set 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)
Set the zoom factor to a new value.
boolean setZoom(int x, int y, double zoom)
Set the zoom factor to a new value using the given pixel coordinate (x,y) as a zoom center.
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)
Changes the viewing area to fit a rectangle on specified page number.
boolean smartZoom(int x, int y)
Set the zoom factor to a new value using the given pixel coordinate (x,y) as a zoom center.
Point2D.Double snapToNearestInDoc(double x, double y)
Returns the point within the document geometry that is closest to another arbtrary point in screen space
void takeSnapshot(String meta_info)
Get the state of the conversion process.
String undo()
Return to the previous state.
void update(Annot a, int num_page)
Redraws the area covered with a given annotation.
void update()
Redraws the contents of the buffer.
void update(Rect rec)
Redraws the given area in the buffer.
void update(Field field)
Redraws all instances (Widgets) of the field.
void update(Graphics g)
void updatePageLayout()
Updates the page layout within the view.
[Expand]
Inherited Methods
From class javax.swing.JComponent
From class java.awt.Container
From class java.awt.Component
From class java.lang.Object
From interface com.pdftron.pdf.__Delete
From interface java.awt.MenuContainer
From interface java.awt.image.ImageObserver
From interface javax.swing.Scrollable

Constants

public static final int e_custom

PDFViewCtrl class supports a number of 'built-in' tool modes. ToolMode enumerates tool modes supported by PDFViewCtrl.

Constant Value: 0 (0x00000000)

public static final int e_facing

This constant is deprecated.
use FACING instead.

only two pages fit in the current view (similar to booklet view).

Constant Value: 3 (0x00000003)

public static final int e_facing_continuous

This constant is deprecated.
use FACING_CONTINUOUS instead.

pages are displayed sequentially with two pages per row.

Constant Value: 4 (0x00000004)

public static final int e_facing_continuous_cover

This constant is deprecated.
use FACING_CONTINUOUS_COVER instead.

display the pages in two columns, with odd-numbered pages on the right.

Constant Value: 6 (0x00000006)

public static final int e_facing_cover

This constant is deprecated.
use FACING_COVER instead.

display the pages two at a time, with odd-numbered pages on the right.

Constant Value: 5 (0x00000005)

public static final int e_fit_height

This constant is deprecated.
use FIT_HEIGHT instead.

fit height

Constant Value: 2 (0x00000002)

public static final int e_fit_page

This constant is deprecated.
use FIT_PAGE instead.

fit page

Constant Value: 0 (0x00000000)

public static final int e_fit_width

This constant is deprecated.
use FIT_WIDTH instead.

fit width

Constant Value: 1 (0x00000001)

public static final int e_pan

The Constant e_pan.

Constant Value: 1 (0x00000001)

public static final int e_postprocess_invert

This constant is deprecated.
use INVERT instead.

invert postprocess

Constant Value: 1 (0x00000001)

public static final int e_postprocess_none

This constant is deprecated.
use NONE instead.

no prostprocess

Constant Value: 0 (0x00000000)

public static final int e_single_continuous

This constant is deprecated.
use SINGLE_CONTINUOUS instead.

pages are displayed sequentially (one underneath another).

Constant Value: 2 (0x00000002)

public static final int e_single_page

This constant is deprecated.
use SINGLE_PAGE instead.

only one page at a time fits in the current view.

Constant Value: 1 (0x00000001)

public static final int e_text_rect_select

The Constant e_text_rect_select.

Constant Value: 2 (0x00000002)

public static final int e_text_struct_select

The Constant e_text_struct_select.

Constant Value: 3 (0x00000003)

public static final int e_zoom

This constant is deprecated.
use ZOOM instead.

zoom

Constant Value: 3 (0x00000003)

Public Constructors

public PDFViewCtrl ()

PDFViewCtrl constructor. Create PDFViewCtrl without associating it to any document.

public PDFViewCtrl (int preferred_width)

Instantiates a new PDFViewCtrl.

Parameters
preferred_width the preferred PDFViewCtrl width

Public Methods

public int GetSelectionBeginPage ()

this method returns the first page number that has text selection on it. Useful when there are selections on multiple pages at the same time.

Returns
  • the int

public int GetSelectionEndPage ()

this method returns the last page number that has text selection on it. Useful when there are selections on multiple pages at the same time.

Returns
  • the int

public boolean HasSelectionOnPage (int page)

Checks for selection on page.

Parameters
page the page
Returns
  • returns true if given page number has any text selection on it. Useful when there are selections on multiple pages at the same time.

public void cancelAllThumbRequests ()

public void cancelRendering ()

Cancels rendering in progress. If PDFViewCtrl is not busy rendering the page, the function has no side effects.

public void cancelRenderingAsync ()

Cancels rendering in progress and returns immediately, potentially before rendering has actually stopped.

public void clearSelection ()

Remove any text selection.

public Point2D.Double convCanvasPtToPagePt (double x, double y, int page_num)

Convert a point in canvas space to a point in a page space.

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

public Point2D.Double convCanvasPtToPagePt (double x, double y)

Convert a point expressed in canvas space to a point in the current page space.

Parameters
x x coordinate of the canvas point
y y coordinate of the canvas point
Returns
  • converted point in page space.

public Point2D.Double convCanvasPtToScreenPt (double x, double y)

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

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

public Point2D.Double convPagePtToCanvasPt (double x, double y, int page_num)

Convert a point in page space to a point in canvas space.

Parameters
x x coordinate of the point on the specified page
y y coordinate of the point on the specified page
page_num input page number
Returns
  • converted point in canvas space.

public Point2D.Double convPagePtToCanvasPt (double x, double y)

Convert a point in a page space to a point in canvas space.

Parameters
x x coordinate of point on current page
y y coordinate of point on current page
Returns
  • converted point in the canvas space.

public Point2D.Double convPagePtToScreenPt (double x, double y)

Convert a point from a page space to screen space.

Parameters
x x coordinate of the point on the current page
y y coordinate of the point on the current page
Returns
  • converted point in screen space.

public Point2D.Double convPagePtToScreenPt (double x, double y, int page_num)

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

Parameters
x x coordinate of the point on the specified page
y y coordinate of the point on the specified page
page_num input page number

public Point2D.Double convScreenPtToCanvasPt (double x, double y)

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

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

public Point2D.Double convScreenPtToPagePt (double x, double y, int page_num)

Convert a point expressed in screen space to a point in a page space.

Parameters
x x coordinate of the screen point
y y coordinate of the screen point
page_num the input page number
Returns
  • converted point in the specified page space.

public Point2D.Double convScreenPtToPagePt (double x, double y)

Convert a point expressed in screen space to the current page space. page.

Parameters
x x coordinate of the screen point
y y coordinate of the screen point
Returns
  • converted point in the current page space.

public void destroy ()

Frees the native memory of the object. This can be explicity called to control the deallocation of native memory and avoid situations where the garbage collector does not free the object in a timely manner.

public void docLock (boolean cancel_thread)

Acquires a write lock on the currently open document, optionally canceling all threads accessing the document.

public void docLockRead ()

Locks the currently open document to prevent competing write threads (using Lock()) 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 doc.UnlockRead(). 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.

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 document is locked for multi-threaded access, false otherwise.

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.

public void docUnlock ()

Releases the write lock from the currently open document.

public void docUnlockRead ()

Releases the read lock from the currently open document.

public void enableUndoRedo ()

Enable Undo/Redo in this PDFview.

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

Selects text by searching for a given string of text asynchronously, and calling a user callback upon completion

Parameters
search_str -
match_case -
match_whole_word -
search_up -
reg_exp - use regular expressions

public Annot getAnnotationAt (int x, int y)

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

Note: For details about client 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.
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.
Returns
  • The annotation closest to the point. If no annotation was found, it returns a null pointer.

public 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 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 int getBufferHeight ()

Get the width of the rendering buffer in pixels.

Note: this method is typically used only in PDFNet for C++

Returns
  • the buffer height

public int getBufferStride ()

Get the stride of the rendering buffer in pixels.

Note: this method is typically used only in PDFNet for C++

Returns
  • the buffer stride

public int getBufferWidth ()

Get the width of the rendering buffer in pixels.

Note: this method is typically used only in PDFNet for C++

Returns
  • the buffer width

public double getCanvasHeight ()

Returns the height of the scrollable space.

public double getCanvasWidth ()

Returns the width of the scrollable space.

public int getColorPostProcessMode ()

Returns
  • the current color post processing mode.

public int getCurrentPage ()

Get the current page.

Returns
  • the current page displayed in the view.

public Matrix2D getDeviceTransform (int page_num)

Get the device transform matrix

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

public Matrix2D getDeviceTransform ()

Get 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: Common::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 PDFDoc getDoc ()

Get the document.

Returns
  • Currently associated document with this PDFViewCtrl.

public ExternalAnnotManager getExternalAnnotManager (String author_name)

Get the external annot manager belonging to this PDFViewCtrl

public int getH ()

public double getHScrollPos ()

Returns
  • the current horizontal scroll position in scrollable space..

public int getHeight ()

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

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

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

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

public String getNextRedoInfo ()

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

Returns
  • Returns true if CancelConversion has been called previously.

public String getNextUndoInfo ()

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

Returns
  • .

public Context getOCGContext ()

Get the oCG context.

Returns
  • the Optional Content Group (OCG) context associated with this PDFViewCtrl, or NULL (i.e. context.IsValid()==false) if there is no OCG context associated with the view. If 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.

public int getPageCount ()

Get the page count.

Returns
  • the total number of pages in the document.

public int getPageNumberFromScreenPt (double x, double y)

Get the page number from screen pt.

Parameters
x x coordinate of the screen point
y y coordinate of the screen point
Returns
  • the number of the page located under the given screen coordinate. The positive number indicates a valid page, whereas number less than 1 means that no page was found.

public int getPagePresentationMode ()

Get the page presentation mode.

Returns
  • the current page presentation mode.

public int getPageViewMode ()

Get the page view mode.

Returns
  • the current page viewing mode

public Dimension getPreferredScrollableViewportSize ()

public Dimension getPreferredSize ()

public int getRotation ()

Get the rotation.

Returns
  • The current rotation of this PDFViewCtrl.

public Rect getScreenRectForAnnot (Annot annot, int page_num)

Gets annotation bounding box in screen points

Parameters
annot target annotation
page_num the page where the annotation is on
Returns
  • the rect in screen points

public int getScrollableBlockIncrement (Rectangle visibleRect, int orientation, int direction)

public boolean getScrollableTracksViewportHeight ()

public boolean getScrollableTracksViewportWidth ()

public int getScrollableUnitIncrement (Rectangle visibleRect, int orientation, int direction)

public PDFViewCtrl.Selection getSelection (int page)

Get the selection.

Parameters
page the page
Returns
  • Current text selection for a given page. If there is only selection on one page, then page number can be -1

public Dimension getSize (Dimension rv)

public void getThumbAsync (int page_num, ThumbAsyncHandler proc, Object data)

public int getToolMode ()

Get the tool mode.

Returns
  • Current tool mode.

public int getV ()

public double getVScrollPos ()

Returns
  • the current vertical scroll position in scrollable space..

public PDFViewScrollPane getViewPane ()

public int getWidth ()

public double getZoom ()

Get the current zoom factor.

Returns
  • current zoom (or scaling) component used to display the page content.

public boolean gotoFirstPage ()

Set the current page to the first page in the document.

Returns
  • true if successful, false otherwise.

public boolean gotoLastPage ()

Set the current page to the last page in the document.

Returns
  • true if successful, false otherwise.

public boolean gotoNextPage ()

Set the current page to the next page in the document.

Returns
  • true if successful, false otherwise.

public boolean gotoPreviousPage ()

Set the current page to the previous page in the document.

Returns
  • true if successful, false otherwise.

public boolean hasSelection ()

Checks for selection.

Returns
  • return true if there is selection, false otherwise.

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.

public void invalidateRect (Rect rect)

Invalidate rect.

Parameters
rect the rect

public void invalidateRect ()

The InvalidateRect function adds a rectangle to the buffer/window update region. The update region represents the portion of the buffer/window's client area that must be redrawn

public boolean isFinishedRendering ()

Returns
  • true is the rendering thread finished rendering the view, false if the rendering is still in progress.

public void onScroll (int pix_dx, int pix_dy)

Scrolls the contents of the rendering buffer 'pix_dx' horizontally and 'pix_dy' vertically.

Parameters
pix_dx horizontal scroll offset, in pixels
pix_dy vertical scroll offset, in pixels

public String redo ()

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

Returns
  • .

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.

public void revertAllChanges ()

Determine whether this DocumentConversion has progress reporting capability.

public void rotateClockwise ()

Rotates all pages in the document 90 degrees clockwise.

public void rotateCounterClockwise ()

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

public void scrollRectToVisible (Rectangle r)

public void selectAll ()

Selects all text on the page.

public boolean selectByHighlights (Highlights hlts)

Selects texts by Highlights.

Parameters
hlts - 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 all words that intersect the given selection rectangle.

Parameters
x1 the x1
y1 the y1
x2 the x2
y2 the y2
Returns
  • true if some text was selected, false otherwise.

public boolean selectBySelection (PDFViewCtrl.Selection sel)

Selects texts by PDFViewCtrl.Selection.

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

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

Selects text taking into account page logical structure. This type of selection is similar to HTML like selection in web-browsers.

Parameters
x1 the x1
y1 the y1
x2 the x2
y2 the y2
Returns
  • true if some text was selected, false otherwise.

public void setAntiAliasing (boolean enable_aa)

Enable or disable anti-aliasing. Anti-Aliasing is a technique used to improve the visual quality of images when displaying them on low resolution devices (for example, low DPI computer monitors).

Note: Anti-aliasing is enabled by default.

Parameters
enable_aa the new anti aliasing

public void setBackground (Color c)

Set the default background color used to paint the area surrounding each page.

Parameters
c the new background

public void setBackgroundColor (byte r, byte g, byte b)

Set the default background color used to paint the area surrounding each page.

Parameters
r the r
g the g
b the b

public void setCaching (boolean enabled)

Enables or disables caching.

Note: by default caching is enabled

Parameters
enabled if true caching is enabled, if false caching is disabled.

public void setColorPostProcessMode (int mode)

This method is deprecated.
use #setColorPostprocessMode()ColorPostprocessMode instead. Set 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 void setColorPostProcessMode (PDFViewCtrl.ColorPostprocessMode mode)

Set 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)

Set the current page to the given page.

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

public void setCurrentPageProc (CurrentPageProc curr_pagenum_proc, Object data)

Set the callback function (i.e. a delegate) that is called whenever current page number changes. This can be used to update the current page number within GUI applications etc.

Parameters
curr_pagenum_proc Callback function (or a delegate in .NET).
data Custom data to be passed as a second parameter to 'curr_pagenum_proc'.

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

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

Parameters
r the r
g the g
b the b

public void setDefaultPageColor (Color c)

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

Parameters
c the new default page color

public void setDevicePixelDensity (double dpi, double scale_factor)

Set device DPI, and scale factor. This affects the rendering of certain content, such as annotations with the no_zoom flag.

Parameters
dpi Scale relative to the internal DPI of 96 (default 1.0).
scale_factor Some DPI sensitive content, sush as annotations, can be scaled up, to make the content larger, which can make user interaction easier (default 1.0).

public void setDoc (PDFDoc doc)

Associates this PDFViewCtrl with a given PDF document.

Note: Acquires a write lock on the document

Parameters
doc A document to be displayed in the view.

public void setDrawAnnotations (boolean render_annots)

Enable or disable annotation and forms rendering. By default, all annotations and form fields are rendered.

Parameters
render_annots True to draw annotations, false otherwise.

public void setErrorReportProc (ErrorReportProc error_proc, Object data)

Set the error report process

Parameters
error_proc error process
data custom data

public void setFindTextHandler (FindTextProc proc, Object data)

Set the callback function (i.e. a delegate) that is called when FindTextAsync is completed.

Parameters
proc Callback function (or a delegate in .NET).
data Custom data to be passed as a parameter to 'findtext_proc'.

public void setGamma (double exp)

Set the gamma factor used for anti-aliased rendering.

Note: Gamma correction is used only in the built-in rasterizer.

Parameters
exp is the exponent value of gamma function. Typical values are in the range from 0.1 to 3. 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).

public void setH (int h)

public void setHScrollPos (double pos)

Sets the horizontal scroll position in the scrollable space..

Parameters
pos the new horizontal scroll position. The position should be a number in the range between 0 and GetCanvasWidth().

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)

Set 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_enabled)

Set the image smoothing.

Parameters
smoothing_enabled If true, image smoothing is enabled, otherwise it is disabled.

public void setImageSmoothing ()

Enable or disable image smoothing. The rasterizer allows a trade-off between rendering quality and rendering speed. This function can be used to indicate the preference between rendering speed and quality.

* Note: image smoothing option has effect only if the source image has higher resolution that the output resolution of the image on the rasterized page. PDFNet automatically controls at what resolution/zoom factor, 'image smoothing' needs to take effect.

* Note: image smoothing is enabled.

public void setOCGContext (Context ctx)

Set 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 PDFDraw.SetOCGContext() 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.

public void setOverprint (int op)

Enable or disable 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 enabled.

Parameters
op 0: always disabled; 1: always enabled; 2: enabled for PDF/X files only. The default is 2.

public void setPageBorderVisibility (boolean border_visible)

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

Parameters
border_visible - if true, the border will be visible.

public void setPagePresentationMode (PDFViewCtrl.PagePresentationMode mode)

Set the current page presentation mode.

Parameters
mode the new page presentation mode.

public void setPagePresentationMode (int mode)

This method is deprecated.
use setPagePresentationMode(PagePresentationMode) instead. Set the current page presentation mode.

Parameters
mode the new page presentation mode.

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

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

Parameters
horiz_col_space the horiz_col_space
vert_col_space the vert_col_space
horiz_pad the horiz_pad
vert_pad the vert_pad

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)

Set the page viewing mode.

Note: The default PageView mode is FIT_WIDTH.

Parameters
mode the new page viewing mode.

public void setPageViewMode (int mode)

This method is deprecated.
use setPageViewMode(PageViewMode) instead. Set the page viewing mode.

Note: The default PageView mode is e_fit_width.

Parameters
mode the new page viewing mode.

public void setPathHinting (boolean enable_ph)

Enable or disable path hinting. Path hinting is used to slightly adjust paths in order to avoid or alleviate artifacts of hair line cracks between certain graphical elements.

Note: Path hinting is enabled by default.

Parameters
enable_ph whether to enable or disable path hinting

public void setPreferredSize (int width, int height)

Set the preferred size.

Parameters
width the width
height the height

public void setPreferredSize (Dimension d)

public void setProgressiveRendering (boolean is_progressive)

Enables or disables progressive rendering in PDFViewCtrl.

Note: Progressive rendering is useful when a PDF page contain lots of elements (e.g. many vector paths, text, or many little images). When progressive rendering is enabled PDFNet will use painter algorithm to draw the page. This way user may be able to see partially rendered page. If a page contains only a single large image, there would be no visible benefit from progressive rendering.

Parameters
is_progressive if true, progressive rendering will be enabled, otherwise progressive rendering will be disabled.

public void setRasterizer (boolean builtin_rasterizer)

Set the core graphics library used for rasterization and rendering. Using this method it is possible to quickly switch between different implementations. By default, PDFNet uses a built-in, high-quality, and platform independent rasterizer.

Parameters
builtin_rasterizer the new rasterizer

public void setRequestRenderInWorkerThreadProc (RequestRenderInWorkerThreadProc render_worker_proc, Object data)

Sets the RequestRenderInWorkerThread Callback

Parameters
render_worker_proc RequestRenderInWorkerThread Callback
data custom data

public void setSnappingMode (int mode_flags)

Set the point snapping mode for the SnapToNearestInDoc method. By default SnapToNearestInDoc will snap to line endpoints, midpoints, and intersections.

public void setThinLineAdjustment (boolean pixel_grid_fit, boolean stroke_adjust)

Set 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 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 setToolMode (int mode)

Set the new tool mode (such as pan, text select, etc).

Parameters
mode new tool mode.

public void setUrlExtraction (boolean enabled)

Enables or disables URL extraction.

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

* Note: 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.

public void setV (int v)

public void setVScrollPos (double pos)

Sets the vertical scroll position in the scrollable space..

Note: In this context the canvas is defined in the screen coordinate system and is a rectangle that surrounds all pages in the current page layout.

Parameters
pos the new vertical scroll position. The position should be a number in the range between 0 and GetCanvasheight().

public void setVerticalAlign (int align)

Set the vertical 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 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. Note that if this function is called after the document has been rasterized, it has no effect.

Parameters
max_cache_size The maximum size, in bytes, of the entire document's page cache. Set to zero to disable the viewer cache.
on_disk If set to 'true', cache will be stored on the local filesystem. If set to 'false', cache will be stored in heap memory.

public boolean setZoom (double zoom)

Set the zoom factor to a new value. The function zooms to a point at the center of the rendering buffer.

Parameters
zoom new scaling component used to display the page content.
Returns
  • true if successful, false otherwise.

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

Set the zoom factor to a new value using the given pixel coordinate (x,y) as a zoom center. The zoom point (x,y) is represented in the screen coordinate system, which starts in the upper-left corner of the client window.

Parameters
x the horizontal coordinate to zoom in.
y the vertical coordinate to zoom in.
zoom - new scaling component used to display the page content.
Returns
  • true if successful, false otherwise.

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.

Parameters
use_embedded Enables or disables using thumbnails embedded in the PDF document as a preview of the rendered page. (Currently ignored - future versions may take advantage of embedded thumbnails)
generate_at_runtime Enables or disables generating thumbnails at runtime.
use_disk_cache Enables or disables caching thumbnails in a temporary disk file.
thumb_max_side_length The maximum size, in pixels, of a dimension of generated thumbnails.
max_abs_cache_size The absolute maximum size on disk, in bytes, for the temporary thumbnail cache.
max_perc_cache_size The maximum percentage of free disk space, in the range 0 - 1.0, that the cache can take up.

public void showAnnotation (Annot annot)

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

public boolean showRect (int page_num, Rect rect)

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

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

public boolean smartZoom (int x, int y)

Set the zoom factor to a new value using the given pixel coordinate (x,y) as a zoom center. The zoom point (x,y) is represented in the screen coordinate system, which starts in the upper-left corner of the client window.

Parameters
x the horizontal coordinate to zoom in.
y the vertical coordinate to zoom in.
Returns
  • true if successful, false otherwise.

public Point2D.Double snapToNearestInDoc (double x, double y)

Returns the point within the document geometry that is closest to another arbtrary 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 void takeSnapshot (String meta_info)

Get the state of the conversion process. Pair this with ConvertNextPage().

Parameters
meta_info -- info to be attached to this particlar undo state.

public String undo ()

Return to the previous state. Returns any meta-data associated with that state.

Returns
  • .

public void update (Annot a, int num_page)

Redraws the area covered with a given annotation.

Parameters
a the a
num_page the num_page

public void update ()

Redraws the contents of the buffer.

public void update (Rect rec)

Redraws the given area in the buffer.

Parameters
rec the rec

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 (Graphics g)

public void updatePageLayout ()

Updates the page layout within the view.