2021.4 Migration Guide

In PSPDFKit for Web 2021.4, we changed the default value of PSPDFKit.Options.PDF_JAVASCRIPT to true, so JavaScript actions will be enabled by default in Standalone mode (JavaScript actions aren’t supported in Server mode).

If this setting affects your integration, you can restore the previous behavior by setting the option to false before calling PSPDFKit.load():

PSPDFKit.Options.PDF_JAVASCRIPT = false;

We completely changed the way we generate TypeScript declarations to make them more powerful and accurate. The internal API declarations are no longer exported, so if you were using those, it might lead to errors during the build step. This shouldn’t affect you if you weren’t using the types of internal APIs. If you still want to use internal types, most of them can be formed using the combination of typeof and utility types.


import Instance from "pspdfkit/dist/types/typescript/Instance";


type Instance = InstanceType<typeof PSPDFKit.Instance>;

Some of the frequently used types are:

type Instance = InstanceType<typeof PSPDFKit.Instance>;
type Rect = InstanceType<typeof PSPDFKit.Geometry.Rect>;
type Color = InstanceType<typeof PSPDFKit.Color>;
type Annotation = InstanceType<typeof PSPDFKit.Annotations.Annotation>;
type TextSelection = InstanceType<typeof PSPDFKit.TextSelection>;
type ToolbarItems = InstanceType<typeof PSPDFKit.Instance>["toolbarItems"];
type List = ReturnType<typeof PSPDFKit.Immutable.List>;

type Awaited<T> = T extends PromiseLike<infer U> ? Awaited<U> : T;
type AnnotationsList = Awaited<ReturnType<Instance["getAnnotations"]>>;

We’re exploring ways to make this experience better in our upcoming releases.

For a full list of changes, check out the changelog.

Migrate PSPDFKit Server

If you use PSPDFKit Server, please make sure you read the 2021.4 Server Migration Guide.