public class

AnnotUtils

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

Class Overview

A utility class for handling annotation.

Summary

Nested Classes
interface AnnotUtils.AnnotVisitor Visitor that visits annotations on a single page or in an entire document. 
interface AnnotUtils.AnnotWithPageVisitor Visitor that visits annotations on a single page or in an entire document. 
interface AnnotUtils.PageVisitor Visitor that visits pages within a document. 
Constants
String KEY_INK_LIST
String XFDF_ADD
String XFDF_DELETE
String XFDF_MODIFY
Fields
public static String KEY_ANNOT_ROTATION
public static String KEY_FreeTextDate
public static String KEY_FreeTextFill
public static String KEY_InReplyTo
public static String KEY_NM
public static String KEY_RawRichContent
public static String KEY_ReplyTo
public static String KEY_RichContent
public static String KEY_UNROTATED_BBOX
public static String KEY_WidgetAuthor
public static String Key_State
public static String Key_StateAccepted
public static String Key_StateCancelled
public static String Key_StateCompleted
public static String Key_StateModel
public static String Key_StateModelMarked
public static String Key_StateModelReview
public static String Key_StateNone
public static String Key_StateRejected
public static String VALUE_Group
public static double sMinBitmapAppearanceDPI
Public Constructors
AnnotUtils()
Public Methods
static void applyCustomFreeTextAppearance(PDFViewCtrl pdfViewCtrl, AutoScrollEditText editText, Annot annot, int pageNum)
Applies custom appearance for a FreeText with custom spacing annotation.
static void applyRedaction(PDFViewCtrl pdfViewCtrl, Redaction redactAnnot, ArrayList<Redactor.Redaction> arr)
static boolean canUseBitmapAppearance(Annot annot)
A read lock is expected around this method.
static int compareCreationDate(Annot thisObj, Annot thatObj)
static int compareDate(Annot thisObj, Annot thatObj)
static Rect computeAnnotInbox(PDFViewCtrl pdfViewCtrl, Annot annot, int pg)
Returns the bounding box of the specified annotation in screen space.
static void createAnnotationGroup(PDFViewCtrl pdfViewCtrl, Annot primary, ArrayList<Annot> allInGroup)
Creates a group of annotations
static Annot createAnnotationReply(String parentAnnotId, int pageNum, PDFViewCtrl pdfViewCtrl, String authorId, String contents)
static Annot createAnnotationStateReply(String parentAnnotId, int pageNum, PDFViewCtrl pdfViewCtrl, String authorId, String authorName, AnnotReviewState state)
static void createCustomFreeTextAppearance(View view, PDFViewCtrl pdfViewCtrl, Annot annot, int pageNum, Rect bbox, boolean useBBoxLocation, AnnotStyle annotStyle)
static void createCustomFreeTextAppearance(View view, PDFViewCtrl pdfViewCtrl, Annot annot, int pageNum, Rect bbox)
Applies custom appearance for a FreeText annotation that is generated from Android EditText Note 1: This API only takes effect on KitKit and above Note 2: A write lock is expected around this call
static void createCustomFreeTextAppearance(View view, PDFViewCtrl pdfViewCtrl, Annot annot, int pageNum, Rect bbox, boolean useBBoxLocation)
Applies custom appearance for a FreeText annotation that is generated from Android EditText Note 1: This API only takes effect on KitKit and above Note 2: A write lock is expected around this call
static File createPdfFromView(View content, int width, int height, File outputFile)
Attempts to create a new single page PDF document using the appearance from an Android view.
static void createRCFreeTextAppearance(PTRichEditor richEditor, PDFViewCtrl pdfViewCtrl, Annot annot, int pageNum, AnnotStyle annotStyle)
Creates the FreeText appearance from PTRichEditor This method does not lock document, a write lock should be acquired outside
static String createScreenshot(File tempDir, PDFDoc pdfDoc, Annot annot, int pageNum)
Static function to create a screenshot out of the bounds of an annot rect bbox.
static createScreenshotAsync(File tempDir, PDFDoc pdfDoc, Annot annot, int annotPageNumber)
Asyncronous method for creating screenshots, as some complex files might take some time to render.
static void createSoundAnnotation(PDFViewCtrl pdfViewCtrl, PointF targetPagePoint, int pageNum, String outputFile)
static void deleteAllAnnotsByType(PDFDoc doc, int type)
static void deleteAnnotationReply(String replyId, int pageNum, PDFViewCtrl pdfViewCtrl, ToolManager toolManager)
static Rect deserializeRect(String rectStr)
static Annot flattenAnnot(PDFViewCtrl pdfViewCtrl, Annot annot, int pageNum)
Flattens an annotation.
static Rect getActualUnrotatedBBox(PDFViewCtrl pdfViewCtrl, Annot annot, int pageNum)
static ArrayList<Pair<Redaction, Integer>> getAllRedactions(PDFViewCtrl pdfViewCtrl)
static int getAnnotBaseRotation(PDFViewCtrl pdfViewCtrl, int pageNumber)
Viewer and page rotation
static int getAnnotColor(Annot annot)
Returns the annotation color of the specified annotation.
static String getAnnotContents(PDFDoc pdfDoc, Annot annot)
static int getAnnotImageResId(int type)
Returns the annotation image resource ID.
static Date getAnnotLocalCreationDate(Annot annot)
Gets the annotation creation date in local date time
static Date getAnnotLocalDate(Annot annot)
Gets the annotation date in local date time
static float getAnnotOpacity(Annot annot)
Returns the annotation opacity of the specified annotation.
static int getAnnotRotation(Annot annot)
A read lock is needed around this method.
static int getAnnotRotationRelToPage(PDFViewCtrl pdfViewCtrl, Annot annot, int pageNumber)
Annotation rotation reletive to page and viewer rotation
static AnnotStyle getAnnotStyle(Annot annot)
Gets the annot style A read lock is required for this function.
static int getAnnotType(Annot annot)
static String getAnnotTypeAsPluralString(Annot annot)
Returns annotation type as raw plural string (not localized).
static String getAnnotTypeAsPluralString(Context context, Annot annot)
Returns annotation type as string.
static String getAnnotTypeAsString(Annot annot)
Returns annotation type as raw string (not localized).
static String getAnnotTypeAsString(Context context, int typeId)
Returns annotation type as string.
static String getAnnotTypeAsString(Context context, Annot annot)
Returns annotation type as string.
static int getAnnotUIRotation(PDFViewCtrl pdfViewCtrl, Annot annot, int pageNumber)
Gets annotation rotation used in UI, read lock is not required.
static Bitmap getAnnotationAppearance(PDFViewCtrl pdfViewCtrl, Annot annot)
static getAnnotationAppearanceAsync(PDFViewCtrl pdfViewCtrl, Annot annot)
static int getAnnotationCountOnPage(PDFViewCtrl pdfViewCtrl, int pageNum, ArrayList<Integer> excludeType)
Gets annotation count on page excluding certain types A read lock should be acquired outside of this method
static ArrayList<Annot> getAnnotationsInGroup(PDFViewCtrl pdfViewCtrl, Annot annot, int pageNum)
Returns all annotations in this group if the annotation passed in is in an annotation group
static Annot getAssociatedAnnotation(PDFViewCtrl pdfViewCtrl, SignatureWidget signatureWidget, int pageNum)
Checks if the signature widget overlaps with a signature annotation within a certain distance Used to check if any annotations should be linked to the widget
static String getAuthor(Annot annot)
Gets the author for the specified annotation.
static String getCurrentTime(String format)
static FileAttachment getFileAttachment(PDFViewCtrl pdfViewCtrl, Annot annot)
static double getFormFieldBackgroundOpacity(Annot annot)
static String getIRTAsString(Annot annot)
Gets the unique Id of the IRT parent annotation of this annotation
static LineEndingStyle getLineEndingStyle(Line line, boolean lineStart)
static Date getLocalDate(Date date)
Converts a com.pdftron.pdf.Date to local Date object
static Rect getOldAnnotScreenPosition(PDFViewCtrl pdfViewCtrl, Annot annot, int annotPageNum)
static Rect getPageRectFromScreenRect(PDFViewCtrl pdfViewCtrl, Rect screenRect, int pg)
static Rect getPageRectFromScreenRect(PDFViewCtrl pdfViewCtrl, Rect screenRect, int pg, int rotation)
static ArrayList<Point> getPolyVertices(Annot annot)
Gets the vertices of a Polyline or a Polygon.
static Annot getPrimaryAnnotInGroup(PDFViewCtrl pdfViewCtrl, ArrayList<Annot> annots)
static ArrayList<Redactor.Redaction> getRedactionArray(Redaction redactAnnot, int annotPageNum)
static RectF getScreenRectFromPageRect(PDFViewCtrl pdfViewCtrl, Rect pageRect, int pg)
static int getStampDegree(Annot annot)
Gets the rotation degree from Stamp annotation.
static int getStampDegreeOld(Annot annot)
Gets the deprecated rotation degree from Stamp annotation.
static double[] getStampSize(Context context, String stampName)
Gets the page corresponding to a certain stamp in our stamps repository.
static Bitmap getStandardStampBitmapFromPdf(Context context, String stampLabel, int bgColor, int height)
static String getStandardStampImageFileFromName(Context context, StandardStampPreviewAppearance stampPreviewAppearance, int height)
static Rect getUnrotatedBBox(Annot annot)
A read lock is required.
static boolean hasPermission(PDFDoc pdfDoc, ToolManager toolManager, Annot annot, int kind)
static boolean hasPermission(PDFViewCtrl pdfViewCtrl, Annot annot, int kind)
Checks whether the annotation has the specified permission
static boolean hasPermission(PDFViewCtrl pdfViewCtrl, PDFDoc pdfDoc, ToolManager tm, Annot annot, int kind)
static boolean hasReplyTypeGroup(Annot annot)
Checks if the annotation is part of a group annotation
static boolean hasReplyTypeReply(Annot annot)
Checks if the annotation is an annotation reply
static boolean hasRotation(Annot annot)
Gets whether the annotation rotation is not a multiple of 90 A read lock is needed around this method.
static boolean hasRotation(PDFViewCtrl pdfViewCtrl, Annot annot)
Gets whether the annotation rotation is not a multiple of 90
static boolean isAreaMeasure(Annot annot)
Checks if the annotation is area measurement This could return a polygon area or a rectangular area measure A read lock is expected around this method.
static boolean isArrow(Annot annot)
Checks if the annotation is an arrow A read lock is expected around this method.
static boolean isBasicFreeText(Annot annot)
Checks if the annotation is a freetext, but not callout A read lock is expected around this method.
static boolean isCallout(Annot annot)
Checks if the annotation is a callout A read lock is expected around this method.
static boolean isCloud(Annot annot)
Checks if the annotation is a cloud polygon A read lock is expected around this method.
static boolean isCountMeasurement(Annot annot)
Checks if the annotation is measure count tool A read lock is expected around this method.
static boolean isFreeHighlighter(Annot annot)
Checks if the annotation is a free highlighter A read lock is expected around this method.
static boolean isFreeTextDate(Annot annot)
Checks if the annotation is a date text A read lock is expected around this method.
static boolean isFreeTextSpacing(Annot annot)
Checks if the annotation is a fill and sign type free text A read lock is expected around this method.
static boolean isGroupSelected(PDFViewCtrl pdfViewCtrl, ArrayList<Annot> selected, int page)
Check whether the selected annotations match an existing group
static boolean isImageStamp(Annot annot)
Checks if the annotation is an image stamp A read lock is expected around this method.
static boolean isListBox(Annot annot)
Checks if the annotation is a list box widget A read lock is expected around this method.
static boolean isPerimeterMeasure(Annot annot)
Checks if the annotation is perimeter measurement A read lock is expected around this method.
static boolean isRectAreaMeasure(Annot annot)
Checks if the annotation is rectangular area measurement A read lock is expected around this method.
static boolean isRuler(Annot annot)
Checks if the annotation is an ruler A read lock is expected around this method.
static boolean isSignature(Annot annot)
Checks if the annotation is a signature stamp A read lock is expected around this method.
static boolean isSignatureField(Annot annot)
Checks if annot is a SignatureField Widget A read lock is expected around this method.
static boolean isSimpleLine(Annot annot)
Checks if the annotation is a line with no ending styles A read lock is expected around this method.
static boolean isTextField(Annot annot)
Checks if annot is a TextField Widget A read lock is expected around this method.
static loadSystemFonts()
static void putFreeTextRotationDegree(Annot annot, int rotation)
Sets the rotation degree for FreeText annotation.
static void putStampDegree(Annot annot, int rotation)
Sets the rotation degree from Stamp annotation.
static Rect quadToRect(QuadPoint qp)
static void refreshAnnotAppearance(Context context, Annot annot)
helper function to refresh annotation appearance.
static boolean refreshCustomFreeTextAppearance(File appearance, Annot annot)
static void safeDeleteAllAnnots(PDFDoc doc)
Delete all annotations except for links and form fields This method does not lock document, a write lock should be acquired outside
static Annot safeDeleteAnnot(PDFDoc pdfDoc, Page page, Annot annot)
Used in replacement of annotRemove(Annot) to handle direct object The returned Annot object should be used after this function.
static Annot safeDeleteAnnotAndUpdate(PDFViewCtrl pdfViewCtrl, Page page, Annot annot, int annotPageNum)
Used in replacement of annotRemove(Annot) to handle direct object and updates the viewer The returned Annot object should be used after this function.
static void safeDeleteAnnotsOnPage(PDFDoc doc, ArrayList<Integer> pages)
Delete all annotations except for links and form fields on pages This method does not lock document, a write lock should be acquired outside
static void saveFreeTextCache(FreeTextCacheStruct freeTextCacheStruct, PDFViewCtrl pdfViewCtrl)
Saves the free text in cache.
static void saveUnrotatedBBox(PDFViewCtrl pdfViewCtrl, Annot annot, int pageNum)
A write lock is required.
static String serializeRect(Rect rect)
static void setAnnotContents(PDFDoc pdfDoc, Markup markup, String newContent)
static void setAuthor(Markup markup, String author)
Sets the author for the specified markup annotation.
static void setAuthor(Annot annot, String author)
Sets the author for the specified annotation, if possible.
static void setBorderStyle(Annot annot, int effect, int style, double[] dash)
A write lock is expected around this call
static void setDateToNow(PDFViewCtrl pdfViewCtrl, Annot annot)
static void setLineEndingStyle(Line line, LineEndingStyle lineEndingStyle, Boolean lineStart)
static void setStyle(Annot annot, boolean hasFill, int strokeColor, int fillColor, float thickness, float opacity)
A write lock is expected around this call
static void setUniqueId(Annot annot, String id)
Sets the unique identifier for the specified annotation, if possible.
static JSONObject simpleXmlParser(String xfdfCommand)
static void traverseAnnots(Page page, AnnotUtils.AnnotVisitor visitor)
Traverse over all annotations on the specified page.
static void traverseAnnots(PDFDoc doc, AnnotUtils.AnnotVisitor visitor)
Traverse over all annotations in the specified document.
static void traverseAnnotsWithPage(PDFDoc doc, AnnotUtils.AnnotWithPageVisitor visitor)
Traverse over all annotations in the specified document.
static void traverseAnnotsWithPage(Page page, AnnotUtils.AnnotWithPageVisitor visitor)
Traverse over all annotations on the specified page.
static void traversePages(PDFDoc doc, AnnotUtils.PageVisitor visitor)
Traverse over all pages in the specified document.
static void ungroupAnnotations(PDFViewCtrl pdfViewCtrl, ArrayList<Annot> allInGroup)
static boolean updateAnnotOnMoveToNewPage(PDFViewCtrl pdfViewCtrl, Annot annot, int currentPageNum, int newPageNum, RectF currentAnnotScreenRect, RectF newAnnotScreenRect, boolean customTextFieldAppearance)
Updates the annotation based on the new page and new screen Rect, so that the appearance will look right side up from the user's perspective.
static Annot updateAnnotationReply(String replyId, int pageNum, PDFViewCtrl pdfViewCtrl, ToolManager toolManager, String contents)
static void updateContentRectOnMove(PDFViewCtrl pdfViewCtrl, Annot annot, int currentPageNum, int newPageNum, RectF currentAnnotScreenRect, RectF newAnnotScreenRect)
Updates the Rect and content Rect of the annotation when the annotation is moved.
static String xfdfCommandExtract(PDFDoc pdfDoc, List<String> annotIdsAdded, List<String> annotIdsModified, List<String> annotIdsDeleted)
Returns an XFDF command with add, modify, and delete tags containing annotations associated with the given annotation ids and PDFDoc.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final String KEY_INK_LIST

Constant Value: "InkList"

public static final String XFDF_ADD

Constant Value: "add"

public static final String XFDF_DELETE

Constant Value: "delete"

public static final String XFDF_MODIFY

Constant Value: "modify"

Fields

public static String KEY_ANNOT_ROTATION

public static String KEY_FreeTextDate

public static String KEY_FreeTextFill

public static String KEY_InReplyTo

public static String KEY_NM

public static String KEY_RawRichContent

public static String KEY_ReplyTo

public static String KEY_RichContent

public static String KEY_UNROTATED_BBOX

public static String KEY_WidgetAuthor

public static String Key_State

public static String Key_StateAccepted

public static String Key_StateCancelled

public static String Key_StateCompleted

public static String Key_StateModel

public static String Key_StateModelMarked

public static String Key_StateModelReview

public static String Key_StateNone

public static String Key_StateRejected

public static String VALUE_Group

public static double sMinBitmapAppearanceDPI

Public Constructors

public AnnotUtils ()

Public Methods

public static void applyCustomFreeTextAppearance (PDFViewCtrl pdfViewCtrl, AutoScrollEditText editText, Annot annot, int pageNum)

Applies custom appearance for a FreeText with custom spacing annotation. Note: appearance will only be applied for Android Lollipop and above. A write lock is expected around this call

Parameters
pdfViewCtrl the viewer
editText the EditText where appearance is from
annot the annotation to apply the appearance to
pageNum the page number of the annot

public static void applyRedaction (PDFViewCtrl pdfViewCtrl, Redaction redactAnnot, ArrayList<Redactor.Redaction> arr)

public static boolean canUseBitmapAppearance (Annot annot)

A read lock is expected around this method.

public static int compareCreationDate (Annot thisObj, Annot thatObj)

public static int compareDate (Annot thisObj, Annot thatObj)

public static Rect computeAnnotInbox (PDFViewCtrl pdfViewCtrl, Annot annot, int pg)

Returns the bounding box of the specified annotation in screen space.

Parameters
pdfViewCtrl The PDFViewCtrl
annot The annotation
pg The page number
Returns
  • The bounding box

public static void createAnnotationGroup (PDFViewCtrl pdfViewCtrl, Annot primary, ArrayList<Annot> allInGroup)

Creates a group of annotations

Parameters
primary the primary annotation
allInGroup all annotations to be added to this group

public static Annot createAnnotationReply (String parentAnnotId, int pageNum, PDFViewCtrl pdfViewCtrl, String authorId, String contents)

public static Annot createAnnotationStateReply (String parentAnnotId, int pageNum, PDFViewCtrl pdfViewCtrl, String authorId, String authorName, AnnotReviewState state)

public static void createCustomFreeTextAppearance (View view, PDFViewCtrl pdfViewCtrl, Annot annot, int pageNum, Rect bbox, boolean useBBoxLocation, AnnotStyle annotStyle)

public static void createCustomFreeTextAppearance (View view, PDFViewCtrl pdfViewCtrl, Annot annot, int pageNum, Rect bbox)

Applies custom appearance for a FreeText annotation that is generated from Android EditText Note 1: This API only takes effect on KitKit and above Note 2: A write lock is expected around this call

Parameters
view the EditText where appearance is from
pdfViewCtrl the viewer
annot the annotation to apply the appearance to
pageNum the page number of the annot
bbox when a bbox is supplied, this will be used as bbox of the annotation

public static void createCustomFreeTextAppearance (View view, PDFViewCtrl pdfViewCtrl, Annot annot, int pageNum, Rect bbox, boolean useBBoxLocation)

Applies custom appearance for a FreeText annotation that is generated from Android EditText Note 1: This API only takes effect on KitKit and above Note 2: A write lock is expected around this call

Parameters
view the EditText where appearance is from
pdfViewCtrl the viewer
annot the annotation to apply the appearance to
pageNum the page number of the annot
bbox when a bbox is supplied, this will be used as bbox of the annotation
useBBoxLocation when true, the bbox location will be used as the bbox of the annotation, otherwise, only width/height will be used

public static File createPdfFromView (View content, int width, int height, File outputFile)

Attempts to create a new single page PDF document using the appearance from an Android view. Returns the output file if successfully created. If a file already exists, it will get overwritten.

Parameters
content view used to create a PDF document
width width of the document
height height of the document
outputFile output PDF file to write to, this file will be overwritten.
Returns
  • the converted output PDF file, or null if the process failed.

public static void createRCFreeTextAppearance (PTRichEditor richEditor, PDFViewCtrl pdfViewCtrl, Annot annot, int pageNum, AnnotStyle annotStyle)

Creates the FreeText appearance from PTRichEditor This method does not lock document, a write lock should be acquired outside

public static String createScreenshot (File tempDir, PDFDoc pdfDoc, Annot annot, int pageNum)

Static function to create a screenshot out of the bounds of an annot rect bbox. Note that this requires a read lock on the PDFDoc.

Parameters
tempDir temporary directory to store the created PNG file
pdfDoc current PDFDoc
annot annot to get the screenshot off of
pageNum current page number of the annot
Returns
  • the string of the path of the PNG file (in a temp file path)
Throws
PDFNetException any exception thrown. will be handled somewhere else

public static createScreenshotAsync (File tempDir, PDFDoc pdfDoc, Annot annot, int annotPageNumber)

Asyncronous method for creating screenshots, as some complex files might take some time to render.

Parameters
tempDir temporary directory path
pdfDoc PDFDoc that contains the annotation
annot (square) annot used to create the screenshot with
annotPageNumber page number that the annotation is on
Returns
  • loation of the temp screenshot created

public static void createSoundAnnotation (PDFViewCtrl pdfViewCtrl, PointF targetPagePoint, int pageNum, String outputFile)

public static void deleteAllAnnotsByType (PDFDoc doc, int type)

public static void deleteAnnotationReply (String replyId, int pageNum, PDFViewCtrl pdfViewCtrl, ToolManager toolManager)

public static Rect deserializeRect (String rectStr)

public static Annot flattenAnnot (PDFViewCtrl pdfViewCtrl, Annot annot, int pageNum)

Flattens an annotation. A document lock is required around this method.

public static Rect getActualUnrotatedBBox (PDFViewCtrl pdfViewCtrl, Annot annot, int pageNum)

public static ArrayList<Pair<Redaction, Integer>> getAllRedactions (PDFViewCtrl pdfViewCtrl)

public static int getAnnotBaseRotation (PDFViewCtrl pdfViewCtrl, int pageNumber)

Viewer and page rotation

public static int getAnnotColor (Annot annot)

Returns the annotation color of the specified annotation.

Parameters
annot The annotation
Returns
  • The annotation color

public static String getAnnotContents (PDFDoc pdfDoc, Annot annot)

public static int getAnnotImageResId (int type)

Returns the annotation image resource ID.

Parameters
type The type of annotation
Returns
  • The annotation image resource ID

public static Date getAnnotLocalCreationDate (Annot annot)

Gets the annotation creation date in local date time

Parameters
annot the annotation
Returns
  • the date

public static Date getAnnotLocalDate (Annot annot)

Gets the annotation date in local date time

Parameters
annot the annotation
Returns
  • the date

public static float getAnnotOpacity (Annot annot)

Returns the annotation opacity of the specified annotation.

Parameters
annot The annotation
Returns
  • The annotation opacity

public static int getAnnotRotation (Annot annot)

A read lock is needed around this method.

public static int getAnnotRotationRelToPage (PDFViewCtrl pdfViewCtrl, Annot annot, int pageNumber)

Annotation rotation reletive to page and viewer rotation

public static AnnotStyle getAnnotStyle (Annot annot)

Gets the annot style A read lock is required for this function.

Parameters
annot the annotation
Returns
  • the annot style
Throws
PDFNetException PDFNet exception

public static int getAnnotType (Annot annot)

public static String getAnnotTypeAsPluralString (Annot annot)

Returns annotation type as raw plural string (not localized).

Parameters
annot The annotation
Returns
  • The annotation type as string

public static String getAnnotTypeAsPluralString (Context context, Annot annot)

Returns annotation type as string.

Parameters
context The context
annot The annotation
Returns
  • The annotation type as string

public static String getAnnotTypeAsString (Annot annot)

Returns annotation type as raw string (not localized).

Parameters
annot The annotation
Returns
  • The annotation type as string

public static String getAnnotTypeAsString (Context context, int typeId)

Returns annotation type as string.

Parameters
context The context
typeId The annotation type ID
Returns
  • The annotation type as string

public static String getAnnotTypeAsString (Context context, Annot annot)

Returns annotation type as string.

Parameters
context The context
annot The annotation
Returns
  • The annotation type as string

public static int getAnnotUIRotation (PDFViewCtrl pdfViewCtrl, Annot annot, int pageNumber)

Gets annotation rotation used in UI, read lock is not required.

public static Bitmap getAnnotationAppearance (PDFViewCtrl pdfViewCtrl, Annot annot)

public static getAnnotationAppearanceAsync (PDFViewCtrl pdfViewCtrl, Annot annot)

public static int getAnnotationCountOnPage (PDFViewCtrl pdfViewCtrl, int pageNum, ArrayList<Integer> excludeType)

Gets annotation count on page excluding certain types A read lock should be acquired outside of this method

public static ArrayList<Annot> getAnnotationsInGroup (PDFViewCtrl pdfViewCtrl, Annot annot, int pageNum)

Returns all annotations in this group if the annotation passed in is in an annotation group

public static Annot getAssociatedAnnotation (PDFViewCtrl pdfViewCtrl, SignatureWidget signatureWidget, int pageNum)

Checks if the signature widget overlaps with a signature annotation within a certain distance Used to check if any annotations should be linked to the widget

public static String getAuthor (Annot annot)

Gets the author for the specified annotation. Annotation needs to be either type of markup or widget.

Parameters
annot the annotation
Returns
  • the author

public static String getCurrentTime (String format)

public static FileAttachment getFileAttachment (PDFViewCtrl pdfViewCtrl, Annot annot)

public static double getFormFieldBackgroundOpacity (Annot annot)

public static String getIRTAsString (Annot annot)

Gets the unique Id of the IRT parent annotation of this annotation

public static LineEndingStyle getLineEndingStyle (Line line, boolean lineStart)

public static Date getLocalDate (Date date)

Converts a com.pdftron.pdf.Date to local Date object

Parameters
date to convert
Returns
  • the local date

public static Rect getOldAnnotScreenPosition (PDFViewCtrl pdfViewCtrl, Annot annot, int annotPageNum)

public static Rect getPageRectFromScreenRect (PDFViewCtrl pdfViewCtrl, Rect screenRect, int pg)

public static Rect getPageRectFromScreenRect (PDFViewCtrl pdfViewCtrl, Rect screenRect, int pg, int rotation)

public static ArrayList<Point> getPolyVertices (Annot annot)

Gets the vertices of a Polyline or a Polygon. This method does not lock the document, so a read lock should be acquired outside.

Parameters
annot annotation with type of polyline or polygon
Returns
  • the vertices

public static Annot getPrimaryAnnotInGroup (PDFViewCtrl pdfViewCtrl, ArrayList<Annot> annots)

public static ArrayList<Redactor.Redaction> getRedactionArray (Redaction redactAnnot, int annotPageNum)

public static RectF getScreenRectFromPageRect (PDFViewCtrl pdfViewCtrl, Rect pageRect, int pg)

public static int getStampDegree (Annot annot)

Gets the rotation degree from Stamp annotation. A read lock is expected around this method.

public static int getStampDegreeOld (Annot annot)

Gets the deprecated rotation degree from Stamp annotation. A read lock is expected around this method.

public static double[] getStampSize (Context context, String stampName)

Gets the page corresponding to a certain stamp in our stamps repository.

Parameters
context The context
stampName The name of stamp icon
Returns
  • The page size; null if cannot find the stamp

public static Bitmap getStandardStampBitmapFromPdf (Context context, String stampLabel, int bgColor, int height)

public static String getStandardStampImageFileFromName (Context context, StandardStampPreviewAppearance stampPreviewAppearance, int height)

public static Rect getUnrotatedBBox (Annot annot)

A read lock is required.

public static boolean hasPermission (PDFDoc pdfDoc, ToolManager toolManager, Annot annot, int kind)

public static boolean hasPermission (PDFViewCtrl pdfViewCtrl, Annot annot, int kind)

Checks whether the annotation has the specified permission

Parameters
annot The annotation
kind The kind of permission. Possible values are ANNOT_PERMISSION_SELECTION, ANNOT_PERMISSION_MENU ANNOT_PERMISSION_FILL_AND_SIGN ANNOT_PERMISSION_INTERACT
Returns
  • True if the annotation has permission

public static boolean hasPermission (PDFViewCtrl pdfViewCtrl, PDFDoc pdfDoc, ToolManager tm, Annot annot, int kind)

public static boolean hasReplyTypeGroup (Annot annot)

Checks if the annotation is part of a group annotation

Parameters
annot the annotation
Returns
  • true if it is part of a group annotation, false otherwise

public static boolean hasReplyTypeReply (Annot annot)

Checks if the annotation is an annotation reply

Parameters
annot the annotation
Returns
  • true if it is an annotation reply, false otherwise

public static boolean hasRotation (Annot annot)

Gets whether the annotation rotation is not a multiple of 90 A read lock is needed around this method.

public static boolean hasRotation (PDFViewCtrl pdfViewCtrl, Annot annot)

Gets whether the annotation rotation is not a multiple of 90

public static boolean isAreaMeasure (Annot annot)

Checks if the annotation is area measurement This could return a polygon area or a rectangular area measure A read lock is expected around this method.

Parameters
annot The annotation
Returns
  • True if the annotation is area measurement

public static boolean isArrow (Annot annot)

Checks if the annotation is an arrow A read lock is expected around this method.

Parameters
annot The annotation
Returns
  • True if the annotation is arrow
Throws
PDFNetException PDFNet exception

public static boolean isBasicFreeText (Annot annot)

Checks if the annotation is a freetext, but not callout A read lock is expected around this method.

Parameters
annot The annotation
Returns
  • True if the annotation is a freetext, but not callout

public static boolean isCallout (Annot annot)

Checks if the annotation is a callout A read lock is expected around this method.

Parameters
annot The annotation
Returns
  • True if the annotation is callout

public static boolean isCloud (Annot annot)

Checks if the annotation is a cloud polygon A read lock is expected around this method.

Parameters
annot The annotation
Returns
  • True if the annotation is cloud
Throws
PDFNetException PDFNet exception

public static boolean isCountMeasurement (Annot annot)

Checks if the annotation is measure count tool A read lock is expected around this method.

Parameters
annot The annotation
Returns
  • True if the annotation is measure count tool

public static boolean isFreeHighlighter (Annot annot)

Checks if the annotation is a free highlighter A read lock is expected around this method.

Parameters
annot The annotation
Returns
  • True if the annotation is free highlighter
Throws
PDFNetException PDFNet exception

public static boolean isFreeTextDate (Annot annot)

Checks if the annotation is a date text A read lock is expected around this method.

Parameters
annot The annotation
Returns
  • True if the annotation is date text

public static boolean isFreeTextSpacing (Annot annot)

Checks if the annotation is a fill and sign type free text A read lock is expected around this method.

Parameters
annot The annotation
Returns
  • True if the annotation is date text

public static boolean isGroupSelected (PDFViewCtrl pdfViewCtrl, ArrayList<Annot> selected, int page)

Check whether the selected annotations match an existing group

Parameters
selected the selected annotations
Returns
  • whether the selected annotations match an existing group

public static boolean isImageStamp (Annot annot)

Checks if the annotation is an image stamp A read lock is expected around this method.

Parameters
annot The annotation
Returns
  • True if the annotation is an image stamp

public static boolean isListBox (Annot annot)

Checks if the annotation is a list box widget A read lock is expected around this method.

Parameters
annot The annotation
Returns
  • True if the annotation is list box widget

public static boolean isPerimeterMeasure (Annot annot)

Checks if the annotation is perimeter measurement A read lock is expected around this method.

Parameters
annot The annotation
Returns
  • True if the annotation is perimeter measurement

public static boolean isRectAreaMeasure (Annot annot)

Checks if the annotation is rectangular area measurement A read lock is expected around this method.

Parameters
annot The annotation
Returns
  • True if the annotation is rectangular area measurement

public static boolean isRuler (Annot annot)

Checks if the annotation is an ruler A read lock is expected around this method.

Parameters
annot The annotation
Returns
  • True if the annotation is ruler

public static boolean isSignature (Annot annot)

Checks if the annotation is a signature stamp A read lock is expected around this method.

Parameters
annot The annotation
Returns
  • True if the annotation is signature stamp

public static boolean isSignatureField (Annot annot)

Checks if annot is a SignatureField Widget A read lock is expected around this method.

Parameters
annot The annotation
Returns
  • True if the annotation is SignatureField widget

public static boolean isSimpleLine (Annot annot)

Checks if the annotation is a line with no ending styles A read lock is expected around this method.

Parameters
annot The annotation
Returns
  • True if the annotation is arrow
Throws
PDFNetException PDFNet exception

public static boolean isTextField (Annot annot)

Checks if annot is a TextField Widget A read lock is expected around this method.

Parameters
annot The annotation
Returns
  • True if the annotation is TextField widget

public static loadSystemFonts ()

public static void putFreeTextRotationDegree (Annot annot, int rotation)

Sets the rotation degree for FreeText annotation. A write lock is expected around this method.

public static void putStampDegree (Annot annot, int rotation)

Sets the rotation degree from Stamp annotation. A write lock is expected around this method.

public static Rect quadToRect (QuadPoint qp)

public static void refreshAnnotAppearance (Context context, Annot annot)

helper function to refresh annotation appearance. Note that some annotations may have their own custom appearance such as Text annotation.

Parameters
context The Context
annot The annotation
Throws
PDFNetException PDFNet exception

public static boolean refreshCustomFreeTextAppearance (File appearance, Annot annot)

public static void safeDeleteAllAnnots (PDFDoc doc)

Delete all annotations except for links and form fields This method does not lock document, a write lock should be acquired outside

Parameters
doc the PDFDoc

public static Annot safeDeleteAnnot (PDFDoc pdfDoc, Page page, Annot annot)

Used in replacement of annotRemove(Annot) to handle direct object The returned Annot object should be used after this function. The Annot parameter should no longer be used after this function.

public static Annot safeDeleteAnnotAndUpdate (PDFViewCtrl pdfViewCtrl, Page page, Annot annot, int annotPageNum)

Used in replacement of annotRemove(Annot) to handle direct object and updates the viewer The returned Annot object should be used after this function. The Annot parameter should no longer be used after this function.

public static void safeDeleteAnnotsOnPage (PDFDoc doc, ArrayList<Integer> pages)

Delete all annotations except for links and form fields on pages This method does not lock document, a write lock should be acquired outside

Parameters
doc the PDFDoc

public static void saveFreeTextCache (FreeTextCacheStruct freeTextCacheStruct, PDFViewCtrl pdfViewCtrl)

Saves the free text in cache.

Parameters
freeTextCacheStruct The FreeTextCacheStruct
pdfViewCtrl The PDFViewCtrl

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

A write lock is required.

public static String serializeRect (Rect rect)

public static void setAnnotContents (PDFDoc pdfDoc, Markup markup, String newContent)

public static void setAuthor (Markup markup, String author)

Sets the author for the specified markup annotation.

This method does not lock the document, so a write lock should be acquired outside.

Parameters
markup the Markup annotation
author the desired author name

public static void setAuthor (Annot annot, String author)

Sets the author for the specified annotation, if possible.

This method does not lock the document, so a write lock should be acquired outside.

Parameters
annot the Annot
author the desired author name

public static void setBorderStyle (Annot annot, int effect, int style, double[] dash)

A write lock is expected around this call

public static void setDateToNow (PDFViewCtrl pdfViewCtrl, Annot annot)

public static void setLineEndingStyle (Line line, LineEndingStyle lineEndingStyle, Boolean lineStart)

public static void setStyle (Annot annot, boolean hasFill, int strokeColor, int fillColor, float thickness, float opacity)

A write lock is expected around this call

public static void setUniqueId (Annot annot, String id)

Sets the unique identifier for the specified annotation, if possible.

This method does not lock the document, so a write lock should be acquired outside.

Parameters
annot the Annot
id the unique identifier

public static JSONObject simpleXmlParser (String xfdfCommand)

Throws
IOException
JSONException
ParserConfigurationException
SAXException

public static void traverseAnnots (Page page, AnnotUtils.AnnotVisitor visitor)

Traverse over all annotations on the specified page. The visitor will be called for each annot via visit(Annot), allowing for arbitrary operations to be performed on the annot.

This method does not lock the document, so a read lock should be acquired outside.

Parameters
page the Page
visitor the AnnotUtils.AnnotVisitor to visit each annot

public static void traverseAnnots (PDFDoc doc, AnnotUtils.AnnotVisitor visitor)

Traverse over all annotations in the specified document. The AnnotUtils.AnnotVisitor will be called for each annot via visit(Annot), allowing for arbitrary operations to be performed on the annot.

This method does not lock the document, so a read lock should be acquired outside.

Parameters
doc the PDFDoc
visitor the AnnotUtils.AnnotVisitor to visit each annot

public static void traverseAnnotsWithPage (PDFDoc doc, AnnotUtils.AnnotWithPageVisitor visitor)

Traverse over all annotations in the specified document. The AnnotUtils.AnnotWithPageVisitor will be called for each annot via visit(Pair), allowing for arbitrary operations to be performed on the annot.

This method does not lock the document, so a read lock should be acquired outside.

Parameters
doc the PDFDoc
visitor the AnnotUtils.AnnotWithPageVisitor to visit each annot

public static void traverseAnnotsWithPage (Page page, AnnotUtils.AnnotWithPageVisitor visitor)

Traverse over all annotations on the specified page. The visitor will be called for each annot via visit(Pair), allowing for arbitrary operations to be performed on the annot.

This method does not lock the document, so a read lock should be acquired outside.

Parameters
page the Page
visitor the AnnotUtils.AnnotWithPageVisitor to visit each annot

public static void traversePages (PDFDoc doc, AnnotUtils.PageVisitor visitor)

Traverse over all pages in the specified document. The visitor will be called for each page via visit(Page), allowing for arbitrary operations to be performed on the page.

This method does not lock the document, so a read lock should be acquired outside.

Parameters
doc the PDFDoc
visitor the AnnotUtils.PageVisitor to visit each page

public static void ungroupAnnotations (PDFViewCtrl pdfViewCtrl, ArrayList<Annot> allInGroup)

public static boolean updateAnnotOnMoveToNewPage (PDFViewCtrl pdfViewCtrl, Annot annot, int currentPageNum, int newPageNum, RectF currentAnnotScreenRect, RectF newAnnotScreenRect, boolean customTextFieldAppearance)

Updates the annotation based on the new page and new screen Rect, so that the appearance will look right side up from the user's perspective. It will update any data points in the annotation based on the new page according to its rotation if needed (such as Ink Points, Poly points, Line points, etc...).

For Images, Signatures, Stamps, or any annotation with custom appearance, the appearance itself will be rotated if needed. You should not call refreshAppearance afterwards, otherwise the custom appearance will be lost.

A write lock is required around this method.

Parameters
pdfViewCtrl the PDFViewCtrl
annot the annotation of interest
currentPageNum the current page of the annotation
newPageNum the new page of the annotation that we want to generate appearance
currentAnnotScreenRect the current screen rect of the annotation
newAnnotScreenRect the new screen rect of the annotation
Returns
  • true if the annotation's appearance needs to be refreshed, false otherwise

public static Annot updateAnnotationReply (String replyId, int pageNum, PDFViewCtrl pdfViewCtrl, ToolManager toolManager, String contents)

public static void updateContentRectOnMove (PDFViewCtrl pdfViewCtrl, Annot annot, int currentPageNum, int newPageNum, RectF currentAnnotScreenRect, RectF newAnnotScreenRect)

Updates the Rect and content Rect of the annotation when the annotation is moved. This method supports moving between different pages.

A write lock is required around this method.

Parameters
pdfViewCtrl the PDFViewCtrl
annot the annotation of interest
currentPageNum the current page of the annotation
newPageNum the new page of the annotation that we want to generate appearance
currentAnnotScreenRect the current screen rect of the annotation
newAnnotScreenRect the new screen rect of the annotation
Returns
  • The new content rect that was set

public static String xfdfCommandExtract (PDFDoc pdfDoc, List<String> annotIdsAdded, List<String> annotIdsModified, List<String> annotIdsDeleted)

Returns an XFDF command with add, modify, and delete tags containing annotations associated with the given annotation ids and PDFDoc.

Requires caller to hold a read lock.

Parameters
pdfDoc the PDFDoc used to create the XFDF command
annotIdsAdded the list of annotation ids associated with annotations in the doc that should be included in the add tag
annotIdsModified the list of annotation ids associated with annotations in the doc that should be included in the modify tag
annotIdsDeleted the list of annotation ids associated with annotations in the doc that should be included in the delete tag
Returns
  • the XFDF command with populated add, modify, and delete tags where applicable