Class PDFViewCtrl
PDFViewCtrl is derived from android.view.ViewGroup and encapsulates a rich set of functionalities for interactive viewing of PDF documents. See parent class documentation here: https://www.pdftron.com/api/android/javadoc/reference/com/pdftron/pdf/PDFViewCtrl.html.
PDFViewCtrl makes use of PDFTron's PDFNet library that is compiled as a native library to ensure real-time viewing experience. It provides a comprehensive set of functionalities, including multi-threaded rendering, PDF rendering settings, scrolling, zooming, page navigation, different page viewing modes, coordinates conversion, text selection, text search, etc. In addition, PDFViewCtrl also allows for extension to accommodate a user's specific needs, which can be achieved in one of the following two ways:
- Derive from PDFViewCtrl and override its functions such as
, , , etc. However, note that since PDFViewCtrl implements these functions, it is necessary to call PDFViewCtrl's implementations first. - The recommended way is to use PDFViewCtrl's
interface. The interface provides a way for users to interact with PDFViewCtrl, including customizing responses to gestures and drawing extra contents on top of the PDF content. In fact, PDFNet SDK also ships with a separate library, Tools.dll, that is programmed via the interface. This library utilizes functions offered by PDFNet and implements several ready-to-use UI modules such as annotation editing, text selection, text search, page navigation, etc. PDFNet customers can have access to the source code of Tools.jar for full customization.
Inheritance
Namespace: pdftron.PDF
Assembly: PDFNetAndroid.dll
Syntax
public class PDFViewCtrl : PDF.PDFViewCtrl
Constructors
PDFViewCtrl(Context, IAttributeSet)
Constructor that is called when inflating a view from XML. This is called when a view is being constructed from an XML file, supplying attributes that were specified in the XML file. This version uses a default style of 0, so the only attribute values applied are those in the Context's Theme and the given AttributeSet.
Declaration
public PDFViewCtrl(Context context, IAttributeSet attrs)
Parameters
Type | Name | Description |
---|---|---|
Context | context | The Context the view is running in, through which it can access the current theme, resources, etc. |
IAttributeSet | attrs | The attributes of the XML tag that is inflating the view. |
PDFViewCtrl(Context, IAttributeSet, Int32)
Perform inflation from XML and apply a class-specific base style. This constructor of View allows subclasses to use their own base style when they are inflating. For example, a Button class's constructor would call this version of the super class constructor and supply R.attr.buttonStyle for defStyle; this allows the theme's button style to modify all of the base view attributes (in particular its background) as well as the Button class's attributes.
Declaration
public PDFViewCtrl(Context context, IAttributeSet attrs, int defStyle)
Parameters
Type | Name | Description |
---|---|---|
Context | context | The Context the view is running in, through which it can access the current theme, resources, etc. |
IAttributeSet | attrs | The attributes of the XML tag that is inflating the view. |
System.Int32 | defStyle | The default style to apply to this view. If 0, no style will be applied (beyond what is included in the theme). This may either be an attribute resource, whose value will be retrieved from the current theme, or an explicit style resource. |
Properties
CurrentPage
Gets or sets the current page.
Declaration
public virtual int CurrentPage { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 | The page number. |
Doc
Gets or sets the PDF document to be displayed.
Declaration
public virtual PDFDoc Doc { get; set; }
Property Value
Type | Description |
---|---|
PDFDoc | The document. |
Methods
CloseDoc()
Declaration
public override void CloseDoc()
ConvCanvasPtToPagePt(Point)
Converts a point in canvas space to the current page space.
Declaration
public virtual Point ConvCanvasPtToPagePt(Point pt)
Parameters
Type | Name | Description |
---|---|---|
Point | pt | The input point. |
Returns
Type | Description |
---|---|
Point | The canvas point to page point. |
ConvCanvasPtToPagePt(Point, Int32)
Converts a point in canvas space to the specified page space.
Declaration
public virtual Point ConvCanvasPtToPagePt(Point pt, int page_num)
Parameters
Type | Name | Description |
---|---|---|
Point | pt | The input point. |
System.Int32 | page_num | page number. |
Returns
Type | Description |
---|---|
Point | The canvas point to page point. |
ConvCanvasPtToScreenPt(Point)
Declaration
public virtual Point ConvCanvasPtToScreenPt(Point pt)
Parameters
Type | Name | Description |
---|---|---|
Point | pt |
Returns
Type | Description |
---|---|
Point |
ConvPagePtToCanvasPt(Point)
Converts a point in the current page space to canvas space.
Declaration
public virtual Point ConvPagePtToCanvasPt(Point pt)
Parameters
Type | Name | Description |
---|---|---|
Point | pt | The input point. |
Returns
Type | Description |
---|---|
Point | The page point to canvas point. |
ConvPagePtToCanvasPt(Point, Int32)
Converts a point in the specified page space to canvas space.
Declaration
public virtual Point ConvPagePtToCanvasPt(Point pt, int page_num)
Parameters
Type | Name | Description |
---|---|---|
Point | pt | The input point. |
System.Int32 | page_num | page number. |
Returns
Type | Description |
---|---|
Point | The page point to canvas point. |
ConvPagePtToHorizontalScrollingPt(Point, Int32)
Declaration
public virtual Point ConvPagePtToHorizontalScrollingPt(Point pt, int page_num)
Parameters
Type | Name | Description |
---|---|---|
Point | pt | |
System.Int32 | page_num |
Returns
Type | Description |
---|---|
Point |
ConvPagePtToScreenPt(Point, Int32)
Converts a point from a page space to a point in screen space.
Declaration
public virtual Point ConvPagePtToScreenPt(Point pt, int page_num)
Parameters
Type | Name | Description |
---|---|---|
Point | pt | The input point. |
System.Int32 | page_num | P2. |
Returns
Type | Description |
---|---|
Point | The page point to client point. |
ConvScreenPtToCanvasPt(Point)
Converts a point expressed in screen space to a point in (PDF) canvas space.
When converting points, PDFViewCtrl may refer to the following spaces:
- Screen Space is the virtual area occupied by PDFViewCtrl on a device, originated at its upper-left corner. Note that this space can extend beyond the visible region. Screen Space is in the same scale with the dimensions of android.view.View;
- Page Space is defined by a PDF page itself, originated at the lower-left corner. Unlike Screen Space, it is independent of how the page is viewed; namely, it does't change with the zoom factor, the scroll position, and etc.
- (PDF) Canvas Space is defined as the smallest axis-aligned rectangle surrounding all the pages in continuous page presentation mode, or the current page(s) in non-continuous page presentation mode. For example, PAGE_PRESENTATION_FACING_CONT will make a wider but shorter Canvas Space than what PAGE_PRESENTATION_SINGLE_CONT will do. Note that PDF Canvas Space is in the same scale of Page Space and also independent of zoom factor, scroll position, etc. For simplicity, PDF Canvas Space is referenced to as Canvas Space.
- Zoomed PDF Canvas Space is similar to PDF Canvas space, but after it is scaled by the current zoom factor, and page gaps are added between pages.
- View Canvas Space is the virtual region occupied by the android.graphics.Canvas object, the one passed in through the onDraw(Canvas) method. Note that View Canvas Space is in general different from Canvas Space. For example, when PDFViewCtrl is zoomed out so that all the pages are visible, View Canvas Space will be larger than Canvas Space.
Declaration
public virtual Point ConvScreenPtToCanvasPt(Point pt)
Parameters
Type | Name | Description |
---|---|---|
Point | pt | The input point. |
Returns
Type | Description |
---|---|
Point | The client point to canvas point. |
ConvScreenPtToPagePt(Point)
Converts a point expressed in screen space to a point on a page space.
Declaration
public virtual Point ConvScreenPtToPagePt(Point pt)
Parameters
Type | Name | Description |
---|---|---|
Point | pt | The input point. |
Returns
Type | Description |
---|---|
Point | The client point to page point. |
ConvScreenPtToPagePt(Point, Int32)
Converts a point expressed in screen space to a point on a page space.
Declaration
public virtual Point ConvScreenPtToPagePt(Point pt, int page_num)
Parameters
Type | Name | Description |
---|---|---|
Point | pt | The input point. |
System.Int32 | page_num | page number. |
Returns
Type | Description |
---|---|
Point | The client point to page point. |
Destroy()
Declaration
public override void Destroy()
ExecuteAction(Action)
Executes the action.
Declaration
public virtual void ExecuteAction(Action action)
Parameters
Type | Name | Description |
---|---|---|
Action | action | The action. |
GetAnnotationAt(Int32, Int32)
Gets the annotation at x and y.
Declaration
public virtual Annot GetAnnotationAt(int x, int y)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | x | The x coordinate. |
System.Int32 | y | The y coordinate. |
Returns
Type | Description |
---|---|
Annot | The Annot. |
GetAnnotationAt(Int32, Int32, Double, Double)
Gets the annotation at the (x, y) position expressed in screen coordinates.
Declaration
public virtual Annot GetAnnotationAt(int x, int y, double distanceThreshold, double minimumLineWeight)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | x | x coordinate of the screen point. |
System.Int32 | y | y coordinate of the screen point. |
System.Double | distanceThreshold | Maximum distance from the point (x, y) to the annotation for the annot to be considered a hit. |
System.Double | minimumLineWeight | For very thin lines, it is almost impossible to hit the actual line. This specifies a minimum line thickness (in screen coordinates) for the purpose of calculating whether a point is inside the annotation or not. |
Returns
Type | Description |
---|---|
Annot | The AnnotThe annotation closest to the point. If no annotation was found, it returns a null pointer. |
GetAnnotationListAt(Int32, Int32, Int32, Int32)
Declaration
public virtual List<Annot> GetAnnotationListAt(int x1, int y1, int x2, int y2)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | x1 | |
System.Int32 | y1 | |
System.Int32 | x2 | |
System.Int32 | y2 |
Returns
Type | Description |
---|---|
List<Annot> |
GetColorPostProcessMode()
Gets the color post processing transformation.
Declaration
public virtual PDFRasterizer.ColorPostProcessMode GetColorPostProcessMode()
Returns
Type | Description |
---|---|
PDFRasterizer.ColorPostProcessMode | the current color post processing mode.. |
GetDoc()
Gets the PDF document to be displayed.
Declaration
public virtual PDFDoc GetDoc()
Returns
Type | Description |
---|---|
PDFDoc | The PDFDoc |
GetPageBox()
Gets the box used by PDFViewCtrl for rasterizing.
Declaration
public virtual Page.Box GetPageBox()
Returns
Type | Description |
---|---|
Page.Box | The page box used to rasterize. See {@link #SetPageBox(Page.Box)} |
GetPageRectForAnnot(Annot, Int32)
Gets the annotation bounding box in page coordinates
Declaration
public virtual Rect GetPageRectForAnnot(Annot annot, int page_num)
Parameters
Type | Name | Description |
---|---|---|
Annot | annot | target annotation. |
System.Int32 | page_num | the page number where the annotation is on. |
Returns
Type | Description |
---|---|
Rect | The page rect for annotation. |
GetProgressiveRendering()
Declaration
public virtual bool GetProgressiveRendering()
Returns
Type | Description |
---|---|
System.Boolean |
GetRotation()
Gets the page rotation.
Declaration
public virtual Page.Rotate GetRotation()
Returns
Type | Description |
---|---|
Page.Rotate | The page rotation. |
GetScreenRectForAnnot(Annot, Int32)
Gets the annotation bounding box in screen coordinates
Declaration
public virtual Rect GetScreenRectForAnnot(Annot annot, int page_num)
Parameters
Type | Name | Description |
---|---|---|
Annot | annot | target annotation. |
System.Int32 | page_num | the page number where the annotation is on. |
Returns
Type | Description |
---|---|
Rect | The screen rect for annotation. |
HideAnnotation(Annot)
Disable rendering of a particular annotation. This does not change the annotation itself, just how it is displayed in this viewer instance.
Declaration
public virtual void HideAnnotation(Annot annot)
Parameters
Type | Name | Description |
---|---|---|
Annot | annot | The annotation object to cease drawing for. |
OpenNonPDFUri(Android.Net.Uri, PDF.WordToPDFOptions)
Declaration
public DocumentConversion OpenNonPDFUri(Android.Net.Uri uri, PDF.WordToPDFOptions options)
Parameters
Type | Name | Description |
---|---|---|
Android.Net.Uri | uri | |
pdftronprivate.PDF.WordToPDFOptions | options |
Returns
Type | Description |
---|---|
DocumentConversion |
OpenPDFUri(Android.Net.Uri, String)
Declaration
public PDFDoc OpenPDFUri(Android.Net.Uri uri, string password)
Parameters
Type | Name | Description |
---|---|---|
Android.Net.Uri | uri | |
System.String | password |
Returns
Type | Description |
---|---|
PDFDoc |
RefreshAndUpdate(ViewChangeCollection)
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.
Declaration
public virtual void RefreshAndUpdate(ViewChangeCollection viewChange)
Parameters
Type | Name | Description |
---|---|---|
ViewChangeCollection | viewChange | contains all the updated fields and rectangles. |
Select(Highlights)
Selects texts identified by Highlights.
Declaration
public virtual bool Select(Highlights hlts)
Parameters
Type | Name | Description |
---|---|---|
Highlights | hlts | The Highlights to be selected. |
Returns
Type | Description |
---|---|
System.Boolean |
|
SelectAndJumpWithHighlights(Highlights)
Selects texts identified by Highlights. Also scroll to the Highlights if selected.
Declaration
public virtual bool SelectAndJumpWithHighlights(Highlights hlts)
Parameters
Type | Name | Description |
---|---|---|
Highlights | hlts | Highlights the Highlights to be selected. |
Returns
Type | Description |
---|---|
System.Boolean |
|
SetColorPostProcessMapFile(Filter)
Declaration
public virtual void SetColorPostProcessMapFile(Filter imageFileContents)
Parameters
Type | Name | Description |
---|---|---|
Filter | imageFileContents |
SetColorPostProcessMode(PDFRasterizer.ColorPostProcessMode)
Sets the color post processing transformation. This transform is applied to the rasterized bitmap as the final step in the rasterization process, and is applied directly to the resulting bitmap (disregarding any color space information). Color post processing only supported for RGBA output.
Declaration
public virtual void SetColorPostProcessMode(PDFRasterizer.ColorPostProcessMode mode)
Parameters
Type | Name | Description |
---|---|---|
PDFRasterizer.ColorPostProcessMode | mode | the specific transform to be applied. |
SetDoc(PDFDoc)
Sets the PDF document to be displayed.
Declaration
public virtual void SetDoc(PDFDoc doc)
Parameters
Type | Name | Description |
---|---|---|
PDFDoc | doc | The PDFDoc |
SetPageBox(Page.Box)
Selects the PageBox to rasterize. PDFViewCtrl will clip pages according to their PageBox as selected here.
Declaration
public virtual void SetPageBox(Page.Box box)
Parameters
Type | Name | Description |
---|---|---|
Page.Box | box | the region to be used for clipping. Possible values are:
|
SetProgressiveRendering(Boolean)
Declaration
public virtual void SetProgressiveRendering(bool progressive)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | progressive |
SetViewerCache(SDFDoc, Int32, Boolean)
Sets the viewer cache.
Declaration
public static void SetViewerCache(SDFDoc document, int max_cache_size, bool on_disk)
Parameters
Type | Name | Description |
---|---|---|
SDFDoc | document | The maximum size, in bytes, of the entire document's page cache. |
System.Int32 | max_cache_size | Max cache size |
System.Boolean | on_disk | Whether or not store the cache on disk. |
ShowAnnotation(Annot)
Enable rendering of a particular annotation. Only has an effect if HideAnnotation() has prviously been called on the same annot.
Declaration
public virtual void ShowAnnotation(Annot annot)
Parameters
Type | Name | Description |
---|---|---|
Annot | annot | The annotation object to resume rendering. |
ShowRect(Int32, Rect)
Adjusts the viewing area to fit a rectangle on a specified page. Rectangle must be specified in page space. This will adjust current page and zoom appropriately.
Declaration
public virtual bool ShowRect(int page_num, Rect rect)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | page_num | The specified page number. |
Rect | rect | The rectangle to fit in. |
Returns
Type | Description |
---|---|
System.Boolean |
|
Update(Annot, Int32)
Redraws the area covered with a given annotation.
Declaration
public virtual void Update(Annot annot, int page_num)
Parameters
Type | Name | Description |
---|---|---|
Annot | annot | the annotation whose occupied region is to be updated. |
System.Int32 | page_num | the number of the page that the annotation belongs to. |
Update(Rect)
Redraws the given area in the client space.
Declaration
public virtual void Update(Rect rect)
Parameters
Type | Name | Description |
---|---|---|
Rect | rect |