PTTool

@interface PTTool : UIView <PTOverridable, UIGestureRecognizerDelegate,
                            PTToolSwitching, PTNoteEditControllerDelegate,
                            UIPopoverPresentationControllerDelegate>

The PTTool base class from which all stock tools derive. These tools implement the PTToolSwitching protocol. For documentation on these methods, please see the protocol documentation, available at http://www.pdftron.com

  • The page number of the currentAnnotation.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) unsigned int annotationPageNumber;

    Swift

    var annotationPageNumber: UInt32 { get set }
  • The location of a long press within the coordinate system of the PTPDFViewCtrl (screen coordinates).

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) CGPoint longPressPoint;

    Swift

    var longPressPoint: CGPoint { get set }
  • The tools have one active annotation at a time, which is pointed to by this property.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, nullable) PTAnnot *currentAnnotation;

    Swift

    var currentAnnotation: PTAnnot? { get set }
  • If YES, an annotation creation tool will switch back to the defaultClass tool, typically the PTPanTool, after the annotation is created. If NO, the annotation creation tool will remain active, so the next set of touches will create another annotation.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) BOOL backToPanToolAfterUse;

    Swift

    var backToPanToolAfterUse: Bool { get set }
  • Class of tool to use when document is interacted with after creating a tool. If backToPanToolAfterUse is YES, then this will normally be the PTPanTool. Otherwise it will be the currently used annotation creation tool.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) Class _Nonnull defaultClass;

    Swift

    var defaultClass: AnyClass { get set }
  • Class of tool to pass the event on to if the current tool if it needs further processing.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, nullable) Class nextToolType;

    Swift

    var nextToolType: AnyClass? { get set }
  • Class of previous tool that created the current tool.

    Declaration

    Objective-C

    @property (readwrite, strong, nonatomic, nullable) Class previousToolType;

    Swift

    var previousToolType: AnyClass? { get set }
  • The PDFNet class that this tool creates.

    Declaration

    Objective-C

    @property (readonly, strong, nonatomic) Class _Nonnull annotClass;

    Swift

    var annotClass: AnyClass { get }
  • The PDFNet annot type that this tool creates.

    Declaration

    Objective-C

    @property (readonly, assign, nonatomic) PTExtendedAnnotType annotType;

    Swift

    var annotType: PTExtendedAnnotType { get }
  • Used to check if this tool can have its style modified.

    Declaration

    Objective-C

    @property (readonly, assign, nonatomic) BOOL canEditStyle;

    Swift

    var canEditStyle: Bool { get }
  • Tools can add a page number indicator to the PTPDFViewCtrl. This boolean turns its visibility on and off.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) BOOL pageIndicatorIsVisible;

    Swift

    var pageIndicatorIsVisible: Bool { get set }
  • Acrobat and Preview do not follow the PDF specification regarding the ordering of quad points in a text markup annotation. Enable this code for compatibility with those viewers.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) BOOL textMarkupAdobeHack;

    Swift

    var textMarkupAdobeHack: Bool { get set }
  • Used to track if the tool should forward the touch events to the PTPDFViewCtrl for scrolling.

    Declaration

    Objective-C

    @property (readonly, assign, nonatomic) BOOL allowScrolling;

    Swift

    var allowScrolling: Bool { get }
  • Requests action object to be executed by the PTPDFViewCtrl. The action must belong to the document currently displayed in the PTPDFViewCtrl.

    Declaration

    Objective-C

    - (void)executeAction:(nonnull PTActionParameter *)action_param;

    Swift

    func executeAction(_ action_param: PTActionParameter)

    Parameters

    action_param

    The object that is to be executed.

    • Used to notify the tool manager that the tool has added an annotation.

    Declaration

    Objective-C

    - (void)annotationAdded:(nonnull PTAnnot *)annotation
               onPageNumber:(unsigned long)pageNumber;

    Swift

    func annotationAdded(_ annotation: PTAnnot, onPageNumber pageNumber: UInt)

    Parameters

    annotation

    The annotation that was added. *

    pageNumber

    The page number of the PDF that the annotation was added to. *

  • Used to notify the tool manager that the tool has modified an annotation.

    Declaration

    Objective-C

    - (void)annotationModified:(nonnull PTAnnot *)annotation
                  onPageNumber:(unsigned long)pageNumber;

    Swift

    func annotationModified(_ annotation: PTAnnot, onPageNumber pageNumber: UInt)

    Parameters

    annotation

    The annotation that was modified.

    pageNumber

    The page number of the PDF that the annotation was modified on.

  • Used to notify the tool manager that the tool has removed an annotation.

    Declaration

    Objective-C

    - (void)annotationRemoved:(nonnull PTAnnot *)annotation
                 onPageNumber:(unsigned long)pageNumber;

    Swift

    func annotationRemoved(_ annotation: PTAnnot, onPageNumber pageNumber: UInt)

    Parameters

    annotation

    The annotation that was removed.

    pageNumber

    The page number of the PDF that the annotation was removed from.

  • Used to notify the tool manager that the tool has modified a form field’s data.

    Declaration

    Objective-C

    - (void)formFieldDataModified:(nonnull PTAnnot *)annotation
                     onPageNumber:(unsigned long)pageNumber;

    Swift

    func formFieldDataModified(_ annotation: PTAnnot, onPageNumber pageNumber: UInt)

    Parameters

    annotation

    The form field annotation’s that had its data modified

    pageNumber

    The page number of the PDF that the form field annotation is on.

  • Used to allow the tool manager to control whether the tool should select the given annotation on pageNumber.

    Declaration

    Objective-C

    - (BOOL)shouldSelectAnnotation:(nonnull PTAnnot *)annotation
                      onPageNumber:(unsigned long)pageNumber;

    Swift

    func shouldSelectAnnotation(_ annotation: PTAnnot, onPageNumber pageNumber: UInt) -> Bool

    Parameters

    annotation

    The annotation that will be selected

    pageNumber

    The page number that the annotation is on.

    Return Value

    YES if the tool should continue to select the annotation; NO if not.

  • Used to notify the tool manager that the tool selected an annotation.

    Declaration

    Objective-C

    - (void)didSelectAnnotation:(nonnull PTAnnot *)annotation
                   onPageNumber:(unsigned long)pageNumber;

    Swift

    func didSelectAnnotation(_ annotation: PTAnnot, onPageNumber pageNumber: UInt)

    Parameters

    annotation

    The annotation that was selected

    pageNumber

    The page number of the PDF that the annotation was selected on

  • Used to allow the tool manager to control whether to show a menu controller for the given annotation and page number.

    Declaration

    Objective-C

    - (BOOL)shouldShowMenu:(nonnull UIMenuController *)menuController
             forAnnotation:(nullable PTAnnot *)annotation
              onPageNumber:(unsigned long)pageNumber;

    Swift

    func shouldShowMenu(_ menuController: UIMenuController, forAnnotation annotation: PTAnnot?, onPageNumber pageNumber: UInt) -> Bool

    Parameters

    annotation

    The annotation that will be selected.

    pageNumber

    The page number that the annotation is on.

    Return Value

    YES if the tool should show the UIMenuController; NO if not.

  • Used to allow the tool manager to take over link handling. Links can either be annotations, or detected as links by PDFNet via text pattern matching. One of the two first parameters will have a value, the other will be nil.

    Declaration

    Objective-C

    - (BOOL)shouldHandleLinkAnnotation:(nullable PTAnnot *)annotation
                            orLinkInfo:(nullable PTLinkInfo *)linkInfo
                          onPageNumber:(unsigned long)pageNumber;

    Swift

    func shouldHandleLinkAnnotation(_ annotation: PTAnnot?, orLinkInfo linkInfo: PTLinkInfo?, onPageNumber pageNumber: UInt) -> Bool

    Parameters

    annotation

    The link annotation, if it exists, that will be handled. If there is not a link annotation, then nil.

    linkInfo

    If it exists, the text that was detected as matching the format of a link. nil otherwise.

    pageNumber

    The page number that the annotation or link is on.

    Return Value

    YES if the tool should handle the link; NO if not.

  • Used to allow the tool manager to control handling of file attachment annotations.

    Declaration

    Objective-C

    - (void)handleFileAttachment:(nonnull PTFileAttachment *)fileAttachment
                    onPageNumber:(unsigned long)pageNumber;

    Swift

    func handle(_ fileAttachment: PTFileAttachment, onPageNumber pageNumber: UInt)

    Parameters

    fileAttachment

    The file attachment.

    pageNumber

    The page number that the annotation is on.

  • Returns the view controller responsible for presenting the PTPDFViewCtrl

    Declaration

    Objective-C

    - (nullable UIViewController *)viewController;

    Swift

    func viewController() -> UIViewController?
  • Call to edit the current annotation’s note.

    Declaration

    Objective-C

    - (void)editSelectedAnnotationNote;

    Swift

    func editSelectedAnnotationNote()
  • Deletes the current annotation.

    Declaration

    Objective-C

    - (void)deleteSelectedAnnotation;

    Swift

    func deleteSelectedAnnotation()
  • Call to keep the current tool’s appearance on screen even after the tool is destroyed. This prevents a possible annotation flash as the PDF under a newly created annotation is re-rendered with the new annotation. The appearance is automatically removed when the PDFViewCtrl finishes its next render (or when its layout changes).

    Declaration

    Objective-C

    - (void)keepToolAppearanceOnScreen;

    Swift

    func keepAppearanceOnScreen()
  • Keeps a tool’s appearance on screen using the provided imageView. See keepToolAppearanceOnScreen.

    Declaration

    Objective-C

    - (void)keepToolAppearanceOnScreenWithImageView:
        (nonnull UIImageView *)imageView;

    Swift

    func keepAppearanceOnScreen(with imageView: UIImageView)

    Parameters

    imageView

    The image view to temporarily keep on screen.

  • Call to explicitly remove an tool appearances that have have been kept on screen by a call too keepToolAppearanceOnScreen.

    Declaration

    Objective-C

    - (void)removeAppearanceViews;

    Swift

    func removeAppearanceViews()
  • Shows a UIMenuController with options relevant for the current tool.

    Declaration

    Objective-C

    - (void)showSelectionMenu:(CGRect)targetRect animated:(BOOL)animated;

    Swift

    func showSelectionMenu(_ targetRect: CGRect, animated: Bool)
  • Shows a UIMenuController with options relevant for the current tool.

    Declaration

    Objective-C

    - (void)showSelectionMenu:(CGRect)targetRect;

    Swift

    func showSelectionMenu(_ targetRect: CGRect)
  • Hides the UIMenuController.

    Declaration

    Objective-C

    - (void)hideMenu;

    Swift

    func hideMenu()
  • Computes the PDF page box in screen (PTPDFViewCtrl) coordinates.

    Declaration

    Objective-C

    - (nullable PTPDFRect *)pageBoxInScreenPtsForPageNumber:(int)pageNumber;

    Swift

    func pageBoxInScreenPts(forPageNumber pageNumber: Int32) -> PTPDFRect?

    Parameters

    pageNumber

    the page number

    Return Value

    the page box in screen points.

  • Returns the union of two rectangles

    Declaration

    Objective-C

    + (nonnull PTPDFRect *)GetRectUnion:(nonnull PTPDFRect *)rect1
                                  Rect2:(nonnull PTPDFRect *)rect2;

    Swift

    class func getRectUnion(_ rect1: PTPDFRect, rect2: PTPDFRect) -> PTPDFRect
  • Converts a point in screen (PTPDFViewCtrl) coordinates to a PDF page coordinate.

    Declaration

    Objective-C

    - (CGPoint)convertScreenPtToPagePt:(CGPoint)screenPoint
                          onPageNumber:(int)pageNumber;

    Swift

    func convertScreenPt(toPagePt screenPoint: CGPoint, onPageNumber pageNumber: Int32) -> CGPoint
  • Converts a point in screen (PTPDFViewCtrl) coordinates to a PDF page coordinate.

    Declaration

    Objective-C

    - (void)ConvertScreenPtToPagePtX:(nonnull CGFloat *)x
                                   Y:(nonnull CGFloat *)y
                          PageNumber:(int)pageNumber;

    Swift

    func convertScreenPt(toPagePtX x: UnsafeMutablePointer<CGFloat>, y: UnsafeMutablePointer<CGFloat>, pageNumber: Int32)
  • Converts a point in page coordinates to screen (PTPDFViewCtrl) coordinates.

    Declaration

    Objective-C

    - (void)ConvertPagePtToScreenPtX:(nonnull CGFloat *)x
                                   Y:(nonnull CGFloat *)y
                          PageNumber:(int)pageNumber;

    Swift

    func convertPagePt(toScreenPtX x: UnsafeMutablePointer<CGFloat>, y: UnsafeMutablePointer<CGFloat>, pageNumber: Int32)
  • Converts a point in page coordinates to screen (PTPDFViewCtrl) coordinates.

    Declaration

    Objective-C

    - (CGPoint)convertPagePtToScreenPt:(CGPoint)pagePoint
                          onPageNumber:(int)pageNumber;

    Swift

    func convertPagePt(toScreenPt pagePoint: CGPoint, onPageNumber pageNumber: Int32) -> CGPoint
  • Converts a PTPDFRect in PDF page coordinates to a CGRect in screen (PTPDFViewCtrl) coordinates.

    Declaration

    Objective-C

    - (CGRect)PDFRectPage2CGRectScreen:(nonnull PTPDFRect *)r
                            PageNumber:(int)pageNumber;

    Swift

    func pdfRectPage2CGRectScreen(_ r: PTPDFRect, pageNumber: Int32) -> CGRect
  • Converts a PTPDFRect in screen (PTPDFViewCtrl) coordinates to a CGRect in screen (PTPDFViewCtrl) coordinates.

    Declaration

    Objective-C

    - (CGRect)PDFRectScreen2CGRectScreen:(nonnull PTPDFRect *)r
                              PageNumber:(int)pageNumber;

    Swift

    func pdfRectScreen2CGRectScreen(_ r: PTPDFRect, pageNumber: Int32) -> CGRect