2022.1 Migration Guide

Note: version 2022.1.0 contains a bug that was immediately fixed in the next version, 2022.1.1. Please use version 2022.1.1 instead of 2022.1.0.

PSPDFKit for Web 2022.1 introduces several API changes. We recommend verifying your implementation to check if it needs updating.

Configuration#pdf Removed

We removed the Configuration#pdf API, which has been deprecated since 2020.2.0, in favor of Configuration#document.

Note that Configuration#document can be used as a drop-in replacement for the removed API, as it works exactly the same.

If you used to set Configuration#pdf to pass a document URL or ArrayBuffer in the configuration, you only need to pass it in Configuration#document instead from now on.

Before:

PSPDFKit.load({
  pdf: "https://example.com/document.pdf"
});

Now:

PSPDFKit.load({
-  pdf: "https://example.com/document.pdf"
+  document: "https://example.com/document.pdf"
});

Javascript Actions Cannot Open External URLs by Default

For security reasons, JavaScript actions will no longer be able to open URLs by default. The URLs will only open if the user has explicitly clicked on a URL. If you want to go back to the old behavior, you can use Configuration#onOpenURI:

PSPDFKit.load({
  // ...
  onOpenURI: () => true
});

Document Comparison Button Now Hidden by Default

The Document Comparison toolbar button is now hidden by default; the reason is its behavior usually needs to be configured so as to be useful and address the required use case.

If you need to enable it, you can do so in the configuration:

PSPDFKit.load({
  toolbarItems: PSPDFKit.defaultToolbarItems.reduce((acc, it) => {
    if (it.type === "document-crop") {
      return acc.concat([it, { type: "document-comparison" }]);
    }

    return acc.concat([it]);
  }, [])
});

Or, after loading:

instance.setTolbarItems((ti) => {
  return ti.reduce((acc, it) => {
    if (it.type === "document-crop") {
      return acc.concat([it, { type: "document-comparison" }]);
    }

    return acc.concat([it]);
  }, []);
});

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

Migrate PSPDFKit Server

For more information, please take a look at the PSPDFKit Server 2022.1 Migration Guide.