2023.3 Migration Guide

PSPDFKit for Web 2023.3 introduces some new APIs and includes several bug fixes. To determine if you need to take action, check your implementation and refer to the information below.

Notable Changes

  • (#39413) If you used the Annotation type in your TypeScript code, change it to AnnotationsUnion to get the correct types. The reason is that the annotation types have different signatures and, because TypeScript is a structural type system, it isn’t possible to have a single type for all annotations. This change is meant to improve developer experience when working with annotations. We aim to keep improving this API. Similarly, change ShapeAnnotation to ShapeAnnotationsUnion, and change TextMarkupAnnotation to TextMarkupAnnotationsUnion. This is a type change only, and it doesn’t affect the runtime behavior. Your code will continue to work as expected. If you didn’t use these types or TypeScript in your code, don’t do anything.

Before

import type {
  Annotation,
  RedactionAnnotation,
  ShapeAnnotation,
  TextMarkupAnnotation
} from "pspdfkit";

const annotation: Annotation = {
  // ...
};

const shapeAnnotation: ShapeAnnotation = {
  // ...
};

const textMarkupAnnotation: TextMarkupAnnotation = {
  // ...
};

const redactionAnnotation: RedactionAnnotation = {
  // ...
};

After

import type {
  AnnotationsUnion,
  ShapeAnnotationsUnion,
  TextMarkupAnnotationsUnion,
  RedactionAnnotation
} from "pspdfkit";

const annotation: AnnotationsUnion = {
  // ...
};

const shapeAnnotation: ShapeAnnotationsUnion = {
  // ...
};

const textMarkupAnnotation: TextMarkupAnnotationsUnion = {
  // ...
};

const redactionAnnotation: RedactionAnnotation = {
  // ...
};

As you can see above, only the types of abstract annotations changed. The concrete annotation types, such as RedactionAnnotation and TextAnnotation, remain the same.

Migrate PSPDFKit Server

For information on PSPDFKit Server migration, see PSPDFKit Server 2023.3 Migration Guide.

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