PSPDFKit 2021.4 migration guide for seamless updates

In PSPDFKit for Web 2021.4, we changed the default value of NutrientViewer.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 NutrientViewer.load():

NutrientViewer.Options.PDF_JAVASCRIPT = false;
NutrientViewer.load(configuration);

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(opens in a new tab).

Before:

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

After:

type Instance = InstanceType<typeof NutrientViewer.Instance>;

Some of the frequently used types are:

type Instance = InstanceType<typeof NutrientViewer.Instance>;
type Rect = InstanceType<typeof NutrientViewer.Geometry.Rect>;
type Color = InstanceType<typeof NutrientViewer.Color>;
type Annotation = InstanceType<typeof NutrientViewer.Annotations.Annotation>;
type TextSelection = InstanceType<typeof NutrientViewer.TextSelection>;
type ToolbarItems = InstanceType<typeof NutrientViewer.Instance>["toolbarItems"];
type List = ReturnType<typeof NutrientViewer.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, make sure you read the 2021.4 server migration guide.