Accusoft PDF Viewer Documentation

v3.6.147042

Class PdfViewerControl

Instance of the PDF Viewer

Hierarchy

  • PdfViewerControl

Index

Methods

Pro getAnnotations

  • getAnnotations(): Promise<{ annotations: Annotation[] }>
  • Gets the current state of the annotations loaded in the viewer. Intended to give you a way to export annotations from one viewer so that you can reload them later in a different viewer via loadAnnotations.

    Note that the array of objects returned by getAnnotations are merely a copy of the annotations in the viewer. Any changes you make to these objects WILL NOT affect the actual annotations in the viewer, and any changes made by the user to the annotations in the viewer WILL NOT affect the state of the objects returned from this method. Use getAnnotations to simply get a copy of the current state of the annotations in the viewer.

    rejects

    with an error with a name property of "FeatureNotLicensed" if your license key does not enable annotation functionality.

    Returns Promise<{ annotations: Annotation[] }>

    • Promise which resolves to { annotations: Array }

Pro loadAnnotations

  • loadAnnotations(options: { annotations: Annotation[] }): Promise<Object>
  • Loads annotations into the viewer. Intended for reloading annotations previously exported by a call to getAnnotations.

    Will not remove any annotations which already exist in the viewer. Can be called repeatedly to load more annotations.

    rejects

    with an error with a name property of "NonUniqueAnnotationIdError" if any of the items in the annotations array use an id value which is used by another annotation in either the given annotations array or by an annotation already loaded in the viewer.

    rejects

    with an error with a name property of "FeatureNotLicensed" if your license key does not enable annotation functionality.

    Parameters

    Returns Promise<Object>

    Promise which resolves to an empty Object

Static create

  • Creates a new PDF viewer within a page.

    rejects

    with an error with a name property of "ExpiredLicenseKeyError" if your license key has expired.

    rejects

    with an error with a name property of "InvalidLicenseKeyError" if your license key is invalid or incompatible for any reason.

    Parameters

    • options: object
      • Pro Optional allowedControls?: object

        Configuration for display of tools and controls in the user interface. Some controls may be hidden/shown/moved due to space or touch gesture considerations depending on the device and viewport. If undefined, uses default interface controls defined below.

        • Optional ellipseTool?: boolean

          Whether the ellipse tool is available to the user in the toolbar, allowing them to create new ellipse annotations.

          defaultvalue

          false

        • Optional freehandDrawingTool?: boolean

          Whether the freehand drawing tool is available to the user in the toolbar, allowing them to create freehand drawing annotations.

          defaultvalue

          false

        • Optional freehandSignatureTool?: boolean

          Whether the freehand signature tool is available to the user in the toolbar, allowing them to draw their signature and place it as an annotation on the document.

          defaultvalue

          false

        • Optional fullScreenToggle?: boolean

          Whether the full screen toggle button is available to the user.

          Note that, even when true, the full screen toggle may still be hidden if the viewer is too small.

          defaultvalue

          true

        • Optional lineTool?: boolean

          Whether the line tool is available to the user in the toolbar, allowing them to create new line annotations.

          defaultvalue

          false

        • Optional nextAndPreviousPageButtons?: boolean

          Whether next and previous page navigation buttons are available to the user.

          defaultvalue

          true

        • Optional pageNumberAndCount?: boolean

          Whether the current page number and total page count are displayed to the user. When displayed, the user can also tap/click on the displayed current page number to input a specific page number to change to.

          defaultvalue

          true

        • Optional printing?: boolean

          Whether printing controls are available to the user.

          Note that, even when true, printing controls are hidden when a mobile-friendly interface is shown since mobile printing is not currently supported.

          defaultvalue

          true

        • Optional rectangleTool?: boolean

          Whether the rectangle tool is available to the user in the toolbar, allowing them to create new rectangle annotations.

          defaultvalue

          false

        • Optional search?: boolean

          Whether search controls are available to the user.

          defaultvalue

          true

        • Optional textHighlightTool?: boolean

          Whether the text highlight tool is available to the user in the toolbar, allowing them to create text highlight annotations.

          defaultvalue

          false

        • Optional thumbnails?: boolean

          Whether controls to view and navigate by page thumbnails are available to the user.

          defaultvalue

          true

        • Optional zoomInAndOutButtons?: boolean

          Whether zoom in and zoom out buttons are available to the user.

          Note that, even when true, these buttons may still be hidden if the viewer is too small.

          Zooming is always possible via touchscreen gestures and via keyboard and mousewheel actions.

          defaultvalue

          true

      • container: Element

        DOM element where the viewer should be created.

      • Optional licenseKey?: string

        Optional. PDF Viewer license key.

        When not provided, the viewer will be limited to free features and will include "Powered by Accusoft" branding.

        When the value 'eval' is provided, the viewer will be created in Evaluation Mode, which will allow paid features to be evaluated, and will apply additional branding, such as a full page watermark.

        defaultvalue

        undefined

      • sourceDocument: string | Uint8Array

        PDF document to open.

        May be one of the two following types:

        • string URL to a PDF. Both standard and data URLs are supported.
        • Uint8Array A byte array of the contents of the PDF document.

    Returns Promise<PdfViewerControl>

Legend

  • Property
  • Method
  • Static method
© 2022 Accusoft Corporation. All rights reserved.