public class

ViewerUtils

extends Object
java.lang.Object
   ↳ com.pdftron.pdf.utils.ViewerUtils

Class Overview

A utility class for pdf viewer

Summary

Public Constructors
ViewerUtils()
Public Methods
static void animateScreenRect(PDFViewCtrl pdfViewCtrl, Rect screenRect)
static void animateUndoRedo(PDFViewCtrl pdfViewCtrl, Rect annotRect, int pageNum)
Animates for showing undo/redo action.
static boolean checkImageIntent(Map imageIntent)
Checks whether the internal image intent map is valid.
static StateListDrawable createBackgroundSelector(Drawable drawable)
static void createFileAttachment(Activity activity, Intent data, PDFViewCtrl pdfViewCtrl, PointF targetPoint)
static void createImageSignature(Activity activity, Intent data, PDFViewCtrl pdfViewCtrl, Uri outputFileUri, PointF targetPoint, int targetPage, Long widget)
static void createImageStamp(Activity activity, Intent data, PDFViewCtrl pdfViewCtrl, Uri outputFileUri, PointF imageStampTargetPoint)
static String exportFileAttachment(PDFViewCtrl pdfViewCtrl, FileAttachment attachment, File directory)
static String exportFileAttachment(PDFViewCtrl pdfViewCtrl, FileAttachment attachment)
static String extractFileFromPortfolio(int type, Context context, PDFDoc portfolioDoc, String destFolderPath, String fileName)
static extractFileFromPortfolioDisposable(int type, Context context, PDFDoc portfolioDoc, String destFolderPath, String fileName)
static void flattenDoc(PDFDoc doc)
static Annot getAnnotById(PDFViewCtrl ctrl, String id, int pageNum)
Returns annotation by providing its ID.
static BitmapDrawable getBitmapDrawable(Context context, int drawableId, int width, int height, int targetColor, boolean roundedCorner)
static BitmapDrawable getBitmapDrawable(Context context, int drawableId, int width, int height, int targetColor, boolean roundedCorner, boolean nonWhiteOnly)
static Bitmap getImageBitmap(Context context, Map imageIntent)
Returns the image bitmap.
static String getImageFilePath(Map imageIntent)
Returns the image file path.
static Uri getImageUri(Map imageIntent)
Returns the image URI
static Uri getImageUriFromIntent(Intent data, Activity activity, Uri outputFileUri)
static int getLastPageForURL(Context context, String url)
static ArrayList<MenuEditorItem> getMenuEditorItemsArray(String savedToolbarMenu)
static String getMenuEditorItemsJSON(ArrayList<MenuEditorItem> newMenuItems)
static String getSelectedString(PDFViewCtrl pdfViewCtrl)
Returns selected text in pdf
static String imageIntentToPdf(Context context, Uri imageUri, String imagePath, ExternalFileInfo documentFile)
Converts image to PDF from an image intent
static String imageIntentToPdf(Context context, Uri imageUri, String imagePath, String outputPath)
Converts image to PDF from an image intent
static boolean isImageFromCamera(Map imageIntent)
Checks whether the image is taken from camera.
static boolean isViewerZoomed(PDFViewCtrl pdfViewCtrl)
Checks whether the PDFViewCtrl is zoomed.
static void jumpToAnnotation(PDFViewCtrl pdfViewCtrl, Annot annot, int pageNum)
Jumps to the specified annotation.
static void openFileIntent(Fragment fragment)
Send a generic file picker intent
static void openFileIntent(Activity activity, Fragment fragment)
Send a generic file picker intent
static void openFileIntent(Activity activity)
Send a generic file picker intent
static Uri openImageIntent(Fragment fragment)
static Uri openImageIntent(Activity activity)
static void passwordDoc(PDFDoc doc, String password)
static Map readImageIntent(Intent data, Context context, Uri outputFileUri)
Reads an image intent.
static Rect scrollToAnnotRect(PDFViewCtrl pdfViewCtrl, Rect annotRect, int pageNum)
Scroll to annotation rect.
static void setLastPageForURL(Context context, String url, int page)
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public ViewerUtils ()

Public Methods

public static void animateScreenRect (PDFViewCtrl pdfViewCtrl, Rect screenRect)

public static void animateUndoRedo (PDFViewCtrl pdfViewCtrl, Rect annotRect, int pageNum)

Animates for showing undo/redo action.

Parameters
pdfViewCtrl The PDFViewCtrl
annotRect The annotation rectangle to be animated
pageNum The page number

public static boolean checkImageIntent (Map imageIntent)

Checks whether the internal image intent map is valid.

Parameters
imageIntent The internal image intent map obtained from readImageIntent(Intent, Context, Uri)
Returns
  • True if the internal image intent is valid

public static StateListDrawable createBackgroundSelector (Drawable drawable)

public static void createFileAttachment (Activity activity, Intent data, PDFViewCtrl pdfViewCtrl, PointF targetPoint)

public static void createImageSignature (Activity activity, Intent data, PDFViewCtrl pdfViewCtrl, Uri outputFileUri, PointF targetPoint, int targetPage, Long widget)

public static void createImageStamp (Activity activity, Intent data, PDFViewCtrl pdfViewCtrl, Uri outputFileUri, PointF imageStampTargetPoint)

public static String exportFileAttachment (PDFViewCtrl pdfViewCtrl, FileAttachment attachment, File directory)

public static String exportFileAttachment (PDFViewCtrl pdfViewCtrl, FileAttachment attachment)

public static String extractFileFromPortfolio (int type, Context context, PDFDoc portfolioDoc, String destFolderPath, String fileName)

public static extractFileFromPortfolioDisposable (int type, Context context, PDFDoc portfolioDoc, String destFolderPath, String fileName)

public static void flattenDoc (PDFDoc doc)

public static Annot getAnnotById (PDFViewCtrl ctrl, String id, int pageNum)

Returns annotation by providing its ID.

Parameters
ctrl The PDFViewCtrl
id The ID of the annotation
pageNum The page number
Returns
  • The annotation having the specified ID

public static BitmapDrawable getBitmapDrawable (Context context, int drawableId, int width, int height, int targetColor, boolean roundedCorner)

public static BitmapDrawable getBitmapDrawable (Context context, int drawableId, int width, int height, int targetColor, boolean roundedCorner, boolean nonWhiteOnly)

public static Bitmap getImageBitmap (Context context, Map imageIntent)

Returns the image bitmap.

Parameters
context The context
imageIntent The internal image intent map obtained from readImageIntent(Intent, Context, Uri)
Returns
  • The image bitmap

public static String getImageFilePath (Map imageIntent)

Returns the image file path.

Parameters
imageIntent The internal image intent map obtained from readImageIntent(Intent, Context, Uri)
Returns
  • The image file path

public static Uri getImageUri (Map imageIntent)

Returns the image URI

Parameters
imageIntent The internal image intent map obtained from readImageIntent(Intent, Context, Uri)
Returns
  • The image URI

public static Uri getImageUriFromIntent (Intent data, Activity activity, Uri outputFileUri)

public static int getLastPageForURL (Context context, String url)

public static ArrayList<MenuEditorItem> getMenuEditorItemsArray (String savedToolbarMenu)

Throws
JSONException

public static String getMenuEditorItemsJSON (ArrayList<MenuEditorItem> newMenuItems)

Throws
JSONException

public static String getSelectedString (PDFViewCtrl pdfViewCtrl)

Returns selected text in pdf

Parameters
pdfViewCtrl The PDFViewCtrl
Returns
  • The selected text in pdf

public static String imageIntentToPdf (Context context, Uri imageUri, String imagePath, ExternalFileInfo documentFile)

Converts image to PDF from an image intent

Parameters
context the context
imageUri the image intent
imagePath the image path
documentFile the result file path
Returns
  • null if failed, otherwise returns the result file path
Throws
IOException
PDFNetException

public static String imageIntentToPdf (Context context, Uri imageUri, String imagePath, String outputPath)

Converts image to PDF from an image intent

Parameters
context the context
imagePath the image intent
outputPath the result file path
Returns
  • null if failed, otherwise returns the result file path
Throws
FileNotFoundException
PDFNetException

public static boolean isImageFromCamera (Map imageIntent)

Checks whether the image is taken from camera.

Parameters
imageIntent The internal image intent map obtained from readImageIntent(Intent, Context, Uri)
Returns
  • True if the image is taken from camera

public static boolean isViewerZoomed (PDFViewCtrl pdfViewCtrl)

Checks whether the PDFViewCtrl is zoomed.

Parameters
pdfViewCtrl The PDFViewCtrl
Returns
  • True if the PDFViewCtrl is zoomed

public static void jumpToAnnotation (PDFViewCtrl pdfViewCtrl, Annot annot, int pageNum)

Jumps to the specified annotation.

Parameters
pdfViewCtrl The PDFViewCtrl
annot The annotation
pageNum The page number where the annotation is on

public static void openFileIntent (Fragment fragment)

Send a generic file picker intent

Parameters
fragment the fragment

public static void openFileIntent (Activity activity, Fragment fragment)

Send a generic file picker intent

Parameters
activity the activity
fragment the fragment

public static void openFileIntent (Activity activity)

Send a generic file picker intent

Parameters
activity the activity

public static Uri openImageIntent (Fragment fragment)

Parameters
fragment the fragment in which you can expect onActivityResult will be called with request code PICK_PHOTO_CAM
Returns
  • the output file Uri

public static Uri openImageIntent (Activity activity)

Parameters
activity the activity in which you can expect onActivityResult will be called with request code PICK_PHOTO_CAM
Returns
  • the output file Uri

public static void passwordDoc (PDFDoc doc, String password)

public static Map readImageIntent (Intent data, Context context, Uri outputFileUri)

Reads an image intent.

Parameters
data The intent
context The context
outputFileUri The output URI
Returns
  • The internal image intent map
Throws
FileNotFoundException FileNotFound exception

public static Rect scrollToAnnotRect (PDFViewCtrl pdfViewCtrl, Rect annotRect, int pageNum)

Scroll to annotation rect.

Parameters
pdfViewCtrl the PDFViewCtrl
annotRect the annot rect
pageNum the annot page number
Returns
  • final rect in client space after scrolling
Throws
PDFNetException PDFNet exception

public static void setLastPageForURL (Context context, String url, int page)