Namespace: PSPDFKit

PSPDFKit

The main PSPDFKit namespace is exported in the global PSPDFKit.

Classes

Namespaces

Members

Methods

Type Definitions




Members

(static, constant) Alignment

Specifies the alignment of an UI element relative to its parent container.

Properties:
Name Type Description
START PSPDFKit.Alignment
END PSPDFKit.Alignment

(static, readonly) AnnotationsWillChangeReason

Indicates the reason why PSPDFKit.AnnotationsWillChangeEvent was emitted.

(static, constant) AutoSaveMode

When working with annotations and form field values, there are multiple options when the data can get saved. The AutoSaveMode controls this behavior.

Properties:
Name Type Description
IMMEDIATE PSPDFKit.AutoSaveMode

Saves immediately whenever an attribute of the annotation changed, or whenever a form field value got updated.

INTELLIGENT PSPDFKit.AutoSaveMode

Saves annotations automatically, when the user finishes editing an annotation. For form fields, this behaves like PSPDFKit.AutoSaveMode.IMMEDIATE.

DISABLED PSPDFKit.AutoSaveMode

Never saves annotations or form field values automatically. Annotations and form field values can still be saved via PSPDFKit.Instance#save or PSPDFKit.Instance#saveFormFieldValues

In this mode, document signatures validation information will not be automatically updated if the document is modified, until changes are saved.

(static, constant) BlendMode

Represents one of the available blend modes for highlight and ink annotations.

Properties:
Name Type Description
normal PSPDFKit.BlendMode
multiply PSPDFKit.BlendMode
screen PSPDFKit.BlendMode
overlay PSPDFKit.BlendMode
darken PSPDFKit.BlendMode
lighten PSPDFKit.BlendMode
colorDodge PSPDFKit.BlendMode
colorBurn PSPDFKit.BlendMode
hardLight PSPDFKit.BlendMode
softLight PSPDFKit.BlendMode
difference PSPDFKit.BlendMode
exclusion PSPDFKit.BlendMode

(static, constant) BorderStyle

Represents one of the available border styles for the widget annotations.

Properties:
Name Type Description
solid PSPDFKit.BorderStyle
dashed PSPDFKit.BorderStyle
beveled PSPDFKit.BorderStyle
inset PSPDFKit.BorderStyle
underline PSPDFKit.BorderStyle

(static) Callout: object

Callout arrow line properties.

Properties of the arrow line attached to a callout (text) annotation.

Type:
  • object
Properties:
Name Type Attributes Description
start PSPDFKit.Geometry.Point <nullable>

Starting point of the arrow line.

knee PSPDFKit.Geometry.Point <nullable>

Knee point of the arrow line.

end PSPDFKit.Geometry.Point <nullable>

Ending point of the arrow line.

cap PSPDFKit.LineCap <nullable>

The line cap style.

innerRectInset PSPDFKit.Geometry.Inset <nullable>

The inner rectangle inset.

(static, constant) CertificateChainValidationStatus

The different possible validation states of the certificate chain.

Properties:
Name Type Description
ok PSPDFKit.CertificateChainValidationStatus

The certificate chain validates correctly.

ok_but_self_signed PSPDFKit.CertificateChainValidationStatus

The certificate chain contains a self-signed certificate.

ok_but_could_not_check_revocation PSPDFKit.CertificateChainValidationStatus

Revocation check network error. Either due to invalid server URL or network timeout. The certificate is valid with a warning.

untrusted PSPDFKit.CertificateChainValidationStatus

The certificate chain contains a certificate that has been classified as "untrusted".

The certificate date is correct, but the identity is unknown because it has not been included in the list of trusted certificates and none of its parents are trusted certificates.

expired PSPDFKit.CertificateChainValidationStatus

The certificate used to sign the document has expired now. Note that the certificate may be valid at the time the document was signed, which is not checked.

not_yet_valid PSPDFKit.CertificateChainValidationStatus

The certificate used to sign the document is not valid yet.

invalid PSPDFKit.CertificateChainValidationStatus

The certificate is not valid.

revoked PSPDFKit.CertificateChainValidationStatus

The certificate has been revoked.

failed_to_retrieve_signature_contents PSPDFKit.CertificateChainValidationStatus

Could not fetch the contents of the signature.

general_validation_problem PSPDFKit.CertificateChainValidationStatus

An unknown problem happened when the certificate trust chain was validated.

Between the possible reasons for this could be that the signature is malformed, the certificate chain is too long and other unknown conditions.

(static, constant) ComparisonOperationType

Describes types for document comparison operation.

Properties:
Name Type Description
TEXT PSPDFKit.ComparisonOperationType

Compare the text of documents.

(static, constant) Conformance

Represents one of the available conformance types for PDF/A documents.

Properties:
Name Type Description
PDFA_1A PSPDFKit.Conformance
PDFA_1B PSPDFKit.Conformance
PDFA_2A PSPDFKit.Conformance
PDFA_2U PSPDFKit.Conformance
PDFA_2B PSPDFKit.Conformance
PDFA_3A PSPDFKit.Conformance
PDFA_3U PSPDFKit.Conformance
PDFA_3B PSPDFKit.Conformance
PDFA_4 PSPDFKit.Conformance
PDFA_4E PSPDFKit.Conformance
PDFA_4F PSPDFKit.Conformance

(static, constant) DocumentComparisonSourceType

Represents one of the available document sources to be used in document comparison.

Properties:
Name Type Description
USE_OPEN_DOCUMENT PSPDFKit.DocumentComparisonSourceType

use the currently open document as source.

USE_FILE_DIALOG PSPDFKit.DocumentComparisonSourceType

show the file dialog for the user to choose the source document from the local file system.

(static, constant) DocumentIntegrityStatus

The different signature validation states the document can be in.

Properties:
Name Type Description
ok PSPDFKit.DocumentIntegrityStatus

The part of the document covered by the signature has not been modified.

tampered_document PSPDFKit.DocumentIntegrityStatus

The part of the document covered by the signature has been modified.

failed_to_retrieve_signature_contents PSPDFKit.DocumentIntegrityStatus

The signature /Contents couldn't be parsed.

failed_to_retrieve_byterange PSPDFKit.DocumentIntegrityStatus

The signature /ByteRange couldn't be parsed.

failed_to_compute_digest PSPDFKit.DocumentIntegrityStatus

The digest of the document couldn't be calculated.

failed_retrieve_signing_certificate PSPDFKit.DocumentIntegrityStatus

The signing certificate from the signature contents couldn't be extracted.

failed_retrieve_public_key PSPDFKit.DocumentIntegrityStatus

The public key from the signature contents couldn't be extracted.

failed_encryption_padding PSPDFKit.DocumentIntegrityStatus

The encryption padding from the signature contents couldn't be extracted.

tampered_or_invalid_timestamp PSPDFKit.DocumentIntegrityStatus

The digital signature contains a timestamp that is not valid or the timestamped data was tampered with.

general_failure PSPDFKit.DocumentIntegrityStatus

An unspecific error.

(static, constant) DocumentValidationStatus

The different possible validation states of the document. Based on the validation of the digital signatures it contains.

Properties:
Name Type Description
valid PSPDFKit.DocumentValidationStatus

All of the signatures of the document are valid, that is, it should be shown with a green checkmark or similar in the UI.

warning PSPDFKit.DocumentValidationStatus

All of the signatures of the document are valid with concerns, that is, it should be shown with a yellow warning or similar in the UI.

error PSPDFKit.DocumentValidationStatus

At least one signature of the document is invalid, that is, it should be shown with a red cross of similar in the UI.

not_signed PSPDFKit.DocumentValidationStatus

The document does not contain digital signatures.

(static, constant) ElectronicSignatureCreationMode

Represents one of the available signing methods for adding new electronic signatures using the UI.

Properties:
Name Type Description
DRAW PSPDFKit.ElectronicSignatureCreationMode

UI in which users draw a signature.

IMAGE PSPDFKit.ElectronicSignatureCreationMode

UI in which users pick or drag an image to use that as the signature.

TYPE PSPDFKit.ElectronicSignatureCreationMode

UI in which users can type a text and generate an image signature from it.

(static) HistoryChangeEvent: PSPDFKit.HistoryChangeEvent

HistoryChangeEvent

Type:
Properties:
Name Type Attributes Description
action string <nullable>

Type of history change.

before AnnotationsUnion <nullable>

Annotation state before the action.

after AnnotationsUnion <nullable>

Annotation state after the action.

(static) HistoryWillChangeEvent: PSPDFKit.HistoryWillChangeEvent

HistoryWillChangeEvent

Type:
Properties:
Name Type Description
type string

Type of action (create, update or delete).

annotation PSPDFKit.Annotations.Annotation

Annotation state being added to the history.

preventDefault function

Callback to prevent the change from being tracked.

(static, constant) InteractionMode

Controls the current interaction mode in the viewer.

Properties:
Name Type Description
TEXT_HIGHLIGHTER PSPDFKit.InteractionMode

When this mode is activated, the creation of new highlight annotations will be enabled and the text will be highlighted as it's selected.

INK PSPDFKit.InteractionMode

When this mode is activated, the creation of new ink annotations will be enabled. This transforms the page to a drawable canvas and an annotation is created while drawing on it. If properties (e.g. color) or the page index changes, a new annotation is created.

INK_SIGNATURE PSPDFKit.InteractionMode

Deprecated: When this mode is activated, the creation of new ink signatures will be enabled. This this shows a dialog where it is possible to select an existing ink signature or create a new one and store it.

This interaction mode is deprecated and it will act just like SIGNATURE.

SIGNATURE PSPDFKit.InteractionMode

When this mode is activated, the creation of new signatures will be enabled. This shows a dialog where it is possible to select an existing signature or create a new one and potentially save it.

STAMP_PICKER PSPDFKit.InteractionMode

When this mode is activated, the stamp annotation templates picker modal UI will be shown. Once a template is selected, the new annotation is configured and created
in the document.

STAMP_CUSTOM PSPDFKit.InteractionMode

When this mode is activated, the custom stamp annotation template editor modal UI will be shown. Once a the custom template is edited, the new custom stamp annotation will be created in the document.

SHAPE_LINE PSPDFKit.InteractionMode

When this mode is activated, the creation of new line annotations will be enabled. This transforms the page to a drawable canvas and an annotation is created while drawing on it.

SHAPE_RECTANGLE PSPDFKit.InteractionMode

When this mode is activated, the creation of new rectangle annotations will be enabled. This transforms the page to a drawable canvas and an annotation is created while drawing on it.

SHAPE_ELLIPSE PSPDFKit.InteractionMode

When this mode is activated, the creation of new ellipse annotations will be enabled. This transforms the page to a drawable canvas and an annotation is created while drawing on it. If properties (e.g. color) or the page index changes, a new annotation is created.

SHAPE_POLYGON PSPDFKit.InteractionMode

When this mode is activated, the creation of new polygon annotations will be enabled. This transforms the page to a drawable canvas and an annotation is created while drawing on it. If properties (e.g. color) or the page index changes, a new annotation is created.

SHAPE_POLYLINE PSPDFKit.InteractionMode

When this mode is activated, the creation of new polyline annotations will be enabled. This transforms the page to a drawable canvas and an annotation is created while drawing on it. If properties (e.g. color) or the page index changes, a new annotation is created.

INK_ERASER PSPDFKit.InteractionMode

When this mode is activated, removing of current ink annotation points will be enabled. This transforms the page to a canvas where the cursor can remove ink annotation points by hand, as well as choose the cursor width.

NOTE PSPDFKit.InteractionMode

When this mode is activated, the creation of new note annotations will be enabled. This transforms the page to a clickable area where the annotation will be created at the position of the click.

COMMENT_MARKER PSPDFKit.InteractionMode

When this mode is activated, the creation of new comment marker annotations will be enabled. This transforms the page to a clickable area where the annotation will be created at the position of the click.

TEXT PSPDFKit.InteractionMode

When this mode is activated, the creation of new text annotations will be enabled. This transforms the page to a clickable area where the annotation will be created at the position of the click.

CALLOUT PSPDFKit.InteractionMode

When this mode is activated, the creation of new callout annotations will be enabled. This transforms the page to a clickable area where the annotation will be created at the position of the click.

PAN PSPDFKit.InteractionMode

This enables the pan tool to allow the user to navigate on a desktop browser using mouse dragging. This will disable text selection.

On a touch device, this will have no effect since panning is already the default technique for scrolling on websites.

SEARCH PSPDFKit.InteractionMode

Enables the search mode and focuses the search input field.

DOCUMENT_EDITOR PSPDFKit.InteractionMode

This shows the document editor modal.

MARQUEE_ZOOM PSPDFKit.InteractionMode

This enables the Marquee Zoom tool. When enabled, you can draw a rectangle on the screen which is zoomed into and scrolled to, once the pointer is released.

REDACT_TEXT_HIGHLIGHTER PSPDFKit.InteractionMode

When this mode is activated, the creation of new redaction annotations will be enabled by highlighting regions of text and the text will be marked for redaction as it's selected.

REDACT_SHAPE_RECTANGLE PSPDFKit.InteractionMode

When this mode is activated, the creation of new redaction annotations will be enabled by drawing rectangles on the pages. This transforms the page to a drawable canvas and annotations are created while drawing on it.

DOCUMENT_CROP PSPDFKit.InteractionMode

When this mode is activated, the creation of cropping area selection is enabled.

BUTTON_WIDGET PSPDFKit.InteractionMode

When this mode is activated, the creation of button widget annotations is enabled.

TEXT_WIDGET PSPDFKit.InteractionMode

When this mode is activated, the creation of text widget annotations is enabled.

RADIO_BUTTON_WIDGET PSPDFKit.InteractionMode

When this mode is activated, the creation of radio button widget annotations is enabled.

CHECKBOX_WIDGET PSPDFKit.InteractionMode

When this mode is activated, the creation of checkbox widget annotations is enabled.

COMBO_BOX_WIDGET PSPDFKit.InteractionMode

When this mode is activated, the creation of combo box widget annotations is enabled.

LIST_BOX_WIDGET PSPDFKit.InteractionMode

When this mode is activated, the creation of list box widget annotations is enabled.

SIGNATURE_WIDGET PSPDFKit.InteractionMode

When this mode is activated, the creation of signature widget annotations is enabled.

DATE_WIDGET PSPDFKit.InteractionMode

When this mode is activated, the creation of date widget annotations is enabled.

FORM_CREATOR PSPDFKit.InteractionMode

When this mode is activated, you will be able to edit and create widget annotations.

LINK PSPDFKit.InteractionMode

When this mode is activated, you will be able to create link annotations.

DISTANCE PSPDFKit.InteractionMode

When this mode is activated, you will be able to create distance annotations. This transforms the page to a drawable canvas and an annotation is created while drawing on it.

PERIMETER PSPDFKit.InteractionMode

When this mode is activated, you will be able to create perimeter annotations. This transforms the page to a drawable canvas and an annotation is created while drawing on it.

RECTANGLE_AREA PSPDFKit.InteractionMode

When this mode is activated, you will be able to create Rectangle Area annotations. This transforms the page to a drawable canvas and an annotation is created while drawing on it.

ELLIPSE_AREA PSPDFKit.InteractionMode

When this mode is activated, you will be able to create Ellipse Area annotations. This transforms the page to a drawable canvas and an annotation is created while drawing on it.

POLYGON_AREA PSPDFKit.InteractionMode

When this mode is activated, you will be able to create Polygon Area annotations. This transforms the page to a drawable canvas and an annotation is created while drawing on it.

CONTENT_EDITOR PSPDFKit.InteractionMode

Available only in Standalone mode with the content editor license: when this mode is activated, you will be able to edit the page contents.

MULTI_ANNOTATIONS_SELECTION PSPDFKit.InteractionMode

When this mode is activated, multiple annotations can be selected with the UI.

MEASUREMENT PSPDFKit.InteractionMode

Available only with the measurement license: when this mode is activated, the measurement annotations mode will be activated.

MEASUREMENT_SETTINGS PSPDFKit.InteractionMode

Available only with the measurement license: when this mode is activated, the measurement settings mode will be activated.

(static, constant) LayoutMode

Describes how the pages will be laid out in the document view.

Properties:
Name Type Description
SINGLE PSPDFKit.LayoutMode

Pages will always be displayed in the single page mode.

This is the default mode.

DOUBLE PSPDFKit.LayoutMode

Pages will always be displayed in groups of two.

AUTO PSPDFKit.LayoutMode

Automatically sets the layout mode to PSPDFKit.LayoutMode.SINGLE or PSPDFKit.LayoutMode.DOUBLE depending on the available space.

Specifically PSPDFKit.LayoutMode.DOUBLE is chosen when the PSPDFKit container is in landscape mode and its size is greater than 992px.

This mode is a perfect fit for tablets in particular since it will automatically update the layout mode then device orientation changes.

When the dimensions of the viewport change (i.e. the browser window is resized), the view will be restored to make the current page visible.

(static, constant) LineCap

Represents one of the available line caps for the line and polyline annotations.

Properties:
Name Type Description
square PSPDFKit.LineCap

square line cap

circle PSPDFKit.LineCap

circle line cap

diamond PSPDFKit.LineCap

diamond line cap

openArrow PSPDFKit.LineCap

open arrow line cap

closedArrow PSPDFKit.LineCap

closed arrow line cap

butt PSPDFKit.LineCap

butt line cap

reverseOpenArrow PSPDFKit.LineCap

reverse open arrow line cap

reverseClosedArrow PSPDFKit.LineCap

reverse closed arrow line cap

slash PSPDFKit.LineCap

slash line cap

(static, constant) MeasurementPrecision

Precision values for length of measurement annotations.

Properties:
Name Type Description
WHOLE PSPDFKit.MeasurementPrecision
ONE PSPDFKit.MeasurementPrecision
TWO PSPDFKit.MeasurementPrecision
THREE PSPDFKit.MeasurementPrecision
FOUR PSPDFKit.MeasurementPrecision
HALVES PSPDFKit.MeasurementPrecision
QUARTERS PSPDFKit.MeasurementPrecision
EIGHTHS PSPDFKit.MeasurementPrecision
SIXTEENTHS PSPDFKit.MeasurementPrecision

(static, constant) MeasurementScaleUnitFrom

Represents one of the units from which you can scale from for measurement annotations.

Properties:
Name Type Description
INCHES PSPDFKit.MeasurementScaleUnitFrom
MILLIMETERS PSPDFKit.MeasurementScaleUnitFrom
CENTIMETERS PSPDFKit.MeasurementScaleUnitFrom
POINTS PSPDFKit.MeasurementScaleUnitFrom

(static, constant) MeasurementScaleUnitTo

Represents one of the units to which you can scale from for measurement annotations.

Properties:
Name Type Description
INCHES PSPDFKit.MeasurementScaleUnitTo
MILLIMETERS PSPDFKit.MeasurementScaleUnitTo
CENTIMETERS PSPDFKit.MeasurementScaleUnitTo
POINTS PSPDFKit.MeasurementScaleUnitTo
FEET PSPDFKit.MeasurementScaleUnitTo
METERS PSPDFKit.MeasurementScaleUnitTo
YARDS PSPDFKit.MeasurementScaleUnitTo
KILOMETERS PSPDFKit.MeasurementScaleUnitTo
MILES PSPDFKit.MeasurementScaleUnitTo

(static, constant) NoteIcon

Available icons for Note Annotations.

Properties:
Name Type Description
COMMENT PSPDFKit.NoteIcon
RIGHT_POINTER PSPDFKit.NoteIcon
RIGHT_ARROW PSPDFKit.NoteIcon
CHECK PSPDFKit.NoteIcon
CIRCLE PSPDFKit.NoteIcon
CROSS PSPDFKit.NoteIcon
INSERT PSPDFKit.NoteIcon
NEW_PARAGRAPH PSPDFKit.NoteIcon
NOTE PSPDFKit.NoteIcon
PARAGRAPH PSPDFKit.NoteIcon
HELP PSPDFKit.NoteIcon
STAR PSPDFKit.NoteIcon
KEY PSPDFKit.NoteIcon

(static, constant) OfficeDocumentFormat

Document conversion output formats.

Properties:
Name Type Description
docx PSPDFKit.OfficeDocumentFormat

DOCX document format.

xlsx PSPDFKit.OfficeDocumentFormat

XLSX document format.

pptx PSPDFKit.OfficeDocumentFormat

PPTX document format.

(static, constant) PAdESLevel

The different PAdES levels.

Properties:
Name Type Description
b_b PSPDFKit.PAdESLevel

B-B

b_t PSPDFKit.PAdESLevel

B-T

b_lt PSPDFKit.PAdESLevel

B-LT

(static, constant) PrintMode

Describes mode used to print a PDF document.

Properties:
Name Type Description
DOM PSPDFKit.PrintMode

This method will render all pages of the PDF document in advance before it sends the results to the printer. This works in all major browsers and will not give your users access to the source PDF file. However, this method is CPU-bound and memory usage scales with PDF size.

Because of its reliability and cross browsers support this method is the default.

Some caveats when using this method:

  • To achieve cross-browser support, we render the resulting images into the main window. We try to hide already existing HTML by applying display: none !important. If the printed page still contains other HTML elements, make sure to apply an appropriate print stylesheet to your web app.
  • This method will produce incorrect results, when pages of the document have different sizes. Unfortunately, there's no way to work around this issue since it's a CSS limitation.
EXPORT_PDF PSPDFKit.PrintMode

This method is built to be resource efficient and to avoid having to render all pages in advance, which might balloon memory usage to multi-GB on PDFs with 100+ pages.

It supports all common browsers, however some fall back to opening the PDF file in a new tab, which might give your users unwanted access to the source files.

Google Chrome and Microsoft Internet Explorer provide the APIs required to use the native renderer, as a fallback on other browser we generate and open a PDF in a new tab. This allows users to print the PDF in a native PDF reader which can, as opposed to browser-built implementations, talk directly to the connected printer.

When using this print mode, we can not call the PSPDFKit.RenderPageCallback when printing pages.

Note: If the PDF is password-protected, we always fall back to opening the PDF in a new tab.

(static, constant) PrintQuality

Describes Quality used to print a PDF document.

Properties:
Name Type Description
LOW PSPDFKit.PrintQuality

Low will print the PDF in original quality.

MEDIUM PSPDFKit.PrintQuality

Medium quality printing (150 dpi).

HIGH PSPDFKit.PrintQuality

High quality printing (300 dpi).

Note: With increase in the PDF print Quality speed of printing will decrease.

(static, constant) ProcessorEngine

optional, Standalone only

Document processing can be a time-consuming task, especially when working with large documents. In order to improve the user experience it is possible to choose between two different processor engines with different optimizations applied: either one with a smaller bundle size (the default), but slower overall performance, or one with a larger bundle size, but faster processing time.

Either case it's recommended to enable asset compression on your Server to improve loading time.

Processor Engine Comparison:

Preference Bundle Size Document Processing Recommended Use
smallerSize Smaller Slower Prioritize compact app size
fasterProcessing Larger Faster Quick document processing
Properties:
Name Type Description
smallerSize PSPDFKit.ProcessorEngine

A smaller processor engine will be used for processing (default).

fasterProcessing PSPDFKit.ProcessorEngine

A faster processor engine will be used for processing.

(static, constant) ProductId

Properties:
Name Type Description
SharePoint PSPDFKit.ProductId

Enables using the SDK in a SharePoint environment. When used, the document should be loaded from a SharePoint site.

Salesforce PSPDFKit.ProductId

Enables using the SDK in a Salesforce environment. When used, the SDK should be loaded from a Salesforce site.

(static, constant) ScrollMode

Describes mode of page scrolling in the document view - either continuous, per spread (paginated) or disabled (changing pages through the UI is disabled).

Properties:
Name Type Description
CONTINUOUS PSPDFKit.ScrollMode

Render all pages as a list and allow smooth scrolling.

This is the default mode.

PER_SPREAD PSPDFKit.ScrollMode

Makes scrolling only possible within a spread. Whenever this mode is activated, or pages are changed when this mode is active, the zoom mode will be reset to PSPDFKit.ZoomMode.FIT_TO_VIEWPORT.

DISABLED PSPDFKit.ScrollMode

Makes scrolling only possible within a spread and doesn't allow changing pages. Whenever this mode is activated the zoom mode will be reset to PSPDFKit.ZoomMode.FIT_TO_VIEWPORT.

(static, constant) SearchPattern

Allows you to perform a search by a built-in pattern that matches common strings.

Note that by design, some of these patterns might overfit the criteria (i.e. include false positive results). This might happen since we strive for including all positive results and avoid data loss. Make sure to review the matches found.

Properties:
Name Type Description
CREDIT_CARD_NUMBER PSPDFKit.SearchPattern

Catches credit card numbers with a number beginning with 1-6, and must be 13 to 19 digits long. Spaces and - are allowed anywhere in the number.

DATE PSPDFKit.SearchPattern

Matches date formats such as mm/dd/yyyy, mm/dd/yy, dd/mm/yyyy, and dd/mm/yy. It will reject any days/months greater than 31 and will match if a leading zero is or is not used for a single digit day or month. The delimiter can either be -, . or /.

TIME PSPDFKit.SearchPattern

Matches time formats such as 00:00:00, 00:00, 00:00 PM. 12 and 24 hour formats are allowed. Seconds and 12 hour AM/PM denotation are both optional.

EMAIL_ADDRESS PSPDFKit.SearchPattern

Matches an email address with the format of [email protected] where xyz can be any alpha numeric character or a . For more information on the pattern please see http://emailregex.com/.

INTERNATIONAL_PHONE_NUMBER PSPDFKit.SearchPattern

Matches International style phone numbers with a prefix of + or 00, containing between 7 - 15 digits with spaces or - occurring anywhere within the number.

IP_V4 PSPDFKit.SearchPattern

Matches an IPV4 address limited to number ranges of 0-255 with an optional mask.

IP_V6 PSPDFKit.SearchPattern

Matches full and compressed IPv6 addresses as defined in RFC 2373.

MAC_ADDRESS PSPDFKit.SearchPattern

Matches a MAC address with delimiters of either - or :

NORTH_AMERICAN_PHONE_NUMBER PSPDFKit.SearchPattern

Matches a NANP (https://en.wikipedia.org/wiki/North_American_Numbering_Plan) style phone number. In general this will match US, Canadian and various other Caribbean countries. The pattern will also match an optional international prefix of +1.

SOCIAL_SECURITY_NUMBER PSPDFKit.SearchPattern

Matches a US social security number (SSN). The format of the number should be either XXX-XX-XXXX or XXXXXXXXX with X denoting [0-9]. We expect the number to have word boundaries on either side, or to be the start/end of the string.

URL PSPDFKit.SearchPattern

Matches a URL with a prefix of http|https|www with an optional subdomain.

US_ZIP_CODE PSPDFKit.SearchPattern

Matches a USA style Zip Code. The format expected is 00000 or 00000-0000, where the delimiter can either be - or /.

VIN PSPDFKit.SearchPattern

Matches US and ISO 3779 standard VINs. The format expects 17 characters with the last 5 characters being numeric. I,O,Q,_ characters are not allowed in upper or lower case.

(static, constant) SearchType

Defines the search type used for text search operations or when creating redaction annotations based on text search.

Properties:
Name Type Description
TEXT PSPDFKit.SearchType

This is the default search type. This is used when you want to search for strings/text.

PRESET PSPDFKit.SearchType

The search type when you want to use the patterns provided by us. see PSPDFKit.SearchPattern for the list of all the patterns.

REGEX PSPDFKit.SearchType

The search type when you want to search using regex. Regex syntax:

(static, constant) ShowSignatureValidationStatusMode

Controls when the digital signature validation UI should be shown.

Properties:
Name Type Description
IF_SIGNED PSPDFKit.ShowSignatureValidationStatusMode

Show the digital signature validation UI if digital signatures are found on the current document.

HAS_WARNINGS PSPDFKit.ShowSignatureValidationStatusMode

Only show the digital signature validation UI if digital signatures with problems or invalid ones are found, and also if the document has been modified since the moment it's been signed.

HAS_ERRORS PSPDFKit.ShowSignatureValidationStatusMode

Only show the digital signature validation UI if invalid signatures are found.

NEVER PSPDFKit.ShowSignatureValidationStatusMode

Never show the digital signature validation UI.

(static, constant) SidebarMode

Controls the current sidebar mode in the viewer.

Properties:
Name Type Description
ANNOTATIONS PSPDFKit.SidebarMode

Annotations sidebar.

BOOKMARKS PSPDFKit.SidebarMode

Bookmarks.

DOCUMENT_OUTLINE PSPDFKit.SidebarMode

Document Outline (table of contents).

THUMBNAILS PSPDFKit.SidebarMode

Thumbnails preview.

SIGNATURES PSPDFKit.SidebarMode

List of Signatures.

LAYERS PSPDFKit.SidebarMode

List of OCG layers in the document.

CUSTOM PSPDFKit.SidebarMode

Custom preview.

(static, constant) SidebarPlacement

Controls the sidebar placement.

Properties:
Name Type Description
START PSPDFKit.SidebarPlacement

The sidebar is shown before the content in the reading direction. For any LTR languages this will be the left side, for RTL languages this will be the right side.

END PSPDFKit.SidebarPlacement

The sidebar is shown after the content in the reading direction. For any LTR languages this will be the right side, for RTL languages this will be the left side.

(static, constant) SignatureAppearanceMode

Specifies the signature appearance mode: whether graphics, description, or both are included in it. See https://pspdfkit.com/guides/web/signatures/digital-signatures/signature-lifecycle/configure-digital-signature-appearance/ for a detailed discussion of the signature modes.

Properties:
Name Type Description
signatureOnly PSPDFKit.SignatureAppearanceMode

Only the graphic is included in the signature appearance.

signatureAndDescription PSPDFKit.SignatureAppearanceMode

Both the graphic and description are included in the signature appearance.

descriptionOnly PSPDFKit.SignatureAppearanceMode

Only the description is included in the signature appearance.

(static, constant) SignatureContainerType

Type of the signature container used for document signatures transfer between the client and the signing service.

Properties:
Name Type Description
raw PSPDFKit.SignatureContainerType

raw

pkcs7 PSPDFKit.SignatureContainerType

pkcs7

(static, constant) SignatureSaveMode

Selects the save mode for ink signatures.

Properties:
Name Type Description
ALWAYS PSPDFKit.SignatureSaveMode

Always store new ink signatures.

NEVER PSPDFKit.SignatureSaveMode

Never store new ink signatures.

USING_UI PSPDFKit.SignatureSaveMode

Store new ink signatures if the option is selected in the UI.

(static, constant) SignatureType

The different types of digital signatures.

Properties:
Name Type Description
CMS PSPDFKit.SignatureType

CMS

CAdES PSPDFKit.SignatureType

CAdES

(static, constant) SignatureValidationStatus

The different possible validation states of the signature.

Properties:
Name Type Description
valid PSPDFKit.SignatureValidationStatus

The overall status of the signature is valid, that is, it should be shown with a green checkmark or similar in the UI.

warning PSPDFKit.SignatureValidationStatus

The overall status of the signature is valid with concerns, that is, it should be shown with a yellow warning or similar in the UI.

error PSPDFKit.SignatureValidationStatus

The overall status of the signature is that it is invalid, that is, it should be shown with a red cross of similar in the UI.

(static) SigningData: object

This object can be provided optionally as part of the PSPDFKit.SignaturePreparationData passed as first argument when calling instance.signDocument() and contains the certificates, private key and signature type for the SDK to use for signing the document using the Web Crypto API.

certificates must be an Array of ArrayBuffer (DER-encoded) or string (PEM-encoded) containing X.509 certificates.

The SDK can sign the document using the Web SubtleCrypto API as long as the certificate chain and private key are provided here.

privatekey must be a string that contains the private key to sign (PEM-encoded). If privateKey is not included, PSPDFKit.TwoStepSignatureCallback needs to be passed as second argument for the instance.signDocument() call to perform the signing.

If certificates is not provided, only PSPDFKit.SignatureType.CMS can be created.

If signatureType is not provided, PSPDFKit.SignatureType.CAdES will be used by default as long as certificates is provided, and will default to PSPDFKit.SignatureType.CMS otherwise.

If timestamp is provided, the signatureType must be PSPDFKit.SignatureType.CAdES.

Type:
  • object
Properties:
Name Type Attributes Description
certificates Array.<ArrayBuffer> | Array.<string> <nullable>

Certificates used to sign the document.

signatureType PSPDFKit.SignatureType <nullable>

Signature type.

privateKey string <nullable>

Private key used to sign the document.

signatureContainer PSPDFKit.SignatureContainerType <nullable>

Signature container type. Can be PSPDFKit.SignatureContainerType.raw or PSPDFKit.SignatureContainerType.pkcs7.

padesLevel PSPDFKit.PAdESLevel <nullable>

PAdES level to use when creating the signature (Document Engine only). This parameter is ignored when the signatureType is cms. Defaults to b-lt.

timestamp object <nullable>

Timestamping authority information (Standalone only).

Properties
Name Type Attributes Description
url string

URL of the timestamp server.

username string <nullable>

Username for the timestamp server.

password string <nullable>

Password for the timestamp server.

ltv boolean <nullable>

Flag to enable LTV (Long Term Validation) for the signature (Standalone only).

(static, constant) Theme

Describes theme to use.

Note: Themes are not supported in IE and setting this option won't have any effect: IE users will get the default light theme. You can customize the appearance of the UI using our public CSS classes. Please refer to this guide article for information on how to customize the appearance.

Properties:
Name Type Description
LIGHT PSPDFKit.Theme

Light mode. This is the default theme.

DARK PSPDFKit.Theme

Dark mode.

AUTO PSPDFKit.Theme

Uses PSPDFKit.Theme.LIGHT or PSPDFKit.Theme.DARK based on the user preferences and the prefers-color-scheme media query. Note this is not available in every browser.

(static, constant) ToolbarPlacement

Configure where the toolbar is placed.

Properties:
Name Type Description
TOP PSPDFKit.ToolbarPlacement

The default value. The toolbar will be placed at the top of the viewport.

BOTTOM PSPDFKit.ToolbarPlacement

The toolbar will be placed at the bottom of the viewport.

(static, constant) UIDateTimeElement

Indicates which UI element certain JavaScript Date instance will be rendered in. Used as part of PSPDFKit.Configuration#dateTimeString.

Properties:
Name Type Description
COMMENT_THREAD PSPDFKit.UIDateTimeElement

Comment thread.

ANNOTATIONS_SIDEBAR PSPDFKit.UIDateTimeElement

Annotations sidebar.

(static, constant) UIElement

Customizable user interface element.

Properties:
Name Type Description
Sidebar PSPDFKit.UIElement

Sidebar element

(static, constant) ZoomMode

A specific zoom mode that will always be applied whenever the viewport is resized.

Properties:
Name Type Description
AUTO PSPDFKit.ZoomMode

Generates a zoomLevel that will automatically align the page for the best viewing experience.

FIT_TO_WIDTH PSPDFKit.ZoomMode

Uses a zoomLevel that will fit the width of the broadest page into the viewport. The height might overflow.

FIT_TO_VIEWPORT PSPDFKit.ZoomMode

Uses a zoomLevel that will fit the current page into the viewport completely.

(static, readonly) defaultAnnotationPresets: Object.<PSPDFKit.AnnotationPreset>

Returns a deep copy of an object containing the default annotation presets.

The default annotation presets for annotations include the default values for the annotation models, and can be retrieved before loading the instance.

The default annotation presets for annotation variants also include the modified properties corresponding to each annotation variant.

Used by toolbar buttons like line or arrow.

  1. arrow
  2. highlighter
  3. line
  4. rectangle
  5. cloudy-rectangle
  6. dashed-rectangle
  7. ellipse
  8. cloudy-ellipse
  9. dashed-ellipse
  10. polygon
  11. cloudy-polygon
  12. dashed-polygon
  13. polyline
  14. text-highlighter
  15. ink
  16. ink-signature
  17. note
  18. text
  19. stamp
  20. image
  21. widget
  22. strikeout
  23. underline
  24. squiggle
  25. highlight
  26. redaction
  27. es-signature
  28. perimeter
  29. distance
  30. ellipse-area
  31. rectangle-area
  32. polygon-area

For the ink preset you can also set the width of the ink eraser tool via the inkEraserWidth property.

Type:

(static, readonly) defaultAnnotationsSidebarContent: Array.<function(new:PSPDFKit.Annotations.Annotation)>

Type:

(static, readonly) defaultDocumentEditorFooterItems: Array.<PSPDFKit.DocumentEditorFooterItem>

Returns a deep copy of an array containing the default document editor footer items ordered by PSPDFKit.DocumentEditorFooterItem#type in the following way:

  1. cancel
  2. selected-pages
  3. spacer
  4. loading-indicator
  5. save-as
  6. save

The loading-indicator is only visible when the changes are being committed and selected-pages is only visible when you have selected multiple pages.

Type:

(static, readonly) defaultDocumentEditorToolbarItems: Array.<PSPDFKit.DocumentEditorToolbarItem>

Returns a deep copy of an array containing the default document editor toolbar items ordered by PSPDFKit.DocumentEditorToolbarItem#type in the following way:

  1. add
  2. remove
  3. duplicate
  4. rotate-left
  5. rotate-right
  6. move
  7. move-left
  8. move-right
  9. import-document
  10. extract-pages
  11. spacer
  12. undo
  13. redo
  14. select-all
  15. select-none
  16. zoom-out
  17. zoom-in
Type:

(static, readonly) defaultEditableAnnotationTypes: Array.<PSPDFKit.Annotations.Annotation>

Returns a deep copy of an array containing the default editable annotation types.

Type:

(static, readonly) defaultElectronicSignatureColorPresets: Array.<PSPDFKit.ColorPreset>

Returns a deep copy of an array containing the default color presets offered as part of the electronic signatures modal.

  1. blue
  2. pspdfkit blue
  3. black
Type:
  • Array.<PSPDFKit.ColorPreset>

(static, readonly) defaultElectronicSignatureCreationModes: Array.<PSPDFKit.ElectronicSignatureCreationMode>

Returns a deep copy of an array containing the default creationModes offered as part of the electronic signatures modal.

  1. DRAW
  2. IMAGE
  3. TYPE
Type:

(static, readonly) defaultSigningFonts: Array.<PSPDFKit.Font>

Returns a deep copy of an array containing the default fonts that are available for electronic signatures.

  1. PSPDFKit.Font({ name: 'Caveat' })
  2. PSPDFKit.Font({ name: 'Pacifico' })
  3. PSPDFKit.Font({ name: 'Marck Script' })
  4. PSPDFKit.Font({ name: 'Meddon' })
Type:

(static, readonly) defaultStampAnnotationTemplates: Array.<(PSPDFKit.Annotations.StampAnnotation|PSPDFKit.Annotations.ImageAnnotation)>

Returns a deep copy of an array containing the default stamp and image annotation templates, which are stamp annotation instances. However, image annotation templates can also be added to this Array using PSPDFKit.setStampAnnotationTemplates. Used by the stamp picker UI. Initially it contains only the following stamp annotations:

  1. Approved
  2. NotApproved
  3. Draft
  4. Final
  5. Completed
  6. Confidential
  7. ForPublicRelease
  8. NotForPublicRelease
  9. ForComment
  10. Void
  11. PreliminaryResults
  12. InformationOnly
  13. Rejected
  14. Accepted
  15. InitialHere
  16. SignHere
  17. Witness
  18. AsIs
  19. Departmental
  20. Experimental
  21. Expired
  22. Sold
  23. TopSecret
  24. Revised
  25. RejectedWithText
Type:

(static, readonly) defaultTextComparisonInnerToolbarItems: Array.<PSPDFKit.TextComparisonInnerToolbarItem>

Returns a deep copy of an array containing the default text comparison instance toolbar items ordered by PSPDFKit.TextComparisonInnerToolbarItem#type in the following way:

  1. pager
  2. pan
  3. zoom-out
  4. zoom-in
  5. spacer

Please keep in mind that under some circumstances some items may be removed from the final list.

Type:

(static, readonly) defaultTextComparisonToolbarItems: Array.<PSPDFKit.TextComparisonToolbarItem>

Returns a deep copy of an array containing the default text comparison toolbar items ordered by PSPDFKit.TextComparisonToolbarItem#type in the following way:

  1. comparison-changes
  2. prev-change
  3. next-change
  4. scroll-lock

Please keep in mind that under some circumstances some items may be removed from the final list.

Type:

(static, readonly) defaultToolbarItems: Array.<PSPDFKit.ToolbarItem>

Returns a deep copy of an array containing the default toolbar items ordered by PSPDFKit.ToolbarItem#type in the following way:

  1. sidebar-thumbnails
  2. sidebar-document-outline
  3. sidebar-annotations
  4. sidebar-bookmarks
  5. sidebar-signatures
  6. sidebar-layers
  7. pager
  8. pan
  9. zoom-out
  10. zoom-in
  11. zoom-mode
  12. spacer
  13. annotate
  14. ink
  15. highlighter
  16. text-highlighter
  17. ink-eraser
  18. signature
  19. image
  20. stamp
  21. note
  22. text
  23. line
  24. arrow
  25. rectangle
  26. cloudy-rectangle
  27. dashed-rectangle
  28. ellipse
  29. cloudy-ellipse
  30. dashed-ellipse
  31. polygon
  32. cloudy-polygon
  33. dashed-polygon
  34. polyline
  35. print
  36. document-editor
  37. document-crop
  38. search
  39. export-pdf
  40. debug
  41. content-editor
  42. link
  43. multi-annotations-selection
  44. callout

Please keep in mind that under some circumstances some items may be removed from the final list.

Items hidden for touch devices:

  • pan

Items hidden for touch devices when the media query (max-width: 992px) for medium devices matches:

  • zoom-out
  • zoom-in
  • zoom-mode

Please keep in mind that the media query is only added for touch devices. You can change this behavior by defining your own mediaQueries and replacing the original item. To learn more about how to do so please refer to our guide.

Items hidden for small screens (max-width: 992px)

  • text
  • callout
  • ink
  • highlighter
  • text-highlighter
  • ink-eraser
  • line
  • arrow
  • rectangle
  • cloudy-rectangle
  • dashed-rectangle
  • ellipse
  • cloudy-ellipse
  • dashed-ellipse
  • polygon
  • cloudy-polygon
  • dashed-polygon
  • polyline
  • signature
  • image
  • stamp
  • note
  • undo
  • redo
  • link

Items shown on small screens (max-width: 992px)

  • annotate

Items hidden when in read-only mode:

  • text
  • ink
  • highlighter
  • text-highlighter
  • ink-eraser
  • line
  • arrow
  • rectangle
  • cloudy-rectangle
  • dashed-rectangle
  • ellipse
  • cloudy-ellipse
  • dashed-ellipse
  • polygon
  • cloudy-polygon
  • dashed-polygon
  • polyline
  • signature
  • image
  • stamp
  • note
  • undo
  • redo
  • link
  • multi-annotations-selection

Hidden when not in debug mode (See this guide article):

  • debug

Hidden by default and only available when explicitly set via the API:

  • layout-config
  • marquee-zoom
  • comment
  • redact-text-highlighter
  • redact-rectangle
  • cloudy-rectangle
  • dashed-rectangle
  • cloudy-ellipse
  • dashed-ellipse
  • dashed-polygon
  • undo
  • redo
  • document-comparison
  • form-creator
  • content-editor
  • measure
Type:

(static, readonly) version

Returns the framework version (e.g. "2019.4.0").


Methods

(static) convertToOffice(configuration, format) → {Promise.<ArrayBuffer>}

Converts a document to the specified supported conversion format.

Returns a Promise resolving to an ArrayBuffer of the converted document, or rejecting with a PSPDFKit.Error.

It requires a configuration object. If the configuration is invalid, the promise will be rejected with a PSPDFKit.Error.

Parameters:
Name Type Description
configuration PSPDFKit.Configuration

A configuration Object.

format PSPDFKit.OfficeDocumentFormat

Format to export the document to.

Returns:

Promise that resolves to an ArrayBuffer of the converted file

Type
Promise.<ArrayBuffer>
Example
PSPDFKit.convertToOffice({
  document: "/article.pdf",
  licenseKey: "YOUR_LICENSE_KEY",
},
PSPDFKit.OfficeDocumentFormat.docx
).then((arrayBuffer) => {
  console.log("Successfully converted document", arrayBuffer);
}).catch((error) => {
  console.error(error.message);
})

(static) convertToPDF(configuration, conformance) → {Promise.<ArrayBuffer>}

Converts a file to a PDF.

Returns a Promise resolving to an ArrayBuffer of a PDF, or rejecting with a PSPDFKit.Error.

The resulting ArrayBuffer can be directly loaded with PSPDFKit.load().

It requires a configuration object. If the configuration is invalid, the promise will be rejected with a PSPDFKit.Error.

Parameters:
Name Type Description
configuration PSPDFKit.Configuration

A configuration Object

conformance PSPDFKit.Conformance

A conformance level of the output PDF

Returns:

Promise that resolves to an ArrayBuffer of a file converted to PDF

Type
Promise.<ArrayBuffer>
Example
PSPDFKit.convertToPDF({
  document: "/sales-report.docx",
  licenseKey: "YOUR_LICENSE_KEY",
}).then((arrayBuffer) => {
  console.log("Successfully converted document", arrayBuffer);
}).catch((error) => {
  console.error(error.message);
})

(static) generateInstantId() → {string}

Generates a new unique ID usable as an ID of annotation, formField, bookmark or comment.

Returns:

A unique identifier.

Type
string

(static) isSignatureCallbackResponseRaw(obj) → {boolean}

Checks if an object is a SignatureCallbackResponseRaw.

Parameters:
Name Type Description
obj any

The object to check.

Returns:

True if the object is a SignatureCallbackResponseRaw, false otherwise.

Type
boolean

(static) load(configuration) → {Promise.<PSPDFKit.Instance, PSPDFKit.Error>}

Creates a new PSPDFKit instance.

Returns a Promise resolving to a new PSPDFKit.Instance, or rejecting with a PSPDFKit.Error.

It requires a configuration object. When the configuration is invalid, the promise will be rejected with a PSPDFKit.Error.

Parameters:
Name Type Description
configuration PSPDFKit.Configuration

A configuration Object

Returns:

Promise that resolves in an PSPDFKit.Instance

Type
Promise.<PSPDFKit.Instance, PSPDFKit.Error>
Examples

Load PSPDFKit for Web Server

PSPDFKit.load({
  authPayload: { jwt: "xxx.xxx.xxx" },
  container: ".foo",
  documentId: "85203",
  instant: true,
}).then((instance) => {
  console.log("Successfully mounted PSPDFKit", instance);
}).catch((error) => {
  console.error(error.message);
})

Load PSPDFKit for Web Standalone

PSPDFKit.load({
  document: "/sales-report.pdf",
  container: ".foo",
  licenseKey: "YOUR_LICENSE_KEY",
}).then((instance) => {
  console.log("Successfully mounted PSPDFKit", instance);
}).catch((error) => {
  console.error(error.message);
})

(static) populateDocumentTemplate(configuration, templateData) → {Promise.<ArrayBuffer>}

This is used to Populate the document template (Docx format) with corresponding data.

Returns a Promise resolving to an ArrayBuffer of a Docx, or rejecting with a PSPDFKit.Error.

The resulting ArrayBuffer can be converted to PDF with PSPDFKit.convertToPDF(). and finally loaded with PSPDFKit.load().

It requires a configuration object and config object with data PSPDFKit.TemplateDataToPopulateDocument which contains the data to be populated in document and delimiter marker to know placeholder of the data. If the configuration is invalid, the promise will be rejected with a PSPDFKit.Error.

Parameters:
Name Type Description
configuration PSPDFKit.Configuration

A configuration Object

templateData PSPDFKit.TemplateDataToPopulateDocument

A template data object

Returns:

Promise that resolves to an ArrayBuffer of a file converted to PDF

Type
Promise.<ArrayBuffer>
Example
PSPDFKit.populateDocumentTemplate(
{
  document: '/sales-report.docx',
  licenseKey: 'YOUR_LICENSE_KEY',
},
{
  config: {
    delimiter: {
      start: '{{',
      end: '}}',
    },
  },
  model: {
    products: [
      {
        title: 'Duk',
        name: 'DukSoftware',
        reference: 'DS0',
      },
      {
        title: 'Tingerloo',
        name: 'Tingerlee',
        reference: 'T00',
      },
    ],
  },
},
)
.then(arrayBuffer => {
  console.log('Successfully populated the template Document with data', arrayBuffer)
})
.catch(error => {
  console.error(error.message)
})
The `delimiter` object sets the pair of delimiters that encloses a template marker
i.e. placeholder marker that need to be substituted with the data.

The `model` object associates a template marker with the corresponding substitution in the final, produced document.

=== Supported Template Features ===
Placeholders let users substitute a marker with some text and Loops generate repetitions
of a given pattern.

The syntax for loops is `#` for the opening tag, and `/` for the closing one in the docs.

For instance if the document contains:

```
{#ITEMS} {name} {price} {/ITEMS}
```

Here, `ITEMS` is the name of the loop template marker, and `name` and `price` are regular placeholder
template markers over which the SDK iterates replacing the `name` placeholder with corresponding `name` value
in `model`, and similarly the `price` placeholder is replaced by the corresponding `price` value in `model`.

```
{
  model: {
    items: [
      {
        name: "A",
        price: 10
      },
      {
        name: "B",
        price: 15
      }
    ]
  }
}
```

(static) preloadWorker(configuration) → {Promise.<void>}

Standalone only

Preloads the standalone WASM worker.

In cases where you don't want to load a PDF right away, the first invocation of PSPDFKit.load after allowing this function to resolve will be significantly faster.

If PSPDFKit.load is called while this function has not yet resolved, then PSPDFKit.load will simply reuse the request from this function without adding any overhead.

Parameters:
Name Type Description
configuration PSPDFKit.Configuration

A configuration Object

Returns:

Promise that resolves when preloading is complete

Type
Promise.<void>
Example
// Fetches worker asynchronously
PSPDFKit.preloadWorker(configuration);
document.querySelector("#open-pdf-button").addEventListener(async () => {
  await PSPDFKit.load({ ...configuration, document: "my-doc.pdf" });
});

(static) unload(target) → {boolean}

Unloads an existing PSPDFKit instance.

It requires an target parameter that is a CSS selector, an HTMLElement or the reference to a PSPDFKit.Instance returned by PSPDFKit.load.

Parameters:
Name Type Description
target HTMLElement | string | PSPDFKit.Instance

A target to unload

Throws:

Will throw an error when the target is invalid but will work when it does not have a mounted PSPDFKit for Web instance.

Type
PSPDFKit.Error
Returns:

When true, an instance of PSPDFKit for Web was unmounted.

Type
boolean
Examples

Unload PSPDFKit for Web using an instance

let instance = null;
PSPDFKit.load({
  document: "/sales-report.pdf",
  container: ".foo",
}).then((i) => {
  instance = i
})
.then(() => {
  // Unload the given instance
  PSPDFKit.unload(instance)
}).catch((error) => {
  console.error(error.message);
})

Unload PSPDFKit for Web using a CSS selector

PSPDFKit.load({
  document: "/sales-report.pdf",
  container: ".foo",
})
.then(() => {
  // Unload the given instance
  PSPDFKit.unload(".foo")
})

Unload PSPDFKit for Web using an HTMLElement

PSPDFKit.load({
  document: "/sales-report.pdf",
  container: ".foo",
})
.then(() => {
  // Unload the given instance
  PSPDFKit.unload(document.querySelector(".foo"))
})

(static) viewStateFromOpenParameters() → {PSPDFKit.ViewState}

Merges the properties extracted from the location.hash into the PSPDFKit.ViewState.

Properties will be extracted following the PDF Open Parameters spec.

Currently, we only support the page parameter.

Parameters:
Type Description
PSPDFKit.ViewState
Returns:
Type
PSPDFKit.ViewState

Type Definitions

AIDocumentAssistantConfiguration

Configuration for the AI Document Assistant.

Type:
  • object
Properties:
Name Type Attributes Description
sessionId string

The session to reopen, or an ID for the new session to create. This ID should be unique for each session and should use alphanumeric characters only.

jwt string

The JWT token to authenticate the user.

backendUrl string

The URL that hosts AI Document Assistant service. e.g. 'https://localhost:4000'.

userId string <nullable>

An optional user ID for the current user. This ID should be unique for each user and should use alphanumeric characters only.

Example
{
    sessionId: 'session-id',
    jwt: 'xxx.xxx.xxx'
    backendUrl: 'https://localhost:4000',
}

AnnotationResizeStartCallback(event) → {AnnotationResizeStartCallbackConfiguration|undefined}

This callback is called whenever an annotation is about to be resized. You can use it to control resize behavior.

Parameters:
Name Type Description
event PSPDFKit.AnnotationsResizeEvent

The event containing information regarding the resizing of the annotation

Returns:

The configuration of the resize behavior or undefined for default behavior.

Type
AnnotationResizeStartCallbackConfiguration | undefined

AnnotationToolbarColorPresetsCallback(options) → {PSPDFKit.AnnotationToolbarColorPresetConfig}

This callback allows users to customize the colors that will be displayed in our color dropdown picker, and to add a custom color picker UI to it.

Parameters:
Name Type Description
options object
Properties
Name Type Description
propertyName BuiltInColorProperty

The annotation property for which we need to render a customized array of colors in the color dropdown. The built-in color properties are:

-'color' -'stroke-color' -'fill-color' -'background-color' -'font-color' -'outline-color

Different annotations have different color properties, but all of them are listed above. If you pass a color property that it's not supported, you will get an error.

defaultItems Array.<ColorPreset>

array of default colors

Returns:

the configuration of the customized color picker

Type
PSPDFKit.AnnotationToolbarColorPresetConfig
Example

Customize different color dropdowns.

PSPDFKit.load({
 annotationToolbarColorPresets: function ({ propertyName }) {
   if (propertyName === "font-color") {
     return {
       presets: [
         {
           color: new PSPDFKit.Color({ r: 0, g: 0, b: 0 }),
           localization: {
             id: "brightRed",
             defaultMessage: "Bright Red",
           },
         },
         {
           color: new PSPDFKit.Color({ r: 100, g: 100, b: 180 }),
           localization: {
             id: "deepBlue",
             defaultMessage: "deepBlue",
           },
         },
       ],
     };
   }

   if (propertyName === "stroke-color") {
     return {
       presets: [
         {
           color: new PSPDFKit.Color({ r: 0, g: 0, b: 0 }),
           localization: {
             id: "brightRed",
             defaultMessage: "Bright Red",
           },
         },
         {
           color: new PSPDFKit.Color({ r: 100, g: 100, b: 180 }),
           localization: {
             id: "deepBlue",
             defaultMessage: "deepBlue",
           },
         },
       ],
       showColorPicker: false,
     };
   }
 },
 //...
});

AnnotationToolbarItemsCallback(annotation, options)

This callback can be run on individual annotation toolbars to modify their toolbar items.

For more information, see PSPDFKit.Configuration#annotationToolbarItems

Parameters:
Name Type Description
annotation AnnotationsUnion

The annotation that is going to be created or is currently selected. In case the annotation is not yet created, pageIndex is null.

options AnnotationToolbarItemsCallbackOptions

The AnnotationToolbarItemsCallbackOptions that can be helpful in implementing custom toolbar.

AnnotationTooltipCallback(annotation)

This callback is called whenever an annotation gets selected and can be used to define and return an array of PSPDFKit.ToolItem that will be rendered in a tooltip for the given annotation.

If the callback returns an empty array then PSPDFKit won't show any tooltip for the selected annotation.

Parameters:
Name Type Description
annotation Annotation

The selected annotation.

Example

Register a AnnotationTooltipCallback handler to show a tooltip for text annotations only.

PSPDFKit.load({
  annotationTooltipCallback: function(annotation) {
    if (annotation instanceof PSPDFKit.Annotations.TextAnnotation) {
      var toolItem = {
        type: 'custom',
        title: 'tooltip item for text annotations',
        id: 'item-text-tooltip-annotation',
        className: 'TooltipItem-Text',
        onPress: function () {
          console.log(annotation)
        }
      }
      return [toolItem]
    } else {
      return []
    }
  }
  // ...
});

Change

An union of supported types of changes.

Type:

ComparisonDocuments

Represents a pair of documents to be compared.

Type:
  • object
Properties:
Name Type Description
originalDocument PSPDFKit.DocumentDescriptor

The original document.

changedDocument PSPDFKit.DocumentDescriptor

The changed document.

CustomUIItemRendererCallback(payload)

This user defined function receives the item element's container DOM node and the item data it renders as argument. It's called whenever the item element because of the container element updates.

Parameters:
Name Type Description
payload object

UI element data

Properties
Name Type Description
itemContainerNode Node

Container DOM element.

item any

Item data rendered by the element.

CustomUIRendererCallback(payload) → {PSPDFKit.CustomUIRendererConfiguration}

This user defined function receives the element's container DOM node and the data it renders as argument. It's called whenever the element is mounted, each time the data is modified, and whenever PSPDFKit.Instance#setCustomUIConfiguration is called.

It must return a PSPDFKit.CustomUIRendererConfiguration object.

Parameters:
Name Type Description
payload object

UI element data

Properties
Name Type Description
containerNode Node

Container DOM element.

items PSPDFKit.Immutable.List.<any> | null

Data rendered by the element.

Returns:
Type
PSPDFKit.CustomUIRendererConfiguration

DateTimeStringCallback(args)

Defining this callback allows you to customize how dates are rendered as part of the PSPDFKit UI.

Parameters:
Name Type Description
args object

Arguments passed to the callback.

Properties
Name Type Description
date Date

The date to be formatted.

element PSPDFKit.UIDateTimeElement

The PSPDFKit UI element on which the date is going to be rendered.

object AnnotationsUnion | PSPDFKit.Comment

The annotation or comment that contains the date that is being rendered.

Example
PSPDFKit.load({
  dateTimeString: ({ dateTime, element }) => {
    if(element === PSPDFKit.UIDateTimeElement.ANNOTATIONS_SIDEBAR) {
      return new Intl.DateTimeFormat("en-US", {
        dateStyle: "short",
        timeStyle: "short",
      }).format(dateTime);
    } else {
      return new Intl.DateTimeFormat("en-US", {
        dateStyle: "full",
        timeStyle: "long",
      }).format(dateTime);
    }
  }
  // ...
});

DocumentComparisonConfiguration

Object containing configuration options for document comparison.

Defines specific configuration options related to the document comparison feature. Passed when calling PSPDFKit.Instance#setDocumentComparisonMode.

Example
instance.setDocumentComparisonMode({
  documentA: {
    source: PSPDFKit.DocumentComparisonSourceType.USE_OPEN_DOCUMENT
  },
  documentB: {
    source: PSPDFKit.DocumentComparisonSourceType.USE_FILE_DIALOG
  },
  autoCompare: false
});

ElectronicSignatureDefaultTextCallback() → {string|null}

Callback that returns the default text for the Type Electronic Signature UI.

Returns:

The default text for the Type Electronic Signature UI.

Type
string | null

EnableRichTextCallback(textAnnotation)

This call back defines which text annotations should be treated as rich text annotation. By default, all the text annotations are treated as plain text annotations, which means that when you edit them, you will see the plain text editor. You can change this behavior by returning true for the text annotations that you want to be treated as rich text annotations.

For more information, see PSPDFKit.Configuration#enableRichText.

Parameters:
Name Type Description
textAnnotation TextAnnotation
Example

Only treat newly created annotations as rich text annotations

PSPDFKit.load({
  enableRichText: annotation => annotation.pageIndex === null
  // ...
});

FontSubstitution

An array of fonts to be substituted and the fonts to substitute them with

Describes the fonts that you would like to substitute in a document and the fonts you would like to use for that substitution

Patterns are matched using the following rules:

  • * matches multiple characters.
  • ? matches a single character.

Ordering matters - As names could match multiple patterns, it's important to note that the order of the patterns matters. Case-insensitive - Both the pattern and the target name are case-insensitive.

Type:
  • object
Properties:
Name Type Description
pattern string

The font you would like to be substituted

target string

The font you would like to substitute the "from" font with

Example

Substitute all Noto fonts found in the document with AwesomeFont

const myFontsSubstitutions = [{
 pattern: "Noto*",
 target: "AwesomeFont"
}]

PSPDFKit.load(
 //...
 fontSubstitutions: myFontsSubstitutions,
)

InlineTextSelectionToolbarItemsCallback(selection)

This callback can be run on specific text selection to modify its inline toolbar items.

Parameters:
Name Type Description
selection PSPDFKit.TextSelection

The text that is currently selected.

InlineToolbarItemsCallbackOptions()

PSPDFKit for Web comes with a built-in toolbar that shows whenever some text is selected on a document, we will refer to said tooltip as inline toolbar from now on. This callback allows users to customize said inline toolbar.

Properties:
Name Type Description
defaultAnnotationToolbarItems Array.<BuiltInInlineToolbarItem>

The list of default items thats is shown in the inline toolbar

hasDesktopLayout boolean

Whether the screen is in desktop layout.

IsEditableAnnotationCallback(annotation)

This callback defines which annotations are read-only. This callback will receive the Annotation a user wants to modify and by returning true or false you can define if the annotation should be read-only (false) or modifiable (true).

For more information, see PSPDFKit.Configuration#isEditableAnnotation.

Parameters:
Name Type Description
annotation AnnotationsUnion
Example

Only allow the modification of annotations from the same author

PSPDFKit.load({
  isEditableAnnotation: function(annotation) {
    return annotation.creatorName === myCurrentUser.name;
  },
});

MeasurementValueConfiguration()

PSPDFKit for Web allows you to pass a customized configuration for measurements annotation scale and precision through the following callback

Properties:
Name Type Attributes Description
name string

Your custom configuration name. It has to be unique.

scale IMeasurementScale

The custom scale passed in the configuration, it represent the scale used in the document

precision IMeasurementPrecision

Precision values for the length of measurement annotations

selected boolean <nullable>

Whether a custom scale is selected or not.

Example

Configure a custom scale and pass it to our viewer

const customScales = [
  {
    scale: {
      unitFrom: PSPDFKit.MeasurementScaleUnitFrom.CENTIMETERS,
      unitTo: PSPDFKit.MeasurementScaleUnitTo.METERS,
      fromValue: 1,
      toValue: 2
    },
    precision: PSPDFKit.MeasurementPrecision.FOUR,
    selected: true
  }
];

PSPDFKit.load({
  // Other options.
  measurementValueConfiguration: (documentScales) => {
    return [...customScales, ...documentScales];
  }
});

ModificationType

Indicates the type of modification made to a PSPDFKit.Change.

Type:
  • 'CREATED' | 'UPDATED' | 'DELETED'

OnCommentCreationStartCallback(comment)

You can programmatically modify the properties of the comment just before it is created.

Parameters:
Name Type Description
comment Comment
Example

Set default text of a Comment

PSPDFKit.load({
  onCommentCreationStart: comment => comment.set('text', { format: 'xhtml', value: '<p>This comment has a default value</p>' })
  // ...
});

OnWidgetAnnotationCreationStartCallback(widgetAnnotation, formField)

You can programmatically modify the properties of the widget annotation and the associated form field just before it is created via the form creator UI.

Parameters:
Name Type Description
widgetAnnotation PSPDFKit.Annotations.WidgetAnnotation

The widget annotation that is about to be created.

formField PSPDFKit.FormFields.FormField

The original form field that is associated with the widget annotation.

Example

Set the opacity of all widget annotations.

PSPDFKit.load({
  onWidgetAnnotationCreationStart: (annotation, formField) => {
    return { annotation: annotation.set('opacity', 0.7) };
  }
  // ...
});

RenderPageCallback(canvas, pageIndex, size)

This callback is called whenever a page is rendered or printed (only for PSPDFKit.PrintMode.DOM). You can use it to render watermarks on the page.

Make sure that the rendering commands are as efficient as possible as they might be invoked multiple times per page (once per tile).

For more information, see PSPDFKit.Configuration#renderPageCallback.

Parameters:
Name Type Description
canvas CanvasRenderingContext2D

A 2D <canvas/> rendering context.

pageIndex number

The current page index, starting with 0 for the first page.

size PSPDFKit.Geometry.Size

The size of the page that you're drawing at. The canvas is already scaled accordingly.

Example

Register a RenderPageCallback handler at configuration time.

PSPDFKit.load({
  renderPageCallback: function(ctx, pageIndex, pageSize) {
    ctx.beginPath();
    ctx.moveTo(0, 0);
    ctx.lineTo(pageSize.width, pageSize.height);
    ctx.stroke();

    ctx.font = "30px Comic Sans MS";
    ctx.fillStyle = "red";
    ctx.textAlign = "center";
    ctx.fillText(
      `This is page ${pageIndex + 1}`,
      pageSize.width / 2,
      pageSize.height / 2
    );
  }
  // ...
});

SigningServiceData

Data for the digital signing service.

Contains information to be optionally passed along to the backend signing service when PSPDFKit.Instance.signDocument() is called, so it can be used for identification, security or any other purpose.

Type:

TrustedCAsCallback() → {Promise.<Array.<(ArrayBuffer|string)>>}

On Standalone, by implementing this callback you have a fine grained control over which certificates are going to be used for digital signatures validation.

For more information, see PSPDFKit.Configuration#trustedCAsCallback

Returns:

The CA certificates in DER (ArrayBuffer) or PEM (string) format. PSPDFKit.load({ trustedCAsCallback: function() { return new Promise((resolve, reject) => { fetch("/your-certificate.cer") .then(res => res.arrayBuffer()) .then(cert => resolve([cert])) .catch(reject) }); }, // ... });

Type
Promise.<Array.<(ArrayBuffer|string)>>
Example
<caption>Fetch and use custom set of certificates (Standalone)</caption>

TwoStepSignatureCallback(signaturePreparedData) → {Promise.<(ArrayBuffer|PSPDFKit.SignatureCallbackResponsePkcs7|PSPDFKit.SignatureCallbackResponseRaw)>}

This callback is called when a document has been prepared for digitally signing by calling instance.signDocument(). It receives the current document hash, file contents and data to be signed as arguments, and must return a Promise object that resolves to any of these types:

  • An ArrayBuffer that contains either the signed data or a PKCS7 container that includes it.
  • A SignatureCallbackResponsePkcs7 that is structured type for when the signature device or service creates signatures in the PKCS#7 format.
  • A SignatureCallbackResponseRaw that is structured type for when the signature device or service creates signatures in the raw (for instance, PKCS#1.5) format. If the returned Promise object rejects, the document will not be signed.

The provided file contents or the data to be signed can be used as input for the Web Crypto API, or for a signing service of your choice to be signed (hashed and encrypted). The file contents hash is also provided so it can be used it to verify the validity of the contents.

See this guide article for more information on how to digitally sign a document on Standalone.

Parameters:
Name Type Description
signaturePreparedData object

Signature prepared data.

Properties
Name Type Attributes Description
hash string

Hash of the current document.

fileContents ArrayBuffer <nullable>

Content of the file to be signed. Provided only for CMS signatures.

dataToBeSigned ArrayBuffer

Data to be signed for CAdES signatures.

Returns:

A promise that resolves to any of these:

  • An ArrayBuffer that contains the signed data in the PKCS#1.5 or PKCS#7 format.
  • A SignatureCallbackResponsePkcs7, for when the signature device or service creates signatures in the PKCS#7 format.
  • A SignatureCallbackResponseRaw, for when the signature device or service creates signatures in the raw (for instance, PKCS#1.5) format. The ArrayBuffer return type is deprecated. It's recommended to return either a SignatureCallbackResponsePkcs7 or SignatureCallbackResponseRaw, depending on the signature format.
Type
Promise.<(ArrayBuffer|PSPDFKit.SignatureCallbackResponsePkcs7|PSPDFKit.SignatureCallbackResponseRaw)>
Example

Sign document (Standalone)

instance.signDocument(null, function({ hash, fileContents }) {
  return new Promise(function(resolve, reject) {
    const PKCS7Container = getPKCS7Container(hash, fileContents);
    if (PKCS7Container != null) {
      return resolve(PKCS7Container)
    }
    reject(new Error("Could not retrieve the PKCS7 container."))
  })
}).then(function() {
  console.log("Document signed!");
})

documentEditorUIConfig

An object that allows you to configure the Document Editor UI.

Type:
  • object
Properties:
Name Type Description
thumbnailMinSize number

The minimum size of the thumbnail

thumbnailMaxSize number

The maximum size of the thumbnail

thumbnailDefaultSize number

The default size of the thumbnail

Example
const myDocumentEditorUIConfig =  {
      thumbnailDefaultSize: 500,
      thumbnailMinSize: 100,
      thumbnailMaxSize: 600,
    }

PSPDFKit.load(
 //...
 documentEditorConfig: myDocumentEditorUIConfig,
)