public class PDFViewCtrl
extends javax.swing.JComponent
implements javax.swing.Scrollable
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:
Modifier and Type | Class and Description |
---|---|
static class |
PDFViewCtrl.LinkInfo
A class that holds information for a link.
|
class |
PDFViewCtrl.Selection
A class representing the current text selection.
|
Modifier and Type | Field and Description |
---|---|
static int |
e_custom
PDFViewCtrl class supports a number of 'built-in' tool modes.
|
static int |
e_facing
The Constant e_facing.
|
static int |
e_facing_continuous
The Constant e_facing_continuous.
|
static int |
e_facing_continuous_cover
The Constant e_facing_continuous_cover.
|
static int |
e_facing_cover
The Constant e_facing_cover.
|
static int |
e_fit_height
The Constant e_fit_height.
|
static int |
e_fit_page
PageViewMode lists common modes of viewing PDF pages.
|
static int |
e_fit_width
The Constant e_fit_width.
|
static int |
e_pan
The Constant e_pan.
|
static int |
e_postprocess_invert
The Constant e_postprocess_invert.
|
static int |
e_postprocess_none
The Constant e_postprocess_none.
|
static int |
e_single_continuous
The Constant e_single_continuous.
|
static int |
e_single_page
PagePresentationMode lists common modes of presenting PDF pages.
|
static int |
e_text_rect_select
The Constant e_text_rect_select.
|
static int |
e_text_struct_select
The Constant e_text_struct_select.
|
static int |
e_zoom
The Constant e_zoom.
|
TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Constructor and Description |
---|
PDFViewCtrl()
PDFViewCtrl constructor.
|
PDFViewCtrl(int preferred_width)
Instantiates a new PDFViewCtrl.
|
Modifier and Type | Method and Description |
---|---|
void |
cancelAllThumbRequests() |
void |
cancelRendering()
Cancels rendering in progress.
|
void |
clearSelection()
Remove any text selection.
|
java.awt.geom.Point2D.Double |
convCanvasPtToPagePt(double x,
double y)
Convert a point expressed in canvas space to a point in the current page
space.
|
java.awt.geom.Point2D.Double |
convCanvasPtToPagePt(double x,
double y,
int page_num)
Convert a point in canvas space to a point in a page space.
|
java.awt.geom.Point2D.Double |
convCanvasPtToScreenPt(double x,
double y)
Convert a point expressed in canvas space to a point in screen space.
|
java.awt.geom.Point2D.Double |
convPagePtToCanvasPt(double x,
double y)
Convert a point in a page space to a point in canvas space.
|
java.awt.geom.Point2D.Double |
convPagePtToCanvasPt(double x,
double y,
int page_num)
Convert a point in page space to a point in canvas space.
|
java.awt.geom.Point2D.Double |
convPagePtToScreenPt(double x,
double y)
Convert a point from a page space to screen space.
|
java.awt.geom.Point2D.Double |
convPagePtToScreenPt(double x,
double y,
int page_num)
Convert a point from a page space to a point in screen space.
|
java.awt.geom.Point2D.Double |
convScreenPtToCanvasPt(double x,
double y)
Convert a point expressed in screen space to a point in canvas space.
|
java.awt.geom.Point2D.Double |
convScreenPtToPagePt(double x,
double y)
Convert a point expressed in screen space to the current page space.
|
java.awt.geom.Point2D.Double |
convScreenPtToPagePt(double x,
double y,
int page_num)
Convert a point expressed in screen space to a point in a 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(java.lang.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 *
|
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()
Get the device transformation matrix
|
Matrix2D |
getDeviceTransform(int page_num)
Get the device transform matrix
|
PDFDoc |
getDoc()
Get the document.
|
int |
getH() |
int |
getHeight() |
double |
getHScrollPos() |
PDFViewCtrl.LinkInfo |
getLinkAt(int x,
int y)
Gets the link info at a given point, specified in client space.
|
java.lang.String |
getNextRedoInfo()
Returns any meta-data associated with the next sate in the undo chain.
|
java.lang.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.
|
java.awt.Dimension |
getPreferredScrollableViewportSize() |
java.awt.Dimension |
getPreferredSize() |
int |
getRotation()
Get the rotation.
|
Rect |
getScreenRectForAnnot(Annot annot,
int page_num)
Gets annotation bounding box in screen points
|
int |
getScrollableBlockIncrement(java.awt.Rectangle visibleRect,
int orientation,
int direction) |
boolean |
getScrollableTracksViewportHeight() |
boolean |
getScrollableTracksViewportWidth() |
int |
getScrollableUnitIncrement(java.awt.Rectangle visibleRect,
int orientation,
int direction) |
PDFViewCtrl.Selection |
getSelection(int page)
Get the selection.
|
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.
|
java.awt.Dimension |
getSize(java.awt.Dimension rv) |
void |
getThumbAsync(int page_num,
ThumbAsyncHandler proc,
java.lang.Object data) |
int |
getToolMode()
Get the tool mode.
|
int |
getV() |
PDFViewScrollPane |
getViewPane() |
double |
getVScrollPos() |
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.
|
boolean |
HasSelectionOnPage(int page)
Checks for selection on page.
|
void |
hideAnnotation(Annot annot)
Disable rendering of a particular annotation.
|
void |
invalidateRect()
The InvalidateRect function adds a rectangle to the buffer/window update
region.
|
void |
invalidateRect(Rect rect)
Invalidate rect.
|
boolean |
isFinishedRendering() |
void |
onScroll(int pix_dx,
int pix_dy)
Scrolls the contents of the rendering buffer 'pix_dx' horizontally and
'pix_dy' vertically.
|
java.lang.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(java.awt.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(java.awt.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)
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,
java.lang.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(java.awt.Color c)
Set the default 'paper' color used to draw background of each page.
|
void |
setDevicePixelDensity(double dpi,
double scale_factor)
Set device pixel density
|
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,
java.lang.Object data)
Set the error report process
|
void |
setFindTextHandler(FindTextProc proc,
java.lang.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 |
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 |
setHScrollPos(double pos)
Sets the horizontal scroll position in the scrollable space..
|
void |
setImageSmoothing()
Enable or disable image smoothing.
|
void |
setImageSmoothing(boolean smoothing_enabled)
Set the 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(int mode)
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(int mode)
Set the page viewing mode.
|
void |
setPathHinting(boolean enable_ph)
Enable or disable path hinting.
|
void |
setPreferredSize(java.awt.Dimension d) |
void |
setPreferredSize(int width,
int height)
Set the preferred size.
|
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,
java.lang.Object data)
Sets the RequestRenderInWorkerThread Callback
|
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 |
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 |
setUrlExtraction(boolean enabled)
Enables or disables URL extraction.
|
void |
setV(int v) |
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.
|
void |
setVScrollPos(double pos)
Sets the vertical scroll position in the scrollable space..
|
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 |
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.
|
void |
takeSnapshot(java.lang.String meta_info)
Get the state of the conversion process.
|
java.lang.String |
undo()
Return to the previous state.
|
void |
update()
Redraws the contents of the buffer.
|
void |
update(Annot a,
int num_page)
Redraws the area covered with a given annotation.
|
void |
update(Field field)
Redraws all instances (Widgets) of the field.
|
void |
update(java.awt.Graphics g) |
void |
update(Rect rec)
Redraws the given area in the buffer.
|
void |
updatePageLayout()
Updates the page layout within the view.
|
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setRequestFocusEnabled, setToolTipText, setTransferHandler, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateUI
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
public static final int e_fit_page
public static final int e_fit_width
public static final int e_fit_height
public static final int e_zoom
public static final int e_single_page
public static final int e_single_continuous
public static final int e_facing
public static final int e_facing_continuous
public static final int e_facing_cover
public static final int e_facing_continuous_cover
public static final int e_postprocess_none
public static final int e_postprocess_invert
public static final int e_custom
public static final int e_pan
public static final int e_text_rect_select
public static final int e_text_struct_select
public PDFViewCtrl()
public PDFViewCtrl(int preferred_width)
preferred_width
- the preferred PDFViewCtrl widthpublic int getH()
public int getV()
public void setH(int h)
public void setV(int v)
public PDFViewScrollPane getViewPane()
public void setToolMode(int mode)
mode
- new tool mode.public void refreshAndUpdate(ViewChangeCollection view_change) throws PDFNetException
view_change
- contains all the updated fields and rectangles.PDFNetException
public void setDoc(PDFDoc doc)
Note: Acquires a write lock on the document
doc
- A document to be displayed in the view.public void enableUndoRedo() throws PDFNetException
PDFNetException
public java.lang.String undo() throws PDFNetException
PDFNetException
public java.lang.String redo() throws PDFNetException
PDFNetException
public void takeSnapshot(java.lang.String meta_info) throws PDFNetException
meta_info
- -- info to be attached to this particlar undo state.PDFNetException
public java.lang.String getNextUndoInfo() throws PDFNetException
PDFNetException
public java.lang.String getNextRedoInfo() throws PDFNetException
PDFNetException
public void revertAllChanges() throws PDFNetException
PDFNetException
public int getWidth()
getWidth
in class javax.swing.JComponent
public int getHeight()
getHeight
in class javax.swing.JComponent
public java.awt.Dimension getSize(java.awt.Dimension rv)
getSize
in class javax.swing.JComponent
public void destroy()
public PDFDoc getDoc()
public void docLock(boolean cancel_thread)
public void docUnlock()
public boolean docTryLock(int milliseconds)
public void docLockRead()
public void docUnlockRead()
public boolean docTryLockRead(int milliseconds)
public void setPageViewMode(int mode)
Note: The default PageView mode is e_fit_width.
mode
- the new page viewing mode.public int getPageViewMode()
public void setPagePresentationMode(int mode)
mode
- the new page presentation mode.public int getPagePresentationMode()
public void setColorPostProcessMode(int mode)
mode
- is the specific transform to be appliedpublic int getColorPostProcessMode()
public int getCurrentPage()
public int getPageCount()
public void scrollRectToVisible(java.awt.Rectangle r)
scrollRectToVisible
in class javax.swing.JComponent
public boolean gotoFirstPage()
public boolean gotoLastPage()
public boolean gotoNextPage()
public boolean gotoPreviousPage()
public boolean setCurrentPage(int page_num)
page_num
- input page numberpublic boolean showRect(int page_num, Rect rect)
page_num
- input page numberrect
- the rectangle to fit inpublic double getZoom()
public boolean setZoom(double zoom)
zoom
- new scaling component used to display the page content.public boolean setZoom(int x, int y, double zoom)
x
- the horizontal coordinate to zoom in.y
- the vertical coordinate to zoom in.zoom
- - new scaling component used to display the page content.public boolean smartZoom(int x, int y)
x
- the horizontal coordinate to zoom in.y
- the vertical coordinate to zoom in.public void rotateClockwise()
public void rotateCounterClockwise()
public int getPageNumberFromScreenPt(double x, double y)
x
- x coordinate of the screen pointy
- y coordinate of the screen pointpublic java.awt.geom.Point2D.Double convScreenPtToCanvasPt(double x, double y)
x
- x coordinate of the screen pointy
- y coordinate of the screen pointpublic java.awt.geom.Point2D.Double convCanvasPtToScreenPt(double x, double y)
x
- x coordinate of the canvas pointy
- y coordinate of the canvas pointpublic java.awt.geom.Point2D.Double convCanvasPtToPagePt(double x, double y)
x
- x coordinate of the canvas pointy
- y coordinate of the canvas pointpublic java.awt.geom.Point2D.Double convCanvasPtToPagePt(double x, double y, int page_num)
x
- x coordinate of the canvas pointy
- y coordinate of the canvas pointpage_num
- the page number for the page used as the origin of the
destination coordinate system. Pages are indexed starting from 1.public java.awt.geom.Point2D.Double convPagePtToCanvasPt(double x, double y)
x
- x coordinate of point on current pagey
- y coordinate of point on current pagepublic java.awt.geom.Point2D.Double convPagePtToCanvasPt(double x, double y, int page_num)
x
- x coordinate of the point on the specified pagey
- y coordinate of the point on the specified pagepage_num
- input page numberpublic java.awt.geom.Point2D.Double convScreenPtToPagePt(double x, double y)
x
- x coordinate of the screen pointy
- y coordinate of the screen pointpublic java.awt.geom.Point2D.Double convScreenPtToPagePt(double x, double y, int page_num)
x
- x coordinate of the screen pointy
- y coordinate of the screen pointpage_num
- the input page numberpublic java.awt.geom.Point2D.Double convPagePtToScreenPt(double x, double y)
x
- x coordinate of the point on the current pagey
- y coordinate of the point on the current pagepublic java.awt.geom.Point2D.Double convPagePtToScreenPt(double x, double y, int page_num)
x
- x coordinate of the point on the specified pagey
- y coordinate of the point on the specified pagepage_num
- input page numberpublic Matrix2D getDeviceTransform()
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();
public Matrix2D getDeviceTransform(int page_num)
page_num
- the page number for the page used as the origin of the
destination coordinate system.public void setErrorReportProc(ErrorReportProc error_proc, java.lang.Object data)
error_proc
- error processdata
- custom datapublic void setRequestRenderInWorkerThreadProc(RequestRenderInWorkerThreadProc render_worker_proc, java.lang.Object data)
render_worker_proc
- RequestRenderInWorkerThread Callbackdata
- custom datapublic void cancelAllThumbRequests()
public void setCurrentPageProc(CurrentPageProc curr_pagenum_proc, java.lang.Object data)
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 double getCanvasWidth()
public double getCanvasHeight()
public double getHScrollPos()
public double getVScrollPos()
public void onScroll(int pix_dx, int pix_dy)
pix_dx
- horizontal scroll offset, in pixelspix_dy
- vertical scroll offset, in pixelspublic void setHScrollPos(double pos)
pos
- the new horizontal scroll position. The position should be a
number in the range between 0 and GetCanvasWidth().public void setVScrollPos(double pos)
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.
pos
- the new vertical scroll position. The position should be a number
in the range between 0 and GetCanvasheight().public boolean isFinishedRendering()
public void cancelRendering()
public void updatePageLayout()
public void update()
public void update(Rect rec)
rec
- the recpublic void update(Annot a, int num_page)
a
- the anum_page
- the num_pagepublic void update(Field field)
field
- the field for which to update all occurancespublic int getBufferWidth()
Note: this method is typically used only in PDFNet for C++
public int getBufferHeight()
Note: this method is typically used only in PDFNet for C++
public int getBufferStride()
Note: this method is typically used only in PDFNet for C++
public void invalidateRect()
public void invalidateRect(Rect rect)
rect
- the rectpublic void hideAnnotation(Annot annot)
annot_obj
- The annotation object to cease drawing for.public void showAnnotation(Annot annot)
annot_obj
- The annotation object to resume rendering.public void setDrawAnnotations(boolean render_annots)
render_annots
- True to draw annotations, false otherwise.public void setHighlightFields(boolean highlight_fields)
highlight_fields
- true to highlight, false otherwise.public void setAntiAliasing(boolean enable_aa)
Note: Anti-aliasing is enabled by default.
enable_aa
- the new anti aliasingpublic void setPathHinting(boolean enable_ph)
Note: Path hinting is enabled by default.
enable_ph
- whether to enable or disable path hintingpublic void setThinLineAdjustment(boolean pixel_grid_fit, boolean stroke_adjust)
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 setImageSmoothing()
* 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 setImageSmoothing(boolean smoothing_enabled)
smoothing_enabled
- If true, image smoothing is enabled, otherwise
it is disabled.public void setCaching(boolean enabled)
Note: by default caching is enabled
enabled
- if true caching is enabled, if false caching is disabled.public void setUrlExtraction(boolean enabled)
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 PDFViewCtrl.LinkInfo getLinkAt(int x, int y)
Note: To get valid links, setUrlExtraction(boolean)
must be set
to true before setting the document.
x
- the x position in client spacey
- the y position in client spacePDFViewCtrl.LinkInfo
object with the link information or null if
no link is found in the queried location.public void setRasterizer(boolean builtin_rasterizer)
builtin_rasterizer
- the new rasterizerpublic void setGamma(double exp)
Note: Gamma correction is used only in the built-in rasterizer.
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 setOverprint(int op) throws PDFNetException
op
- 0: always disabled; 1: always enabled; 2: enabled for PDF/X
files only. The default is 2.PDFNetException
public void setOCGContext(Context ctx) throws PDFNetException
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.
ctx
- Optional Content Group (OCG) context, or NULL if the
rasterizer should render all content on the page.PDFNetException
public Context getOCGContext() throws PDFNetException
PDFNetException
public int getToolMode()
public boolean selectByRect(double x1, double y1, double x2, double y2)
x1
- the x1y1
- the y1x2
- the x2y2
- the y2public boolean selectByStruct(double x1, double y1, double x2, double y2)
x1
- the x1y1
- the y1x2
- the x2y2
- the y2public boolean selectByHighlights(Highlights hlts)
hlts
- - the Highlights to be selected.public boolean selectBySelection(PDFViewCtrl.Selection sel)
sel
- - the PDFViewCtrl.Selection to be selected.public void selectAll()
public void findTextAsync(java.lang.String search_str, boolean match_case, boolean match_whole_word, boolean search_up, boolean reg_exp)
search_str
- -match_case
- -match_whole_word
- -search_up
- -reg_exp
- - use regular expressionspublic void setFindTextHandler(FindTextProc proc, java.lang.Object data)
proc
- Callback function (or a delegate in .NET).data
- Custom data to be passed as a parameter to 'findtext_proc'.public boolean hasSelection()
public void clearSelection()
public PDFViewCtrl.Selection getSelection(int page)
page
- the pagepublic int GetSelectionBeginPage()
public int GetSelectionEndPage()
public boolean HasSelectionOnPage(int page)
page
- the pagepublic void setPageBorderVisibility(boolean border_visible)
border_visible
- - if true, the border will be visible.public void setPageTransparencyGrid(boolean trans_grid_visible)
trans_grid_visible
- - if true, the grid is turned on.public void setDefaultPageColor(byte r, byte g, byte b)
r
- the rg
- the gb
- the bpublic void setDefaultPageColor(java.awt.Color c)
c
- the new default page colorpublic void setBackgroundColor(byte r, byte g, byte b)
r
- the rg
- the gb
- the bpublic void setBackground(java.awt.Color c)
setBackground
in class javax.swing.JComponent
c
- the new backgroundpublic void setHorizontalAlign(int align)
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 setVerticalAlign(int align)
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 setPageSpacing(int horiz_col_space, int vert_col_space, int horiz_pad, int vert_pad)
horiz_col_space
- the horiz_col_spacevert_col_space
- the vert_col_spacehoriz_pad
- the horiz_padvert_pad
- the vert_padpublic void setDevicePixelDensity(double dpi, double scale_factor)
dpi
- the device pixel densitypublic Rect getScreenRectForAnnot(Annot annot, int page_num)
annot
- target annotationpage_num
- the page where the annotation is onpublic Annot getAnnotationAt(int x, int y)
Note: For details about client space, please refer to
convScreenPtToCanvasPt(double, double)
.
x
- x coordinate of the screen pointy
- y coordinate of the screen pointpublic Annot getAnnotationAt(int x, int y, double distanceThreshold, double minimumLineWeight)
x
- x coordinate of the screen pointy
- y coordinate of the screen pointdistanceThreshold
- 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.public Annot[] getAnnotationListAt(int x1, int y1, int x2, int y2)
x1
- x coordinate of the screen point at one of the end points of the liney1
- y coordinate of the screen point at one of the end points of the linex2
- x coordinate of the screen point at another end point of the liney2
- y coordinate of the screen point at another end point of the linepublic void setProgressiveRendering(boolean is_progressive)
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.
is_progressive
- if true, progressive rendering will be enabled,
otherwise progressive rendering will be disabled.public int getRotation() throws PDFNetException
PDFNetException
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)
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 getThumbAsync(int page_num, ThumbAsyncHandler proc, java.lang.Object data)
public static void setViewerCache(SDFDoc document, int max_cache_size, boolean on_disk) throws PDFNetException
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.PDFNetException
public void setPreferredSize(java.awt.Dimension d)
setPreferredSize
in class javax.swing.JComponent
public void setPreferredSize(int width, int height)
width
- the widthheight
- the heightpublic java.awt.Dimension getPreferredSize()
getPreferredSize
in class javax.swing.JComponent
public java.awt.Dimension getPreferredScrollableViewportSize()
getPreferredScrollableViewportSize
in interface javax.swing.Scrollable
public int getScrollableUnitIncrement(java.awt.Rectangle visibleRect, int orientation, int direction)
getScrollableUnitIncrement
in interface javax.swing.Scrollable
public int getScrollableBlockIncrement(java.awt.Rectangle visibleRect, int orientation, int direction)
getScrollableBlockIncrement
in interface javax.swing.Scrollable
public boolean getScrollableTracksViewportWidth()
getScrollableTracksViewportWidth
in interface javax.swing.Scrollable
public boolean getScrollableTracksViewportHeight()
getScrollableTracksViewportHeight
in interface javax.swing.Scrollable
public void update(java.awt.Graphics g)
update
in class javax.swing.JComponent