PTPDFViewCtrl


@interface PTPDFViewCtrl
    : UIView <UIScrollViewDelegate, UIGestureRecognizerDelegate> {
  UIView *ContainerView;
  UIScrollView *innerScrollView;
  UIScrollView *outerScrollView;
}

PTPDFViewCtrl is a utility class that can be used for interactive rendering of PDF documents.

On iOS, PTPDFViewCtrl derives from UIView.

PTPDFViewCtrl defines several coordinate spaces and it is important to understand their differences:

  • Page Space refers to the space in which a PDF page is defined. It is determined by a page itself and the origin is at the lower-left corner of the page. Note that Page Space is independent of how a page is viewed in PDFView and each page has its own Page space.

  • Canvas Space refers to the tightest axis-aligned bounding box of all the pages given the current page presentation mode in PDFView. For example, if the page presentation mode is e_single_continuous, all the pages are arranged vertically with one page in each row, and therefore the Canvas Space is a rectangle with possibly large height value. For this reason, Canvas Space is also, like Page Space, independent of the zoom factor. Also note that since PDFView adds gaps between adjacent pages, the Canvas Space is larger than the space occupied by all the pages. The origin of the Canvas Space is located at the upper-left corner.

  • Screen Space (or Client Space) is the space occupied by PDFView and its origin is at the upper-left corner. Note that the virtual size of this space can extend beyond the visible region.

  • Scrollable Space is the virtual space within which PDFView can scroll. It is determined by the Canvas Space and the current zoom factor. Roughly speaking, the dimensions of the Scrollable Space is the dimensions of the Canvas Space timed by the zoom. Therefore, a large zoom factor will result in a larger Scrollable region given the same Canvas region. For this reason, Scrollable Space might also be referred to as Zoomed Canvas Space. Note that since PDFView adds gaps between pages in Canvas Space and these gaps are not scaled when rendered, the scrollable range is not exactly what the zoom factor times the Canvas range. For functions such as -SetHScrollPos:, -SetVScrollPos:, -GetCanvasHeight, and -GetCanvasWidth, it is the Scrollable Space that is involved.

    • Deprecated
    • The view that displays the PDF, that is the content view of a UIScrollView. Please use overlayView or toolsView for displaying content on top of the PDF.

    Declaration

    Objective-C

    UIView *ContainerView
  • Undocumented

    Declaration

    Objective-C

    UIScrollView* innerScrollView
  • Undocumented

    Declaration

    Objective-C

    UIScrollView* outerScrollView
  • A view that extends over the entire scrollable area of PTPDFViewCtrl. This view can be used to attach subviews for drawing custom content on top of the PDF.

    Declaration

    Objective-C

    @property (nonatomic, retain, readonly) UIView *_Nonnull overlayView;

    Swift

    var overlayView: UIView { get }
  • A view that extends over the entire scrollable area of PTPDFViewCtrl, but under the overlayView. This view can be used to attach subviews for annotation handling (by default used by the included tools library).

    Declaration

    Objective-C

    @property (nonatomic, retain, readonly) UIView *_Nonnull toolOverlayView;

    Swift

    var toolOverlayView: UIView { get }
  • The scroll view responsible for paging in non-continuous page presentation modes.

    The delegate of this scroll view is the owning PTPDFViewCtrl instance and should not be re-assigned.

    Declaration

    Objective-C

    @property (nonatomic, retain, readonly) UIScrollView *_Nonnull pagingScrollView;

    Swift

    var pagingScrollView: UIScrollView { get }
  • The scroll view responsible for panning and zooming of page content.

    The delegate of this scroll view is the owning PTPDFViewCtrl instance and should not be re-assigned.

    Declaration

    Objective-C

    @property (nonatomic, retain, readonly) UIScrollView *_Nonnull contentScrollView;

    Swift

    var contentScrollView: UIScrollView { get }
  • An object that conforms to the PTPDFViewCtrlDelegate protocol.

    Declaration

    Objective-C

    @property (nonatomic, weak, nullable) id<PTPDFViewCtrlDelegate> delegate;

    Swift

    weak var delegate: (any PTPDFViewCtrlDelegate)? { get set }
  • An object that conforms to the PTPDFViewCtrlToolDelegate protocol.

    Declaration

    Objective-C

    @property (nonatomic, weak, nullable) id<PTPDFViewCtrlToolDelegate> toolDelegate;

    Swift

    weak var toolDelegate: (any PTPDFViewCtrlToolDelegate)? { get set }
  • Enables or disables the ability for the user to scroll the content.

    Declaration

    Objective-C

    @property (nonatomic) BOOL scrollEnabled;

    Swift

    var scrollEnabled: Bool { get set }
  • Enables or disables the ability for the user to pinch-zoom the control.

    Declaration

    Objective-C

    @property (nonatomic) BOOL zoomEnabled;

    Swift

    var zoomEnabled: Bool { get set }
  • Enables or disables the document’s use of a retina display. If it is disabled, the document will display at a non-retina resolution. Default is enabled.

    Declaration

    Objective-C

    @property (nonatomic) BOOL retinaEnabled;

    Swift

    var retinaEnabled: Bool { get set }
  • Enables or disables automatically calling PurgeMemory when a low memory warning is received. Default YES.

    Declaration

    Objective-C

    @property (nonatomic) BOOL purgeMemoryOnMemoryWarning;

    Swift

    var purgeMemoryOnMemoryWarning: Bool { get set }
  • A Boolean value that determines whether scrolling is disabled in a particular direction.

    Declaration

    Objective-C

    @property (nonatomic, assign, unsafe_unretained, readwrite,
              getter=isDirectionalLockEnabled) BOOL directionalLockEnabled;

    Swift

    var isDirectionalLockEnabled: Bool { get set }
  • The behavior for determining the adjusted content offsets. This property specifies how the safe area insets are used to modify the content area of the scroll view. The default value of this property is Never.

    Declaration

    Objective-C

    @property (nonatomic) UIScrollViewContentInsetAdjustmentBehavior contentInsetAdjustmentBehavior;

    Swift

    var contentInsetAdjustmentBehavior: UIScrollView.ContentInsetAdjustmentBehavior { get set }
  • A double value that determines the extra vertical content accounted for by the on-screen keyboard

    Declaration

    Objective-C

    @property (nonatomic, readonly) double extraVerticalContentForKeyboard;

    Swift

    var extraVerticalContentForKeyboard: Double { get }
  • Associates this PTPDFViewCtrl with a given PDF document.

    Note

    SetDoc acquires a write lock on the document, so the document must be unlocked when this method is called or an exception will be thrown.

    Declaration

    Objective-C

    - (void)SetDoc:(nonnull PTPDFDoc *)doc;

    Swift

    func setDoc(_ doc: PTPDFDoc)

    Parameters

    doc

    A document to be displayed in the view.

  • Declaration

    Objective-C

    - (nullable PTPDFDoc *)GetDoc;

    Swift

    func getDoc() -> PTPDFDoc?

    Return Value

    Currently associated document with this PTPDFViewCtrl.

  • Closes the document currently opened in PTPDFViewCtrl.

    Note

    CloseDoc acquires a write lock on the document, so the document must be unlocked when this method is called or an exception will be thrown.

    Declaration

    Objective-C

    - (void)CloseDoc;

    Swift

    func closeDoc()
  • Sets the PDF document from a URL. If the PDF is linearized, PTPDFViewCtrl will display it incrementally while downloading it. If the PDF is not linearized, it will display blank pages until the entire document is downloaded.

    Note

    This method will acquire a write lock on the document that is displayed in the viewer when this method is called, so it must be free of locks or an exception will be thrown.

    Declaration

    Objective-C

    - (void)OpenUrlAsync:(nonnull NSString *)url;

    Swift

    func openUrlAsync(_ url: String)

    Parameters

    url

    The URL of the document to open.

  • Sets the PDF document from a URL. If the PDF is linearized, PTPDFViewCtrl will display it incrementally while downloading it. If the PDF is not linearized, it will display blank pages until the entire document is downloaded.

    Note

    This method will acquire a write lock on the document that is displayed in the viewer when this method is called, so it must be free of locks or an exception will be thrown.

    Declaration

    Objective-C

    - (void)OpenUrlAsync:(nonnull NSString *)url
         WithPDFPassword:(nullable NSString *)password;

    Swift

    func openUrlAsync(_ url: String, withPDFPassword password: String?)

    Parameters

    url

    The URL of the document to open.

    password

    The password used to open the PDF document if it is password protected.

  • Sets the PDF document from a URL. If the PDF is linearized, PTPDFViewCtrl will display it incrementally while downloading it. If the PDF is not linearized, it will display blank pages until the entire document is downloaded.

    Note

    This method will acquire a write lock on the document that is displayed in the viewer when this method is called, so it must be free of locks or an exception will be thrown.

    Declaration

    Objective-C

    - (void)OpenUrlAsync:(nonnull NSString *)url
         WithPDFPassword:(nullable NSString *)password
           WithCacheFile:(nullable NSString *)fullPath;

    Swift

    func openUrlAsync(_ url: String, withPDFPassword password: String?, withCacheFile fullPath: String?)

    Parameters

    url

    The URL of the document to open.

    password

    The password used to open the PDF document if it is password protected.

    fullPath

    The path to a file that will be used to cache the downloaded file which will be used to resume a download. If no cache file is specified, a file is created in the temporary directory.

  • Sets the PDF document from a URL. If the PDF is linearized, PTPDFViewCtrl will display it incrementally while downloading it. If the PDF is not linearized, it will display blank pages until the entire document is downloaded.

    Note

    This method will acquire a write lock on the document that is displayed in the viewer when this method is called, so it must be free of locks or an exception will be thrown.

    Declaration

    Objective-C

    - (void)OpenUrlAsync:(nonnull NSString *)url
         WithPDFPassword:(nullable NSString *)password
           WithCacheFile:(nullable NSString *)fullPath
             WithOptions:(nullable PTHTTPRequestOptions *)options;

    Swift

    func openUrlAsync(_ url: String, withPDFPassword password: String?, withCacheFile fullPath: String?, with options: PTHTTPRequestOptions?)

    Parameters

    url

    The URL of the document to open.

    password

    The password used to open the PDF document if it is password protected.

    fullPath

    The path to a file that will be used to cache the downloaded file which will be used to resume a download. If no cache file is specified, a file is created in the temporary directory.

    options

    HTTP request options to use with every HTTP request

  • Opens a streamable document type that requires conversion, such as .doc, .docx, .pptx, .xlsx. The PTPDFViewCtrl will show the document incrementally as it is converted.

    Declaration

    Objective-C

    - (void)openUniversalDocumentWithConversion:
        (nonnull PTDocumentConversion *)conversion;

    Swift

    func openUniversalDocument(with conversion: PTDocumentConversion)

    Parameters

    conversion

    The conversion object

  • Declaration

    Objective-C

    - (nonnull PTDocumentConversion *)documentConversion;

    Swift

    func documentConversion() -> PTDocumentConversion

    Return Value

    The document conversion object passed into -openUniversalDocumentWithConversion:.

  • An array of NSNumbers with the pages currently visible on the screen.

    Declaration

    Objective-C

    @property (nonatomic, readonly, getter=GetVisiblePages) NSArray<NSNumber *> *_Nonnull visiblePages;

    Swift

    var visiblePages: [NSNumber] { get }
  • Get an array of NSNumbers with the pages currently visible on the screen.

    Unavailable in Swift. Please use the property:

    Declaration

    Objective-C

    - (nonnull NSArray<NSNumber *> *)GetVisiblePages;

    Swift

    func getVisiblePages() -> [NSNumber]

    Return Value

    an array of NSNumbers of the pages currently visible on the screen.

  • Find if a specific page is currently visible on the screen

    Declaration

    Objective-C

    - (BOOL)pageIsOnScreen:(int)pageNumber;

    Swift

    func pageIs(onScreen pageNumber: Int32) -> Bool

    Parameters

    pageNumber

    The page number of the page to check.

    Return Value

    true if the page is on screen, false otherwise.

  • The page number of the page displayed in the view.

    Declaration

    Objective-C

    @property (nonatomic, assign, unsafe_unretained, readwrite,
              getter=GetCurrentPage, setter=PT_setCurrentPage:) int currentPage;

    Swift

    var currentPage: Int32 { get set }
  • Get the current page displayed in the view.

    Unavailable in Swift. Please use the property:

    Declaration

    Objective-C

    - (int)GetCurrentPage;

    Swift

    func getCurrentPage() -> Int32

    Return Value

    the current page displayed in the view.

  • Sets the current page to the given page.

    Declaration

    Objective-C

    - (_Bool)SetCurrentPage:(int)page_num;

    Swift

    func setCurrentPage(_ page_num: Int32) -> Bool

    Return Value

    true if successful, false otherwise.

  • Sets the current page to the first page in the document.

    Declaration

    Objective-C

    - (_Bool)GotoFirstPage;

    Swift

    func gotoFirstPage() -> Bool

    Return Value

    true if successful, false otherwise.

  • Sets the current page to the last page in the document.

    Declaration

    Objective-C

    - (_Bool)GotoLastPage;

    Swift

    func gotoLastPage() -> Bool

    Return Value

    true if successful, false otherwise.

  • Sets the current page to the next page in the document.

    Declaration

    Objective-C

    - (_Bool)GotoNextPage;

    Swift

    func gotoNextPage() -> Bool

    Return Value

    true if successful, false otherwise.

  • Sets the current page to the previous page in the document.

    Declaration

    Objective-C

    - (_Bool)GotoPreviousPage;

    Swift

    func gotoPreviousPage() -> Bool

    Return Value

    true if successful, false otherwise.

  • Get the current horizontal scroll position. The returned value is expressed in the canvas coordinate system. The canvas coordinate system is defined by a bounding box that surrounds all pages in the view.

    Declaration

    Objective-C

    - (double)GetHScrollPos;

    Swift

    func getHScrollPos() -> Double

    Return Value

    the current horizontal scroll position.

  • Get the current vertical scroll position. The returned value is expressed in the canvas coordinate system. The canvas coordinate system is defined by a bounding box that surrounds all pages in the view.

    Declaration

    Objective-C

    - (double)GetVScrollPos;

    Swift

    func getVScrollPos() -> Double

    Return Value

    the current vertical scroll position.

  • Sets the horizontal scroll position. The position should be a number in the range between 0 and -GetCanvasWidth and is expressed in the canvas coordinate system. The canvas coordinate system is defined by a bounding box that surrounds all pages in the view. If Animated is not specified, the default value is YES.

    Declaration

    Objective-C

    - (void)SetHScrollPos:(double)pos;

    Swift

    func setHScrollPos(_ pos: Double)

    Parameters

    pos

    the new horizontal scroll position.

  • Sets the horizontal scroll position. The position should be a number in the range between 0 and -GetCanvasWidth and is expressed in the canvas coordinate system. The canvas coordinate system is defined by a bounding box that surrounds all pages in the view.

    Declaration

    Objective-C

    - (void)SetHScrollPos:(double)pos Animated:(BOOL)animated;

    Swift

    func setHScrollPos(_ pos: Double, animated: Bool)

    Parameters

    pos

    The new horizontal scroll position.

    animated

    Whether to animate the change in scroll position.

  • Sets the vertical scroll position. The position should be a number in the range between 0 and -GetCanvasHeight and is expressed in the canvas coordinate system. The canvas coordinate system is defined by a bounding box that surrounds all pages in the view. If Animated is not specified, the default value is YES.

    Declaration

    Objective-C

    - (void)SetVScrollPos:(double)pos;

    Swift

    func setVScrollPos(_ pos: Double)

    Parameters

    pos

    The new vertical scroll position.

  • Sets the vertical scroll position. The position should be a number in the range between 0 and -GetCanvasHeight and is expressed in the canvas coordinate system. The canvas coordinate system is defined by a bounding box that surrounds all pages in the view.

    Declaration

    Objective-C

    - (void)SetVScrollPos:(double)pos Animated:(BOOL)animated;

    Swift

    func setVScrollPos(_ pos: Double, animated: Bool)

    Parameters

    pos

    The new vertical scroll position.

    animated

    Whether to animate the change in scroll position.

  • The zoom level of the PDF.

    Declaration

    Objective-C

    @property (nonatomic, assign, unsafe_unretained, readwrite, getter=GetZoom,
              setter=SetZoom:) double zoom;

    Swift

    var zoom: Double { get set }
  • Returns the current zoom level of the PDF.

    Unavailable in Swift. Please use the property:

    See

    zoom

    Declaration

    Objective-C

    - (double)GetZoom;

    Swift

    func getZoom() -> Double

    Return Value

    current zoom (or scaling) component used to display the page content.

  • Sets the zoom level of the PDF to a new value. The function zooms to a point at the center of the rendering buffer.

    Unavailable in Swift. Please use the property:

    See

    zoom

    Declaration

    Objective-C

    - (void)SetZoom:(double)zoom;

    Swift

    func setZoom(_ zoom: Double)

    Parameters

    zoom

    new scaling component used to display the page content.

  • Sets the zoom factor to a new value using the given pixel coordinate (x,y) as a zoom center.

    The zoom point (x,y) is represented in the screen coordinate system, which starts in the upper-left corner of the client window.

    Declaration

    Objective-C

    - (void)SetZoomX:(int)x Y:(int)y Zoom:(double)zoom;

    Swift

    func setZoomX(_ x: Int32, y: Int32, zoom: Double)

    Parameters

    x

    the horizontal coordinate to zoom in.

    y

    the vertical coordinate to zoom in.

    zoom

    new scaling component used to display the page content.

  • Sets the zoom factor to a new value using the given pixel coordinate (x,y) to find an intersecting paragraph. The width of the paragraph helps to determine the zoom value, center of the paragraph is used as a zoom center. Paragraph has to contain more than one line and be wider than 1/5th of a page width. When called on a paragraph wider than current zoom level, or smart zoom cannot find something to zoom on, the method returns false. The zoom point (x,y) is represented in the screen space, which starts in the upper-left corner of the client window.

    Declaration

    Objective-C

    - (BOOL)SmartZoomX:(double)in_x y:(double)in_y animated:(BOOL)animated;

    Swift

    func smartZoomX(_ in_x: Double, y in_y: Double, animated: Bool) -> Bool

    Parameters

    in_x

    the horizontal coordinate to look for a text block.

    in_y

    the vertical coordinate to look for a text block.

    animated

    whether or not to animate the zooming

    Return Value

    true if successful, false if no zooming was performed.

  • Changes the viewing area to fit a rectangle rect on page page_num. The rectangle must be specified in page coordinates. This will adjust current page and zoom appropriately.

    Declaration

    Objective-C

    - (BOOL)ShowRect:(int)page_num rect:(nonnull PTPDFRect *)rect;

    Swift

    func showRect(_ page_num: Int32, rect: PTPDFRect) -> Bool

    Parameters

    page_num

    the specified page number

    rect

    the rectangle to fit in

    Return Value

    true if successful, false otherwise.

  • Changes the viewing area to fit a rectangle in viewer coordinates.

    Declaration

    Objective-C

    - (void)zoomToRect:(CGRect)rect animated:(BOOL)animated;

    Swift

    func zoom(to rect: CGRect, animated: Bool)

    Parameters

    rect

    the rectangle to zoom in, in viewer coordinates.

    animated

    will animate zoom if YES, will not if NO.

  • The page view mode. The default PageView mode is e_trn_fit_width.

    Declaration

    Objective-C

    @property (nonatomic, assign, unsafe_unretained, readwrite,
              getter=GetPageViewMode, setter=SetPageViewMode:)
        TrnPageViewMode pageViewMode;

    Swift

    var pageViewMode: TrnPageViewMode { get set }
  • Get the current page viewing mode.

    Unavailable in Swift. Please use the property:

    Declaration

    Objective-C

    - (TrnPageViewMode)GetPageViewMode;

    Swift

    func getPageViewMode() -> TrnPageViewMode

    Return Value

    the current page viewing mode

  • Sets the page viewing mode. The default PageView mode is e_trn_fit_width.

    Unavailable in Swift. Please use the property:

    Declaration

    Objective-C

    - (void)SetPageViewMode:(TrnPageViewMode)mode;

    Swift

    func setPageViewMode(_ mode: TrnPageViewMode)

    Parameters

    mode

    the new page viewing mode.

  • The reference page view mode.

    In a non-continous page presentation mode, the reference page view mode is used to determine the page view mode upon a page change event. For example, if the reference page view mode is set to e_trn_fit_width, the new page coming in will be displayed with width-fit mode.

    Declaration

    Objective-C

    @property (nonatomic, assign, unsafe_unretained, readwrite,
              getter=GetPageRefViewMode, setter=SetPageRefViewMode:)
        TrnPageViewMode pageRefViewMode;

    Swift

    var pageRefViewMode: TrnPageViewMode { get set }
  • Sets the reference page view mode. In a non-continous page presentation mode, the reference page view mode is used to determine the page view mode upon a page change event. For example, if the reference page view mode is set to e_trn_fit_width, the new page coming in will be displayed with width-fit mode.

    Unavailable in Swift. Please use the property:

    Declaration

    Objective-C

    - (void)SetPageRefViewMode:(TrnPageViewMode)mode;

    Swift

    func setPageRefViewMode(_ mode: TrnPageViewMode)

    Parameters

    mode

    The reference page view mode to set. Valid values are e_trn_fit_page, e_trn_fit_width, and e_trn_fit_height.

  • Gets the reference page view mode. See more details about reference page view mode in -SetPageRefViewMode:.

    Unavailable in Swift. Please use the property:

    Declaration

    Objective-C

    - (TrnPageViewMode)GetPageRefViewMode;

    Swift

    func getPageRefViewMode() -> TrnPageViewMode

    Return Value

    the reference page view mode.

  • The current page presentation mode.

    Declaration

    Objective-C

    @property (nonatomic, assign, unsafe_unretained, readwrite,
              getter=GetPagePresentationMode, setter=SetPagePresentationMode:)
        TrnPagePresentationMode pagePresentationMode;

    Swift

    var pagePresentationMode: TrnPagePresentationMode { get set }
  • Get the current page presentation mode.

    Unavailable in Swift. Please use the property:

    Declaration

    Objective-C

    - (TrnPagePresentationMode)GetPagePresentationMode;

    Swift

    func getPagePresentationMode() -> TrnPagePresentationMode

    Return Value

    the current page presentation mode.

  • Sets the current page presentation mode. The default PagePresentationMode is e_trn_single_continuous.

    Unavailable in Swift. Please use the property:

    Declaration

    Objective-C

    - (void)SetPagePresentationMode:(TrnPagePresentationMode)mode;

    Swift

    func setPagePresentationMode(_ mode: TrnPagePresentationMode)

    Parameters

    mode

    the new page presentation mode.

  • Determine if the current page presentation mode is continuous

    Declaration

    Objective-C

    - (BOOL)pagePresentationModeIsContinuous;

    Swift

    func pagePresentationModeIsContinuous() -> Bool

    Return Value

    true if the page presentation mode is continuous, false otherwise.

  • The direction of paging for non-continuous page presentation modes.

    Note

    The default value of this property is PTPDFViewCtrlPagingDirectionHorizontal.

    Declaration

    Objective-C

    @property (nonatomic) PTPDFViewCtrlPagingDirection pagingDirection;

    Swift

    var pagingDirection: PTPDFViewCtrl.PagingDirection { get set }
  • Enables or disables URL extraction. 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.

    Declaration

    Objective-C

    - (void)SetUrlExtraction:(BOOL)enabled;

    Swift

    func setUrlExtraction(_ enabled: Bool)

    Parameters

    enabled

    if true URL extraction is enabled, if false URL extraction is disabled.

  • Enables or disables drawing of a thin border around each page.

    Declaration

    Objective-C

    - (void)SetPageBorderVisibility:(BOOL)border_visible;

    Swift

    func setPageBorderVisibility(_ border_visible: Bool)

    Parameters

    border_visible

    if true, the border will be visible.

  • Enables or disables the transparency grid (check board pattern) to reflect page transparency.

    Declaration

    Objective-C

    - (void)SetPageTransparencyGrid:(BOOL)trans_grid_visible;

    Swift

    func setPageTransparencyGrid(_ trans_grid_visible: Bool)

    Parameters

    trans_grid_visible

    if true, the grid is turned on.

  • Sets the default ‘paper’ color used to draw the background of each page.

    Declaration

    Objective-C

    - (void)SetDefaultPageColor:(unsigned char)r
                              g:(unsigned char)g
                              b:(unsigned char)b;

    Swift

    func setDefaultPageColor(_ r: UInt8, g: UInt8, b: UInt8)

    Parameters

    r

    red RGB color component

    g

    green RGB color component

    b

    blue RGB color component

  • Sets the default background color used to paint the area surrounding each page.

    Declaration

    Objective-C

    - (void)SetBackgroundColor:(unsigned char)r
                             g:(unsigned char)g
                             b:(unsigned char)b
                             a:(unsigned char)a;

    Swift

    func setBackgroundColor(_ r: UInt8, g: UInt8, b: UInt8, a: UInt8)

    Parameters

    r

    red RGBA color component

    g

    green RGBA color component

    b

    blue RGBA color component

    a

    alpha RGBA color component

  • Sets the horizontal alignment used for rendering pages within the view.

    Declaration

    Objective-C

    - (void)SetHorizontalAlign:(int)align;

    Swift

    func setHorizontalAlign(_ align: Int32)

    Parameters

    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 top aligned; align=0, pages are centered; align>0, pages are bottom aligned.

  • Sets the vertical alignment used for rendering pages within the view.

    Declaration

    Objective-C

    - (void)SetVerticalAlign:(int)align;

    Swift

    func setVerticalAlign(_ align: Int32)

    Parameters

    align

    an integer specifying the vertical alignment. Depending of whether align is positive, negative, or zero, pages will be bottom, top, or center aligned: align<0, pages are top aligned; align=0, pages are centered; align>0, pages are bottom aligned.

  • Sets the vertical and horizontal padding and column spacing between adjacent pages in the view.

    Declaration

    Objective-C

    - (void)SetPageSpacing:(int)horiz_col_space
            vert_col_space:(int)vert_col_space
                 horiz_pad:(int)horiz_pad
                  vert_pad:(int)vert_pad;

    Swift

    func setPageSpacing(_ horiz_col_space: Int32, vert_col_space: Int32, horiz_pad: Int32, vert_pad: Int32)

    Parameters

    horiz_col_space

    horizontal column spacing (represented in pixels) between adjacent pages in the view. Default is 10.

    vert_col_space

    vertical column spacing (represented in pixels) between adjacent pages in the view. Default is 10.

    horiz_pad

    horizontal padding (represented in pixels) on the left and right side of the view. Default is 10.

    vert_pad

    vertical padding (represented in pixels) on the top and bottom side of the view. Default is 10.

  • Rotates all pages in the document 90 degrees clockwise.

    Declaration

    Objective-C

    - (void)RotateClockwise;

    Swift

    func rotateClockwise()
  • Rotates all pages in the document 90 degrees counter-clockwise.

    Declaration

    Objective-C

    - (void)RotateCounterClockwise;

    Swift

    func rotateCounterClockwise()
  • The current rotation applied to all pages in PTPDFViewCtrl.

    Rotation can be applied to all pages using -RotateClockwise and -RotateCounterClockwise.

    Declaration

    Objective-C

    @property (nonatomic, readonly, getter=GetRotation) PTRotate rotation;

    Swift

    var rotation: PTRotate { get }
  • Get the current rotation applied to all pages in PTPDFViewCtrl.

    Unavailable in Swift. Please use the property:

    See

    rotation

    Declaration

    Objective-C

    - (PTRotate)GetRotation;

    Swift

    func getRotation() -> PTRotate

    Return Value

    The current rotation applied to all pages in PTPDFViewCtrl.

  • 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 is only supported for RGBA output.

    Note

    When setting this property to e_ptpostprocess_gradient_map, the colors used for gradient map should also be set using -SetColorPostProcessColors:black_color:.

    Declaration

    Objective-C

    @property (nonatomic, assign, unsafe_unretained, readwrite,
              getter=GetColorPostProcessMode, setter=SetColorPostProcessMode:)
        PTColorPostProcessMode colorPostProcessMode;

    Swift

    var colorPostProcessMode: PTColorPostProcessMode { get set }
  • Get the current color post processing mode.

    Unavailable in Swift. Please use the property:

    Declaration

    Objective-C

    - (PTColorPostProcessMode)GetColorPostProcessMode;

    Swift

    func getColorPostProcessMode() -> PTColorPostProcessMode

    Return Value

    the current color post processing mode.

  • Set 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 is only supported for RGBA output.

    Unavailable in Swift. Please use the property:

    Declaration

    Objective-C

    - (void)SetColorPostProcessMode:(PTColorPostProcessMode)mode;

    Swift

    func setColorPostProcessMode(_ mode: PTColorPostProcessMode)

    Parameters

    mode

    the specific transform to be applied

  • 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.

    This mode will map the brightness of the original rasterized bitmap to a gradient in image_file_contents from left to right.

    Declaration

    Objective-C

    - (void)SetColorPostProcessMapFile:(nonnull PTFilter *)image_file_contents;

    Swift

    func setColorPostProcessMapFile(_ image_file_contents: PTFilter)

    Parameters

    image_file_contents

    A filter with image file contents.

  • 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. This mode will map the brightness of the original rasterized bitmap to a gradient between whiteColor and blackColor

    Declaration

    Objective-C

    - (void)SetColorPostProcessColors:(nonnull UIColor *)white_color
                          black_color:(nonnull UIColor *)black_color;

    Swift

    func setColorPostProcessColors(_ white_color: UIColor, black_color: UIColor)

    Parameters

    white_color

    The white color of the page.

    black_color

    The black color of the page.

  • Converts a color based on the view’s color post processing transformation.

    Declaration

    Objective-C

    - (nonnull PTColorPt *)GetPostProcessedColor:(nonnull PTColorPt *)color;

    Swift

    func getPostProcessedColor(_ color: PTColorPt) -> PTColorPt

    Parameters

    color

    the color to be converted

    Return Value

    the post-processed color

  • Sets whether the control will render progressively or will just draw once the entire view has been rendered.

    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.

    Declaration

    Objective-C

    - (void)SetProgressiveRendering:(BOOL)progressive
                   withInitialDelay:(int)delayMilliseconds
                       withInterval:(int)intervalMilliseconds;

    Swift

    func setProgressiveRendering(_ progressive: Bool, withInitialDelay delayMilliseconds: Int32, withInterval intervalMilliseconds: Int32)

    Parameters

    progressive

    if true the view will be rendered progressively

    delayMilliseconds

    delay before the progressive rendering timer is started.

    intervalMilliseconds

    delay between refreshes. Default is 750 ms.

  • Enable or disable path hinting.

    Path hinting is used to slightly adjust paths in order to avoid or alleviate artifacts of hair line cracks between certain graphical elements.

    This option is enabled by default.

    Declaration

    Objective-C

    - (void)SetPathHinting:(BOOL)enabled;

    Swift

    func setPathHinting(_ enabled: Bool)

    Parameters

    enabled

    if YES path hinting is enabled.

  • Enable or disable anti-aliasing.

    Anti-Aliasing is a technique used to improve the visual quality of images when displaying them on low resolution devices (for example, low DPI computer monitors).

    Anti-aliasing is enabled by default.

    Declaration

    Objective-C

    - (void)SetAntiAliasing:(_Bool)enabled;

    Swift

    func setAntiAliasing(_ enabled: Bool)
  • Set thin line adjustment parameters.

    Declaration

    Objective-C

    - (void)SetThinLineAdjustment:(_Bool)pixel_grid
                     StrokeAdjust:(_Bool)stroke_adjust;

    Swift

    func setThinLineAdjustment(_ pixel_grid: Bool, strokeAdjust stroke_adjust: Bool)

    Parameters

    pixel_grid

    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.

    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.

  • Enable or disable image smoothing.

    The rasterizer allows a trade-off between rendering quality and rendering speed. This function can be used to indicate the preference between rendering speed and quality.

    Note

    The 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.

    Image smoothing is enabled by default.

    Declaration

    Objective-C

    - (void)SetImageSmoothing:(_Bool)enabled;

    Swift

    func setImageSmoothing(_ enabled: Bool)

    Parameters

    enabled

    True to enable image smoothing, false otherwise.

  • Sets the gamma factor used for anti-aliased rendering.

    Gamma correction can be used to improve the quality of anti-aliased image output and can (to some extent) decrease the appearance of common anti-aliasing artifacts (such as pixel width lines between polygons).

    Note

    Gamma correction is used only in the built-in rasterizer.

    Declaration

    Objective-C

    - (void)SetGamma:(double)exp;

    Swift

    func setGamma(_ exp: Double)

    Parameters

    exp

    the exponent value of the gamma function. Typical values are in the range from 0.1 to 3.

  • Enable or disable annotation and forms rendering. By default, all annotations and form fields are rendered.

    Declaration

    Objective-C

    - (void)SetDrawAnnotations:(BOOL)render_annots;

    Swift

    func setDrawAnnotations(_ render_annots: Bool)

    Parameters

    render_annots

    True to draw annotations, false otherwise.

  • Enable or disable highlighting form fields. Default is disabled.

    Declaration

    Objective-C

    - (void)SetHighlightFields:(BOOL)highlight_fields;

    Swift

    func setHighlightFields(_ highlight_fields: Bool)

    Parameters

    highlight_fields

    YES to highlight, NO otherwise.

  • Set the highlight color for fields.

    This option only has an effect if field highlighting is turned on using -SetHighlightFields:.

    Note

    Signature fields have their own highlight color, independent of this one (see -SetSignatureHighlightColor:).

    Declaration

    Objective-C

    - (void)SetFieldHighlightColor:(nonnull UIColor *)highlightColor;

    Swift

    func setFieldHighlight(_ highlightColor: UIColor)

    Parameters

    highlightColor

    The new highlight color.

  • Set the border color for required fields.

    This option only has an effect if field highlighting is turned on using -SetHighlightFields:.

    Declaration

    Objective-C

    - (void)SetRequiredFieldBorderColor:(nonnull UIColor *)borderColor;

    Swift

    func setRequiredFieldBorderColor(_ borderColor: UIColor)

    Parameters

    borderColor

    The new border color.

  • Set the highlight color for signature fields.

    This option only has an effect if field highlighting is turned on using -SetHighlightFields:.

    Note

    Non-signature fields have their own highlight color, independent of this one (see -SetFieldHighlightColor:).

    Declaration

    Objective-C

    - (void)SetSignatureHighlightColor:(nonnull UIColor *)highlightColor;

    Swift

    func setSignatureHighlight(_ highlightColor: UIColor)

    Parameters

    highlightColor

    The new signature highlight color.

  • Enable or disable support for overprint and overprint simulation. Overprint is a device dependent feature and the results will vary depending on the output color space and supported colorants (i.e. CMYK, CMYK+spot, RGB, etc).

    By default overprint is only enabled for PDF/X files.

    Declaration

    Objective-C

    - (void)SetOverprint:(PTOverprintPreviewMode)op;

    Swift

    func setOverprint(_ op: PTOverprintPreviewMode)

    Parameters

    op

    e_ptop_on: always enabled; e_ptop_off: always disabled; e_ptop_pdfx_on: enabled for PDF/X files only.

  • Sets the Optional Content Group (OCG) context that should be used when viewing the document. This function can be used to change the current OCG context. Optional content (such as PDF layers) will be selectively rendered based on the states of optional content groups in the given context.

    Note

    Unlike -[PTPDFDraw SetOCGContext:] this method copies the given context. As a result, in order to modify the state of OCG groups in the current context use -GetOCGContext to obtain the currently selected content and then modify states.

    Declaration

    Objective-C

    - (void)SetOCGContext:(nonnull PTContext *)ctx;

    Swift

    func setOCGContext(_ ctx: PTContext)

    Parameters

    ctx

    Optional Content Group (OCG) context, or nil if the rasterizer should render all content on the page.

  • Get the Optional Content Group (OCG) context associated with this PTPDFViewCtrl.

    See

    OCGContext

    Declaration

    Objective-C

    - (nullable PTContext *)GetOCGContext;

    Swift

    func getOCGContext() -> PTContext?

    Return Value

    the Optional Content Group (OCG) context associated with this PTPDFViewCtrl, or nil (i.e. -[PTContext IsValid] is NO) if there is no OCG context associated with the view. If there is an OCG context associated with the view, optional content (such as PDF layers) will be selectively rendered based on the states of optional content groups in the given context.

  • Prompts the PDFViewCtrl to update its list of optional content groups. Call this method if you modify the PDFDoc in a way that adds or removes a layer. For example, after using Stamper to create a stamp.

    Declaration

    Objective-C

    - (void)UpdateOCGContext;

    Swift

    func updateOCGContext()
  • Disable rendering of a particular annotation. This does not change the annotation itself, just how it is displayed in this viewer instance.

    Declaration

    Objective-C

    - (void)HideAnnotation:(nonnull PTAnnot *)annot;

    Swift

    func hideAnnotation(_ annot: PTAnnot)

    Parameters

    annot

    The annotation object to cease drawing for.

  • Enable rendering of a particular annotation. Only has an effect if -HideAnnotation: has previously been called on the same annot.

    Declaration

    Objective-C

    - (void)ShowAnnotation:(nonnull PTAnnot *)annot;

    Swift

    func showAnnotation(_ annot: PTAnnot)

    Parameters

    annot

    The annotation object to resume rendering.

  • Selects text by searching for a given string of text.

    Note

    This function runs in asynchronous mode: it launches a search thread and returns immediately. If a matched string is found, the corresponding text is highlighted; otherwise, a message box is shown. Users can use SetCustomEventHandlers() to set a TextFindDoneHandler to customize a different behavior.

    Declaration

    Objective-C

    - (BOOL)FindText:(nonnull NSString *)searchString
             MatchCase:(BOOL)matchCase
        MatchWholeWord:(BOOL)matchWholeWord
              SearchUp:(BOOL)searchUp
                RegExp:(BOOL)regExp;

    Swift

    func findText(_ searchString: String, matchCase: Bool, matchWholeWord: Bool, searchUp: Bool, regExp: Bool) -> Bool

    Parameters

    searchString

    The text to search for

    matchCase

    Indicates if it is case sensitive

    matchWholeWord

    Indicates if it matches an entire word only

    searchUp

    If it searches upward

    regExp

    Indicates if it uses regular expressions.

  • Cancel the text search thread if -FindText:MatchCase:MatchWholeWord:SearchUp:RegExp: is started in a different thread.

    Note

    If the text search thread is currently being suspended by the render thread, it will only be canceled after it is awaken by the render thread.

    Declaration

    Objective-C

    - (void)CancelFindText;

    Swift

    func cancelFindText()
  • Sets the selection mode used for text highlighting.

    Declaration

    Objective-C

    - (void)SetTextSelectionMode:(PTTextSelectionMode)tm;

    Swift

    func setTextSelectionMode(_ tm: PTTextSelectionMode)

    Parameters

    tm

    the text selection mode.

  • Places a rectangle over text that has been selected.

    Declaration

    Objective-C

    - (void)highlightSelection:(nonnull PTSelection *)selection
                     withColor:(nonnull UIColor *)color;

    Swift

    func highlight(_ selection: PTSelection, with color: UIColor)

    Parameters

    selection

    A selection object.

    color

    The color of the drawn rectangle. Set the alpha value to less than 1.0 to give transparency.

  • Places a rectangle over text that has been selected.

    Declaration

    Objective-C

    - (void)highlightSelections:(nonnull NSArray<PTSelection *> *)selections
                      withColor:(nonnull UIColor *)color;

    Swift

    func highlight(_ selections: [PTSelection], with color: UIColor)

    Parameters

    selections

    An array of PTSelection objects.

    color

    The color of the drawn rectangle. Set the alpha value to less than 1.0 to give transparency.

  • Clears the rectangle drawn by highlightSelection:withColor:.

    Declaration

    Objective-C

    - (void)hideSelectedTextHighlights;

    Swift

    func hideSelectedTextHighlights()
  • Checks if there is any text selection.

    Declaration

    Objective-C

    - (BOOL)HasSelection;

    Swift

    func hasSelection() -> Bool

    Return Value

    return true if there is selection, false otherwise.

  • Remove any text selection.

    Declaration

    Objective-C

    - (void)ClearSelection;

    Swift

    func clearSelection()
  • Get the text selection for a given page.

    Declaration

    Objective-C

    - (nullable PTSelection *)GetSelection:(int)pagenum;

    Swift

    func getSelection(_ pagenum: Int32) -> PTSelection?

    Return Value

    the current text selection for a given page. If there is only selection on one page, then page number does not need to be provided.

  • The first page number that has text selection on it. Useful when there are selections on multiple pages at the same time.

    Declaration

    Objective-C

    @property (nonatomic, readonly, getter=GetSelectionBeginPage) int selectionBeginPage;

    Swift

    var selectionBeginPage: Int32 { get }
  • Get the first page number that has text selection on it. Useful when there are selections on multiple pages at the same time.

    Unavailable in Swift. Please use the property:

    Declaration

    Objective-C

    - (int)GetSelectionBeginPage;

    Swift

    func getSelectionBeginPage() -> Int32

    Return Value

    the first page number that has text selection on it.

  • The last page number that has text selection on it. Useful when there are selections on multiple pages at the same time.

    Declaration

    Objective-C

    @property (nonatomic, readonly, getter=GetSelectionEndPage) int selectionEndPage;

    Swift

    var selectionEndPage: Int32 { get }
  • Get the last page number that has text selection on it. Useful when there are selections on multiple pages at the same time.

    Unavailable in Swift. Please use the property:

    Declaration

    Objective-C

    - (int)GetSelectionEndPage;

    Swift

    func getSelectionEndPage() -> Int32

    Return Value

    the last page number that has text selection on it.

  • Checks if there is any text selection on a given page. Useful when there are selections on multiple pages at the same time.

    Declaration

    Objective-C

    - (BOOL)HasSelectionOnPage:(int)ipage;

    Swift

    func hasSelection(onPage ipage: Int32) -> Bool

    Return Value

    returns true if given page number has any text selection on it.

  • Selects text within the given region using the current text selection mode. (x1, y1) and (x2, y2) are two points (screen coordinates, origin located at the upper-left corner of this view) defining the opposite corners of a selection rectangle.

    Declaration

    Objective-C

    - (BOOL)SelectX1:(double)x1 Y1:(double)y1 X2:(double)x2 Y2:(double)y2;

    Swift

    func selectX1(_ x1: Double, y1: Double, x2: Double, y2: Double) -> Bool

    Return Value

    true if some text was selected, false otherwise.

  • Selects text using structural mode. Point (x1, y1) is the start selection point (in page coordinates space) on page pageNumber1 and point (x2, y2) is the end selection point on page pageNumber2.

    Declaration

    Objective-C

    - (BOOL)SelectX1:(double)x1
                  Y1:(double)y1
         PageNumber1:(int)pageNumber1
                  X2:(double)x2
                  Y2:(double)y2
         PageNumber2:(int)pageNumber2;

    Swift

    func selectX1(_ x1: Double, y1: Double, pageNumber1: Int32, x2: Double, y2: Double, pageNumber2: Int32) -> Bool

    Return Value

    true if some text were selected, false otherwise.

  • Selects text identified by Highlights.

    Declaration

    Objective-C

    - (BOOL)SelectWithHighlights:(nonnull PTHighlights *)highlights;

    Swift

    func select(with highlights: PTHighlights) -> Bool

    Parameters

    highlights

    an instance of the Highlights class.

    Return Value

    true if some text was selected, false otherwise.

  • Selects text identified by Selection.

    Declaration

    Objective-C

    - (BOOL)SelectWithSelection:(nonnull PTSelection *)select;

    Swift

    func select(with select: PTSelection) -> Bool

    Parameters

    select

    an instance of the Selection class.

    Return Value

    true if some text was selected, false otherwise.

  • Selects all text on the page.

    Declaration

    Objective-C

    - (void)SelectAll;

    Swift

    func selectAll()
  • Requests for preparing words of the given page. Note: Words are going to be prepared asynchronously

    Declaration

    Objective-C

    - (void)PrepareWords:(int)page_num;

    Swift

    func prepareWords(_ page_num: Int32)

    Parameters

    page_num

    - page number

  • Declaration

    Objective-C

    - (BOOL)WereWordsPrepared:(int)page_num;

    Swift

    func wereWordsPrepared(_ page_num: Int32) -> Bool

    Parameters

    page_num

    - page number

    Return Value

    true if words of the given page has been prepared, false otherwise

  • Declaration

    Objective-C

    - (BOOL)IsThereTextInRect:(double)x1 y1:(double)y1 x2:(double)x2 y2:(double)y2;

    Swift

    func isThereText(inRect x1: Double, y1: Double, x2: Double, y2: Double) -> Bool

    Return Value

    true if there is a text in the given rectangle, false otherwise and point (x2, y2) is the end selection point. The points are defined in screen space.

  • Requests for preparing annotations of the given page. Note: Annotations are going to be prepared asynchronously

    Declaration

    Objective-C

    - (void)PrepareAnnotsForMouse:(int)page_num
               distance_threshold:(double)distance_threshold
              minimum_line_weight:(double)minimum_line_weight;

    Swift

    func prepareAnnots(forMouse page_num: Int32, distance_threshold: Double, minimum_line_weight: Double)

    Parameters

    page_num

    - page number

    distance_threshold

    - Maximum distance from the point (x, y) to the annotation for the annot to be considered a hit.

    minimum_line_weight

    - 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

  • Declaration

    Objective-C

    - (BOOL)WereAnnotsForMousePrepared:(int)page_num;

    Swift

    func wereAnnots(forMousePrepared page_num: Int32) -> Bool

    Parameters

    page_num

    - page number

    Return Value

    true if annotations of the given page have been prepared, false otherwise

  • Declaration

    Objective-C

    - (PTAnnotType)GetAnnotTypeUnder:(double)x y:(double)y;

    Swift

    func getAnnotTypeUnder(_ x: Double, y: Double) -> PTAnnotType

    Parameters

    x

    - x coordinate of the input point

    y

    - y coordinate in the input point

    Return Value

    annotation type at the given point

  • Adds a UIView that will “stick” to a PDF page. The frame of the UIView is assumed to be in the PDFViewCtrl’s coordinate system, and the view will “stick” to page over which it is positioned.

    Declaration

    Objective-C

    - (void)addFloatingView:(nonnull UIView *)view;

    Swift

    func addFloating(_ view: UIView)

    Parameters

    view

    The view to “stick” to a PDF page.

  • Adds a UIView that will “stick” to the specified PDF page with the specified rect.

    Declaration

    Objective-C

    - (void)addFloatingView:(nonnull UIView *)view
                     toPage:(int)pageNumber
               withPageRect:(nonnull PTPDFRect *)pageSpaceRect
                     noZoom:(BOOL)noZoom;

    Swift

    func addFloating(_ view: UIView, toPage pageNumber: Int32, withPageRect pageSpaceRect: PTPDFRect, noZoom: Bool)

    Parameters

    view

    The view to add to the page.

    pageNumber

    The sequence number of the page to add the view to.

    pageSpaceRect

    The rectangle, in PDF coordinates, to add the page to.

    noZoom

    If true, the view will be scaled to the screen size which corresponds to the PDF being viewed at 100%, regardless of the actual viewer zoom level. If false, the view will scale with the other elements on the PDF page.

  • Adds a view that will “stick” to the specified page at the specified point. The size of the view is determined by the input view’s frame.size, and is maintained regardless of the viewer’s zoom level.

    Declaration

    Objective-C

    - (void)addFloatingView:(nonnull UIView *)view
                     toPage:(int)pageNumber
                atPagePoint:(nonnull PTPDFPoint *)pageSpacePoint;

    Swift

    func addFloating(_ view: UIView, toPage pageNumber: Int32, atPagePoint pageSpacePoint: PTPDFPoint)

    Parameters

    view

    The view to add to the page.

    pageNumber

    The sequence number of the page to add the view to.

    pageSpacePoint

    The point, in PDF coordinates, to add the view to.

  • Removes all views added via a -addFloatingView: method.

    Declaration

    Objective-C

    - (void)clearFloatingViews;

    Swift

    func clearFloatingViews()
  • Removes the specified view that was added via a -addFloatingView: method.

    Declaration

    Objective-C

    - (void)removeFloatingView:(nonnull UIView *)view;

    Swift

    func removeFloating(_ view: UIView)

    Parameters

    view

    The view to remove.

  • Removes views that were added via a -addFloatingView: method.

    Declaration

    Objective-C

    - (void)removeFloatingViews:(nonnull NSArray<UIView *> *)views;

    Swift

    func removeFloating(_ views: [UIView])

    Parameters

    views

    An array of views to remove.

  • Repositions the floating views that were added via a -addFloatingView: method.

    Declaration

    Objective-C

    - (void)repositionFloatingViews;

    Swift

    func repositionFloatingViews()
  • Returns an array of views added via a -addFloatingView method on the specified page.

    Declaration

    Objective-C

    - (nonnull NSArray<UIView *> *)floatingViewsOnPage:(int)pageNumber;

    Swift

    func floatingViews(onPage pageNumber: Int32) -> [UIView]

    Parameters

    pageNumber

    The page from which to return views that were added with an -addFloatingView method.

  • This method is unlikley to be needed for most use cases, as explained below.

    The control’s floating views are associated with each page via its PDF “object number”. During most document opertions (editing annotations, re-ordering pages, deleting pages, adding new pages), page PDF object numbers do not change. However if saving with the e_ptlinearized flag, or if using low-level APIs to purposefully change object numbers, this method must be called to ensure that each floating view is associated with the correct page.

    Declaration

    Objective-C

    - (void)clearFloatingViewPageCache;

    Swift

    func clearFloatingViewPageCache()
  • Returns the annotation bounding box present at the specified page number.

    Declaration

    Objective-C

    - (nullable PTPDFRect *)GetScreenRectForAnnot:(nonnull PTAnnot *)annot
                                         page_num:(int)page_num;

    Swift

    func getScreenRect(for annot: PTAnnot, page_num: Int32) -> PTPDFRect?

    Parameters

    annot

    The target annotation

    page_num

    The page number of the page where the annotation is on

    Return Value

    the annotation bounding box in screen points

  • Returns the annotation present at screen coordinates (x, y). If no annotation is present, callling IsValid on the returned annotation will return false. You must acquire a read lock for the doc when retrieving an annotation.

    Declaration

    Objective-C

    - (nullable PTAnnot *)GetAnnotationAt:(int)x
                                        y:(int)y
                        distanceThreshold:(double)distanceThreshold
                        minimumLineWeight:(double)minimumLineWeight;

    Swift

    func getAnnotationAt(_ x: Int32, y: Int32, distanceThreshold: Double, minimumLineWeight: Double) -> PTAnnot?

    Parameters

    x

    The x location in screen coordinates

    y

    The y location in screen coordinates

    distanceThreshold

    Maximum distance from the point (x, y) to the annotation for the annot to be considered a hit. The value used in versions of the SDK prior to 6.3 was 22.

    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. The value used in versions of the SDK prior to 6.3 was 10.

    Return Value

    the annotation at (x, y). If there is no annotation at (x, y), the returned annotation’s IsValid method will return false.

  • Returns an array of annotations under the line (x1, y1, x2, y2) expressed in screen coordinates. Does not include form field annotations.

    @returns An array of annotations under the line (x1, y1, x2, y2) expressed in screen coordinates.

    Declaration

    Objective-C

    - (nonnull NSArray<PTAnnot *> *)GetAnnotationListAt:(int)x1
                                                     y1:(int)y1
                                                     x2:(int)x2
                                                     y2:(int)y2;

    Swift

    func getAnnotationList(at x1: Int32, y1: Int32, x2: Int32, y2: Int32) -> [PTAnnot]

    Parameters

    x1

    The x-coordinate of the first point of the line.

    y1

    The y-coordinate of the first point of the line.

    x2

    The x-coordinate of the second point of the line.

    y2

    The y-coordinate of the second point of the line.

  • Returns an array of all of the annotations on a given page.

    Declaration

    Objective-C

    - (nonnull NSArray<PTAnnot *> *)GetAnnotationsOnPage:(int)page_num;

    Swift

    func getAnnotationsOnPage(_ page_num: Int32) -> [PTAnnot]

    Parameters

    page_num

    The number of the PDF page on which to look for annotaitons.

    Return Value

    An array of annotations that are on the page.

  • Set device DPI, and scale factor. This affects the rendering of certain content, such as annotations with the no_zoom flag.

    Declaration

    Objective-C

    - (void)SetDevicePixelDensity:(double)dpi scale_factor:(double)scale_factor;

    Swift

    func setDevicePixelDensity(_ dpi: Double, scale_factor: Double)

    Parameters

    dpi

    Scale relative to the internal DPI of 96 (default 1.0).

    scale_factor

    Some DPI sensitive content, sush as annotations, can be scaled up, to make the content larger, which can make user interaction easier (default 1.0).

  • Returns the annotation present at screen coordinates (x, y). If no link is present, callling length on the string returned by getUrl of the returned LinkInfo object will be <= 0. You must acquire a read lock for doc when retrieving a LinkInfo object.

    Declaration

    Objective-C

    - (nullable PTLinkInfo *)GetLinkAt:(int)x y:(int)y;

    Swift

    func getLinkAt(_ x: Int32, y: Int32) -> PTLinkInfo?

    Parameters

    x

    The x location in screen coordinates

    y

    The y location in screen coordinates

    Return Value

    link information for a link present at screen coordinates (x, y).

  • Enables or disables requiring two fingers to scroll the viewer.

    Declaration

    Objective-C

    - (void)setMinimumTwoFingersToScrollEnabled:(_Bool)enabled;

    Swift

    func setMinimumTwoFingersToScrollEnabled(_ enabled: Bool)

    Parameters

    enabled

    To require two fingers to scroll send YES; otherwise NO.

  • Called in response to a single tap gesture and is included here so that subclasses may extend or override the functionality.

    Declaration

    Objective-C

    - (void)handleTap:(nonnull UITapGestureRecognizer *)gestureRecognizer;

    Swift

    func handleTap(_ gestureRecognizer: UITapGestureRecognizer)

    Parameters

    gestureRecognizer

    The gesture recognizer that trigger the callback.

  • Called in response to a long press gesture and is included here so that subclasses may extend or override the functionality.

    Declaration

    Objective-C

    - (void)handleLongPress:
        (nonnull UILongPressGestureRecognizer *)gestureRecognizer;

    Swift

    func handleLongPress(_ gestureRecognizer: UILongPressGestureRecognizer)

    Parameters

    gestureRecognizer

    The gesture recognizer that trigger the callback.

  • Acquires a write lock for PTPDFDoc instance used by PTPDFViewCtrl. Simultaneous write access to a PTPDFDoc instance is not allowed. A write lock cannot be acquired if the thread already holds a read lock. Attempting to do so will throw an exception.

    Declaration

    Objective-C

    - (void)DocLock:(BOOL)cancelThreads;

    Swift

    func docLock(_ cancelThreads: Bool)

    Parameters

    cancelThreads

    If true, other threads accessing the document are terminated before trying to lock the document. This ensures a quick return from this function. Otherwise, this function can halt the UI and the app may be unresponsive before the other thread finishes. If the rendering thread is canceled, unlocking the document UnlockDoc will restart the rendering thread.

  • Tries to acquire a write lock on the PTPDFDoc instance used by PTPDFViewCtrl. Returns true if it succeeds and false otherwise.

    Declaration

    Objective-C

    - (BOOL)DocTryLock:(int)milliseconds;

    Swift

    func docTryLock(_ milliseconds: Int32) -> Bool

    Parameters

    milliseconds

    time that the selector will block while trying to aquire the lock before returning.

    Return Value

    true if the lock was aquired, false otherwise.

  • Releases a write lock on the PTPDFDoc instance used by PTPDFViewCtrl and restarts the rendering thread if it was canceled.

    Declaration

    Objective-C

    - (void)DocUnlock;

    Swift

    func docUnlock()
  • Acquires a read lock for PTPDFDoc instance used by PTPDFViewCtrl.

    Declaration

    Objective-C

    - (void)DocLockRead;

    Swift

    func docLockRead()
  • Tries to acquire read lock on the PTPDFDoc instance used by PTPDFViewCtrl. Returns true if it succeeds and false otherwise.

    Declaration

    Objective-C

    - (BOOL)DocTryLockRead:(int)milliseconds;

    Swift

    func docTryLockRead(_ milliseconds: Int32) -> Bool

    Parameters

    milliseconds

    time that the selector will block while trying to aquire the lock before returning.

    Return Value

    true if the lock was aquired, false otherwise.

  • Releases a read lock on the PTPDFDoc instance used by PTPDFViewCtrl.

    Declaration

    Objective-C

    - (void)DocUnlockRead;

    Swift

    func docUnlockRead()
  • Sets the minimum and maximum zoom bounds of PTPDFViewCtrl.

    Note

    if the zoom limits are relative, 1.0 is defined as the zoom level where the document is displayed in page fit mode, where the entire page is visible on screen.

    Declaration

    Objective-C

    - (void)SetZoomLimits:(TrnZoomLimitMode)mode
                  Minimum:(double)min
                 Maxiumum:(double)max;

    Swift

    func setZoomLimits(_ mode: TrnZoomLimitMode, minimum min: Double, maxiumum max: Double)

    Parameters

    mode

    defines how the zoom bounds are to be used

    min

    the minimum zoom bound

    max

    the maximum zoom bound

  • Gets the zoom limit mode of the PTPDFViewCtrl.

    See

    zoomLimitMode

    Declaration

    Objective-C

    - (TrnZoomLimitMode)GetZoomLimitMode;

    Swift

    func getZoomLimitMode() -> TrnZoomLimitMode
  • Gets the minimum zoom bound of the PTPDFViewCtrl.

    See

    zoomMinimumLimit

    Declaration

    Objective-C

    - (double)GetZoomMinimumLimit;

    Swift

    func getZoomMinimumLimit() -> Double
  • Gets the maximum zoom bound of the PTPDFViewCtrl.

    See

    zoomMaximumLimit

    Declaration

    Objective-C

    - (double)GetZoomMaximumLimit;

    Swift

    func getZoomMaximumLimit() -> Double
  • Declaration

    Objective-C

    - (int)GetPageNumberFromScreenPt:(double)x y:(double)y;

    Swift

    func getPageNumber(fromScreenPt x: Double, y: Double) -> Int32

    Return Value

    the number of the page located under the given screen coordinate. The positive number indicates a valid page, whereas number less than 1 means that no page was found.

  • Converts a point expressed in screen coordinates to a point on canvas.

    Declaration

    Objective-C

    - (nonnull PTPDFPoint *)ConvScreenPtToCanvasPt:(nonnull PTPDFPoint *)pt;

    Swift

    func convScreenPt(toCanvasPt pt: PTPDFPoint) -> PTPDFPoint
  • Converts a point expressed in canvas coordinates to a point on screen.

    Declaration

    Objective-C

    - (nonnull PTPDFPoint *)ConvCanvasPtToScreenPt:(nonnull PTPDFPoint *)pt;

    Swift

    func convCanvasPt(toScreenPt pt: PTPDFPoint) -> PTPDFPoint
  • Converts a point expressed in canvas coordinates to a point on a given page.

    Declaration

    Objective-C

    - (nonnull PTPDFPoint *)ConvCanvasPtToPagePt:(nonnull PTPDFPoint *)pt
                                        page_num:(int)page_num;

    Swift

    func convCanvasPt(toPagePt pt: PTPDFPoint, page_num: Int32) -> PTPDFPoint

    Parameters

    page_num

    the page number for the page used as the origin of the destination coordinate system. Negative values are used to represent the current page. Pages are indexed starting from one.

  • Converts a point from a coordinate system of a given page to a point on canvas.

    Declaration

    Objective-C

    - (nonnull PTPDFPoint *)ConvPagePtToCanvasPt:(nonnull PTPDFPoint *)pt
                                        page_num:(int)page_num;

    Swift

    func convPagePt(toCanvasPt pt: PTPDFPoint, page_num: Int32) -> PTPDFPoint

    Parameters

    page_num

    the page number for the page used as the origin of the destination coordinate system. Negative values are used to represent the current page. Pages are indexed starting from one.

  • Converts a point expressed in screen coordinates to a point on a given page.

    Declaration

    Objective-C

    - (nonnull PTPDFPoint *)ConvScreenPtToPagePt:(nonnull PTPDFPoint *)pt
                                        page_num:(int)page_num;

    Swift

    func convScreenPt(toPagePt pt: PTPDFPoint, page_num: Int32) -> PTPDFPoint

    Parameters

    page_num

    the page number for the page used as the origin of the destination coordinate system. Negative values are used to represent the current page. Pages are indexed starting from one.

  • Converts a point from a coordinate system of a given page to a point on screen. If PDFView is in a non-continous page view mode, and the page is not visible, the result is undefined.

    Declaration

    Objective-C

    - (nonnull PTPDFPoint *)ConvPagePtToScreenPt:(nonnull PTPDFPoint *)pt
                                        page_num:(int)page_num;

    Swift

    func convPagePt(toScreenPt pt: PTPDFPoint, page_num: Int32) -> PTPDFPoint

    Parameters

    page_num

    the page number for the page used as the origin of the destination coordinate system. Negative values are used to represent the current page. Pages are indexed starting from one.

  • Converts a PTPDFRect in PDF page coordinates to a CGRect in screen (PTPDFViewCtrl) coordinates.

    @returns The equivalent rectangle, in screen coordinates.

    Declaration

    Objective-C

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

    Swift

    func pdfRectPage2CGRectScreen(_ pdfRect: PTPDFRect, pageNumber: Int32) -> CGRect

    Parameters

    pdfRect

    The rectangle in PDF coordinates

    pageNumber

    The page number that the rectangle is on.

  • Converts a CGRect in screen (PTPDFViewCtrl) coordinates to a PTPDFRect in PDF page coordinates.

    @returns The equivalent rectangle, in page coordinates.

    Declaration

    Objective-C

    - (nonnull PTPDFRect *)CGRectScreen2PDFRectPage:(CGRect)cgRect
                                         PageNumber:(int)pageNumber;

    Swift

    func cgRectScreen2PDFRectPage(_ cgRect: CGRect, pageNumber: Int32) -> PTPDFRect

    Parameters

    cgRect

    The rectangle in screen coordinates

    pageNumber

    The page number for which the returned coordinates should reference

  • Snaps a point (in screen space) to the nearest piece of document geometry.

    @returns The nearest point in document geometry.

    Declaration

    Objective-C

    - (nonnull PTPDFPoint *)SnapToNearestInDoc:(nonnull PTPDFPoint *)screen_pt;

    Swift

    func snapToNearest(inDoc screen_pt: PTPDFPoint) -> PTPDFPoint

    Parameters

    screen_pt

    the point to snap.

  • Set the point snapping mode for the -SnapToNearestInDoc: method.

    By default -SnapToNearestInDoc: will snap to line endpoints, midpoints, and intersections (ie. the e_ptDefaultSnapMode snapping mode).

    Declaration

    Objective-C

    - (void)SetSnappingMode:(unsigned int)mode_flags;

    Swift

    func setSnappingMode(_ mode_flags: UInt32)

    Parameters

    mode_flags

    a bitwise combination of the members of PTGeometryCollectionSnappingMode

  • Note

    to obtain a transformation matrix that maps screen coordinates to page coordinates, you can invert the device matrix. For example:

    Common::Matrix2D scr2page(pdfviewctrl.GetDeviceTransform());
    scr2page.Inverse();
    

    Declaration

    Objective-C

    - (nullable PTMatrix2D *)GetDeviceTransform:(int)page_num;

    Swift

    func getDeviceTransform(_ page_num: Int32) -> PTMatrix2D?

    Parameters

    page_num

    same as for PTPDFViewCtrl.Conv???() methods.

    Return Value

    the device transformation matrix. The device transformation matrix maps the page coordinate system to screen (or device) coordinate system.

  • The current width of the canvas. The canvas coordinate system is defined by a bounding box that surrounds all pages in the view.

    Declaration

    Objective-C

    @property (nonatomic, readonly, getter=GetCanvasWidth) double canvasWidth;

    Swift

    var canvasWidth: Double { get }
  • Returns the current canvas width.

    Unavailable in Swift. Please use the property:

    Declaration

    Objective-C

    - (double)GetCanvasWidth;

    Swift

    func getCanvasWidth() -> Double
  • The current height of the canvas. The canvas coordinate system is defined by a bounding box that surrounds all pages in the view.

    Declaration

    Objective-C

    @property (nonatomic, readonly, getter=GetCanvasHeight) double canvasHeight;

    Swift

    var canvasHeight: Double { get }
  • Returns the current canvas height.

    Unavailable in Swift. Please use the property:

    Declaration

    Objective-C

    - (double)GetCanvasHeight;

    Swift

    func getCanvasHeight() -> Double
  • Declaration

    Objective-C

    - (BOOL)IsFinishedRendering:(BOOL)visible_region_only;

    Swift

    func isFinishedRendering(_ visible_region_only: Bool) -> Bool

    Parameters

    visible_region_only

    Specifies if the method refers only to currently visible content.

    Return Value

    true is the rendering thread finished rendering the view, false if the rendering is still in progress.

  • Cancels rendering in` progress. If PTPDFViewCtrl is not busy rendering the page, the function has no side effects.

    Declaration

    Objective-C

    - (void)CancelRendering;

    Swift

    func cancelRendering()
  • Redraws the contents of the buffer. Equivalent to Update:NO

    Declaration

    Objective-C

    - (void)Update;

    Swift

    func update()
  • Redraws the contents of the buffer.

    Declaration

    Objective-C

    - (void)Update:(_Bool)all;

    Swift

    func update(_ all: Bool)

    Parameters

    all

    if true, all of the rendered content is discarded and re-rendered; otherwise, only the visible region will be re-rendered.

  • Redraws the area covered with a given annotation.

    Declaration

    Objective-C

    - (void)UpdateWithAnnot:(nonnull PTAnnot *)annot page_num:(int)page_num;

    Swift

    func update(with annot: PTAnnot, page_num: Int32)

    Parameters

    annot

    The annotation to update.

    page_num

    The page number on which the annotation is located.

  • Redraws the given area in the buffer.

    Declaration

    Objective-C

    - (void)UpdateWithRect:(nonnull PTPDFRect *)update;

    Swift

    func update(with update: PTPDFRect)

    Parameters

    update

    The rectangle to update expressed in screen coordinates.

  • Redraws the given area covered by the given field. Useful when a field is connected to other fields.

    Declaration

    Objective-C

    - (void)UpdateWithField:(nonnull PTField *)field;

    Swift

    func update(with field: PTField)

    Parameters

    field

    The field to update.

  • 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

    Objective-C

    - (void)RefreshAndUpdate:(nonnull PTViewChangeCollection *)view_change;

    Swift

    func refreshAndUpdate(_ view_change: PTViewChangeCollection)

    Parameters

    view_change

    contains all the updated fields and rectangles.

  • Renders content that requires rendering. May be called to resume rendering after CancelRendering.

    Declaration

    Objective-C

    - (void)RequestRendering;

    Swift

    func requestRendering()
  • Set the suggested memory size of the rendered content.

    PTPDFViewCtrl keeps off-screen content in order to achieve better viewing experience; however, this increases memory usage. By default, PTPDFViewCtrl will use 80% of available memory to render on-screen and off-screen content. The value set here will be overidden if PurgeMemory is called.

    Note

    If you want to minimize memory usage at the cost of viewing experience quality, you can set allowedMax to 0 and PTPDFViewCtrl will not keep any off-screen content. Also note that this function only controls the memory used to store rendered content not the entire memory footprint of the control.

    Declaration

    Objective-C

    - (void)SetRenderedContentBufferSize:(long)allowedMax;

    Swift

    func setRenderedContentBufferSize(_ allowedMax: Int)

    Parameters

    allowedMax

    the allowed heap memory usage in MB.

  • Removes all non-visible portions of document to reduce memory consumption. This will reset the value set via SetContentBufferSize back to the default of 80% of available memory.

    Suggested use is in response to a low memory warning. May slightly slow down the time to complete rendering.

    Declaration

    Objective-C

    - (void)PurgeMemory;

    Swift

    func purgeMemory()
  • Enables of disables caching of images, fonts, and other resources. Disabling caching can lower memory requirements at the expense of rendering speed.

    Declaration

    Objective-C

    - (void)SetCaching:(BOOL)enabled;

    Swift

    func setCaching(_ enabled: Bool)

    Parameters

    enabled

    if true caching is enabled, if false caching is disabled. @default by default caching is enabled

  • Sets the cache parameters of the page cache on disk (which caches content streams and mipmapped images) for this specific document. These parameters will override the default cache parameters. Note that if this function is called after the document has been rasterized, it has no effect.

    Declaration

    Objective-C

    + (void)SetViewerCache:(nonnull PTSDFDoc *)document
            max_cache_size:(unsigned long)max_cache_size
                   on_disk:(BOOL)on_disk;

    Swift

    class func setViewerCache(_ document: PTSDFDoc, max_cache_size: UInt, on_disk: Bool)

    Parameters

    document

    The document whose settings will be modified

    max_cache_size

    The maximum size, in bytes, of the entire document’s page cache

    on_disk

    Whether or not to store the cache on disk

  • Specify the different thumbnail settings for the viewer.

    Declaration

    Objective-C

    - (void)SetupThumbnails:(BOOL)use_embedded
          generate_at_runtime:(BOOL)generate_at_runtime
               use_disk_cache:(BOOL)use_disk_cache
        thumb_max_side_length:(int)thumb_max_side_length
           max_abs_cache_size:(unsigned long)max_abs_cache_size
          max_perc_cache_size:(double)max_perc_cache_size;

    Swift

    func setupThumbnails(_ use_embedded: Bool, generate_at_runtime: Bool, use_disk_cache: Bool, thumb_max_side_length: Int32, max_abs_cache_size: UInt, max_perc_cache_size: Double)

    Parameters

    use_embedded

    Enables or disables using thumbnails embedded in the PDF document as a preview of the rendered page.

    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.

  • Clears the thumbnail cache.

    Declaration

    Objective-C

    - (void)ClearThumbCache;

    Swift

    func clearThumbCache()
  • Requests a thumbnail from the document, which is returned in the delegate method GotThumbAsync:(int)page_num thumbImage:(UIImage*)image;

    If there is no document set on the control, it will throw an exception.

    Declaration

    Objective-C

    - (void)GetThumbAsync:(int)page_num;

    Swift

    func getThumbAsync(_ page_num: Int32)
  • Requests a thumbnail from the document, which is returned in the provided completion block. If there is no document set on the control, this method will throw an exception.

    Declaration

    Objective-C

    - (void)GetThumbAsync:(int)page_num
               completion:(nonnull void (^)(UIImage *_Nullable))completion;

    Swift

    func getThumbAsync(_ page_num: Int32) async -> UIImage?
  • Cancels all outstanding thumbnail requests queued by GetThumbAsync:

    Declaration

    Objective-C

    - (void)CancelAllThumbRequests;

    Swift

    func cancelAllThumbRequests()
  • The total number of pages in the document displayed by this PDFViewCtrl.

    If pages are added, moved, or removed from the current document then it is necessary to call the -UpdatePageLayout method to synchronize the PDFViewCtrl’s displayed pages with the document’s.

    Declaration

    Objective-C

    @property (nonatomic, readonly, getter=GetPageCount) int pageCount;

    Swift

    var pageCount: Int32 { get }
  • Unavailable in Swift. Please use the property:

    See

    pageCount

    Declaration

    Objective-C

    - (int)GetPageCount;

    Swift

    func getPageCount() -> Int32

    Return Value

    the total number of pages in the document.

  • Updates the page layout within the view.

    This function must be called after the document page sequence is modified (such as when a page is being added to or removed from the document) or after changes to page dimensions (e.g. after a page is rotated or resized).

    Declaration

    Objective-C

    - (void)UpdatePageLayout;

    Swift

    func updatePageLayout()
  • Used to add extra vertical scroll space to the PDF scroll view (inner scroll view) when the keyboard would otherwise block the bottom of the document when editing interactive forms.

    Declaration

    Objective-C

    - (void)setExtraVerticalContent:(int)points;

    Swift

    func setExtraVerticalContent(_ points: Int32)
  • Will cause PTPDFViewCtrl to scroll the content so that the onscreen keyboard does not hide the content being edited. See FormFillTool.m in the standard libTools distribution for example usage.

    Declaration

    Objective-C

    - (void)keyboardWillShow:(nonnull NSNotification *)notification
        rectToNotOverlapWith:(CGRect)rect;

    Swift

    func keyboardWillShow(_ notification: Notification, rectToNotOverlapWith rect: CGRect)

    Parameters

    notification

    The notification object returned by a UIKeyboardWillShowNotification notification.

    rect

    The rectangle, in screen coordinates, that the keyboard should not overlap with.

  • Will cause PTPDFViewCtrl to scroll the content so that the onscreen keyboard does not hide the content being edited. See FormFillTool.m in the standard libTools distribution for example usage.

    Declaration

    Objective-C

    - (void)keyboardWillShow:(nonnull NSNotification *)notification
        rectToNotOverlapWith:(CGRect)rect
                     topEdge:(CGFloat)topEdge;

    Swift

    func keyboardWillShow(_ notification: Notification, rectToNotOverlapWith rect: CGRect, topEdge: CGFloat)

    Parameters

    notification

    The notification object returned by a UIKeyboardWillShowNotification notification.

    rect

    The rectangle, in screen coordinates, that the keyboard should not overlap with.

    topEdge

    The top screen coordinate above which the rectangle should not be scrolled under.

  • Will cause PTPDFViewCtrl to reset the scroll position after a call to keyboardWillShow:rectToNotOverlapWith.

    Declaration

    Objective-C

    - (void)keyboardWillHide:(nonnull NSNotification *)notification;

    Swift

    func keyboardWillHide(_ notification: Notification)

    Parameters

    notification

    The notificaion object returned by a UIKeyboardWillHideNotification notification.

  • The zoomScale of PTPDFViewCtrl. This will return 1.0 except when the control is actively being scaled for example by a pinch gesture. To get/set the zoom level of the displayed PDF, use GetZoom and SetZoom.

    Declaration

    Objective-C

    - (double)zoomScale;

    Swift

    func zoomScale() -> Double
  • Requests action object to be executed by PTPDFViewCtrl. Action must belong to the document currently displayed in PTPDFViewCtrl.

    Declaration

    Objective-C

    - (void)ExecuteAction:(nonnull PTAction *)action;

    Swift

    func execute(_ action: PTAction)

    Parameters

    action

    object that is to be executed.

  • Requests action object to be executed by PTPDFViewCtrl. Action must belong to the document currently displayed in PTPDFViewCtrl.

    Declaration

    Objective-C

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

    Swift

    func executeAction(with action_param: PTActionParameter)

    Parameters

    action_param

    Container for parameters used in handling various actions.

  • Sets if document is to be presented for a left-to-right or right-to-left language. Default is left-to-right.

    Declaration

    Objective-C

    - (void)SetRightToLeftLanguage:(BOOL)isRightToLeft;

    Swift

    func setRightToLeftLanguage(_ isRightToLeft: Bool)

    Parameters

    isRightToLeft

    true if language is right-to-left; false otherwise.

  • Declaration

    Objective-C

    - (BOOL)GetRightToLeftLanguage;

    Swift

    func getRightToLeftLanguage() -> Bool

    Return Value

    true if PTPDFViewCtrl is set to display a PDF with a right-to-left language; false otherwise.

  • Gets the box used by PDFViewCtrl for displaying.

    Declaration

    Objective-C

    - (PTBox)GetPageBox;

    Swift

    func getPageBox() -> PTBox
  • Sets the box to display in the viewer.

    Declaration

    Objective-C

    - (void)SetPageBox:(PTBox)region;

    Swift

    func setPageBox(_ region: PTBox)

    Parameters

    region

    the new PTBox to display.

  • Enable undo/redo in this PDFViewCtrl.

    Declaration

    Objective-C

    - (void)EnableUndoRedo;

    Swift

    func enableUndoRedo()
  • Whether undo/redo is enabled in this PDFViewCtrl. The default value is NO.

    Declaration

    Objective-C

    @property (nonatomic, assign, unsafe_unretained, readonly,
              getter=isUndoRedoEnabled) BOOL undoRedoEnabled;

    Swift

    var isUndoRedoEnabled: Bool { get }
  • Returns whether there is an undo state in the undo/redo chain.

    Declaration

    Objective-C

    - (BOOL)CanUndo;

    Swift

    func canUndo() -> Bool

    Return Value

    whether there is an undo state in the undo/redo chain

  • Returns whether there is a redo state in the undo/redo chain.

    Declaration

    Objective-C

    - (BOOL)CanRedo;

    Swift

    func canRedo() -> Bool

    Return Value

    whether there is a redo state in the undo/redo chain

  • Return to the previous state in the undo/redo chain. Returns any meta-data associated with that state.

    Declaration

    Objective-C

    - (nonnull NSString *)Undo;

    Swift

    func undo() -> String

    Return Value

    meta-data associated with the current state in the undo/redo chain after undoing one state.

  • Go to the next state in the undo/redo chain. Returns any meta-data associated with that state.

    Declaration

    Objective-C

    - (nonnull NSString *)Redo;

    Swift

    func redo() -> String

    Return Value

    meta-data associated with the current state in the undo/redo chain after redoing one state.

  • Creates a new state at the top of the undo/redo chain by taking a snapshot.

    Declaration

    Objective-C

    - (void)TakeUndoSnapshot:(nonnull NSString *)meta_info;

    Swift

    func takeUndoSnapshot(_ meta_info: String)

    Parameters

    meta_info

    meta-data to be attached to this new state.

  • Returns any meta-data associated with the previous sate in the undo/redo chain.

    Declaration

    Objective-C

    - (nonnull NSString *)GetNextUndoInfo;

    Swift

    func getNextUndoInfo() -> String

    Return Value

    meta-data associated with the previous sate in the undo/redo chain.

  • Returns any meta-data associated with the next sate in the undo/redo chain.

    Declaration

    Objective-C

    - (nonnull NSString *)GetNextRedoInfo;

    Swift

    func getNextRedoInfo() -> String

    Return Value

    meta-data associated with the next sate in the undo/redo chain.

  • Returns to the initial state in the undo/redo chain.

    Declaration

    Objective-C

    - (void)RevertAllChanges;

    Swift

    func revertAllChanges()
  • The NSUndoManager instance used by this PDFViewCtrl.

    When -isUndoRedoEnabled is NO, this property returns the default UIResponder value obtained by walking up the responder chain to find the first NSUndoManager.

    When -isUndoRedoEnabled is YES, this property returns a local NSUndoManager instance.

    Declaration

    Objective-C

    @property (nonatomic, strong, readonly, nullable) NSUndoManager *undoManager;

    Swift

    var undoManager: UndoManager? { get }
  • The PTExternalAnnotManager that is created and returned by -EnableAnnotationManager:.

    For example usage, please see the PTCollaborationManager class in Tools.framework.

    Declaration

    Objective-C

    @property (nonatomic, strong, readonly, nullable) PTExternalAnnotManager *externalAnnotManager;

    Swift

    var externalAnnotManager: PTExternalAnnotManager? { get }
  • Enables the collaboration annotation manager. The e_ptadmin_undo_own mode is used by default.

    Declaration

    Objective-C

    - (nonnull PTExternalAnnotManager *)EnableAnnotationManager:
        (nonnull NSString *)userID;

    Swift

    func enableAnnotationManager(_ userID: String) -> PTExternalAnnotManager

    Parameters

    userID

    The name of the author to associate with new annotations.

    Return Value

    the PTExternalAnnotManager created for and associated with this PTPDFViewCtrl

  • Enables the collaboration annotation manager.

    Declaration

    Objective-C

    - (nonnull PTExternalAnnotManager *)
        EnableAnnotationManager:(nonnull NSString *)userID
                           mode:(PTExternalAnnotManagerMode)mode;

    Swift

    func enableAnnotationManager(_ userID: String, mode: PTExternalAnnotManagerMode) -> PTExternalAnnotManager

    Parameters

    userID

    The name of the author to associate with new annotations.

    mode

    Return Value

    the PTExternalAnnotManager created for and associated with this PTPDFViewCtrl

  • The extra left (x) and top (y) scrollable area

    @returns The extra left (x) and top (y) scrollable area

    Declaration

    Objective-C

    - (CGPoint)getInsetOffsets;

    Swift

    func getInsetOffsets() -> CGPoint
  • Undocumented

    Declaration

    Objective-C

    @property (nonatomic) CGFloat additionalYOffset

    Swift

    var additionalYOffset: CGFloat { get set }
  • Synchronously acquires a write lock for the PTPDFDoc instance used by the PTPDFViewCtrl and executes the given block on the current queue.

    Simultaneous write access to a PTPDFDoc instance is not allowed. A write lock cannot be acquired if the thread already holds a read lock - attempting to do so is an error.

    Declaration

    Objective-C

    - (void)DocLock:(BOOL)cancelThreads
          withBlock:(nonnull void (^)(PTPDFViewCtrl *_Nonnull))block;

    Parameters

    cancelThreads

    If true, other threads accessing the document are terminated before trying to lock the document. This ensures a quick return from this function. Otherwise, this function can halt the UI and the app may be unresponsive before the other thread finishes. If the rendering thread is canceled, the rendering thread will restart when the document is unlocked.

    block

    The block to perform.

  • Synchronously acquires a read lock for the PTPDFDoc instance used by the PTPDFViewCtrl and executes the given block on the current queue.

    Declaration

    Objective-C

    - (void)DocLockReadWithBlock:(nonnull void (^)(PTPDFViewCtrl *_Nonnull))block;

    Parameters

    block

    The block to perform.

  • Synchronously acquires a write lock for the PTPDFDoc instance used by the PTPDFViewCtrl. Simultaneous write access to a PTPDFDoc instance is not allowed. A write lock cannot be acquired if the thread already holds a read lock. Attempting to do so is an error.

    Any NSException thrown while locking or unlocking the document, or executing the block, is converted into an NSError object and returned in the error parameter.

    Note

    In Swift, this method returns Void and is marked with the throws keyword to indicate that it throws an error in cases of failure.

    Declaration

    Objective-C

    - (BOOL)DocLock:(BOOL)cancelThreads
          withBlock:(nonnull void (^)(PTPDFDoc *_Nullable))block
              error:(out NSError *_Nullable *_Nullable)error;

    Swift

    func docLock(_ cancelThreads: Bool, with block: (PTPDFDoc?) -> Void) throws

    Parameters

    cancelThreads

    If true, other threads accessing the document are terminated before trying to lock the document. This ensures a quick return from this function. Otherwise, this function can halt the UI and the app may be unresponsive before the other thread finishes. If the rendering thread is canceled, unlocking the document UnlockDoc will restart the rendering thread.

    block

    The block to perform.

    error

    On input, a pointer to an error object. If an error occurs (an NSException is thrown), this pointer is set to an actual error object containing the error information. You may specify nil for this parameter if you do not want the error information.

    Return Value

    YES if the document could be locked and the block could be run successfully. If an error occurs (an NSException is thrown), this method returns NO and assigns an appropriate error object to the error parameter.

  • Synchronously acquires a read lock for the PTPDFDoc instance used by the PTPDFViewCtrl and executes the given block on the current queue. Any NSException thrown while locking or unlocking the document, or executing the block, is converted into an NSError object and returned in the error parameter.

    Note

    In Swift, this method returns Void and is marked with the throws keyword to indicate that it throws an error in cases of failure.

    Declaration

    Objective-C

    - (BOOL)DocLockReadWithBlock:(nonnull void (^)(PTPDFDoc *_Nullable))block
                           error:(out NSError *_Nullable *_Nullable)error;

    Swift

    func docLockRead(_ block: (PTPDFDoc?) -> Void) throws

    Parameters

    block

    The block to perform.

    error

    On input, a pointer to an error object. If an error occurs (an NSException is thrown), this pointer is set to an actual error object containing the error information. You may specify nil for this parameter if you do not want the error information.

    Return Value

    YES if the document could be locked and the block could be run successfully. If an error occurs (an NSException is thrown), this method returns NO and assigns an appropriate error object to the error parameter.

  • Navigates the PDFViewCtrl to the page at the specified PDF page number.

    Note

    In Swift, this method returns Void and is marked with the throws keyword to indicate that it throws an error in cases of failure.

    Declaration

    Objective-C

    - (BOOL)NavigateToPageNumber:(int)pageNumber
                           error:(out NSError *_Nullable *_Nullable)error;

    Swift

    func navigate(toPageNumber pageNumber: Int32) throws

    Parameters

    pageNumber

    The PDF page number to which to navigate

    error

    On input, a pointer to an error object. If an error occurs, this pointer is set to an actual error object containing the error information. You may specify nil for this parameter if you do not want the error information.

    Return Value

    YES if the navigation was successful. If an error occurs, this method returns NO and assigns an appropriate error object to the error parameter.

  • Undocumented

    Declaration

    Objective-C

    - (void)enumerateAnnotationsOnPageNumber:(int)pageNumber withBlock:(void (NS_NOESCAPE ^)(PTAnnot *annotation, NSUInteger index, BOOL *stop))block;

    Swift

    func enumerateAnnotations(onPageNumber pageNumber: Int32, with block: (PTAnnot, UInt, UnsafeMutablePointer<ObjCBool>) -> Void)
  • Undocumented

    Declaration

    Objective-C

    - (void)enumerateAnnotationsFromPageNumber:(int)startPageNumber toPageNumber:(int)endPageNumber withBlock:(void (NS_NOESCAPE ^)(int pageNumber, PTAnnot *annotation, NSUInteger indexOnPage, BOOL *stop))block;

    Swift

    func enumerateAnnotations(fromPageNumber startPageNumber: Int32, toPageNumber endPageNumber: Int32, with block: (Int32, PTAnnot, UInt, UnsafeMutablePointer<ObjCBool>) -> Void)
  • Undocumented

    Declaration

    Objective-C

    - (void)enumerateAnnotationsWithBlock:(void (NS_NOESCAPE ^)(int pageNumber, PTAnnot *annotation, NSUInteger indexOnPage, BOOL *stop))block;

    Swift

    func enumerateAnnotations() async -> (Int32, PTAnnot, UInt, UnsafeMutablePointer<ObjCBool>)
  • The zoom ratio of point size to physical size

    Declaration

    Objective-C

    @property (nonatomic) double zoomWhenPrinted;

    Swift

    var zoomWhenPrinted: Double { get set }