Load a PDF as an ArrayBuffer in Standalone Mode

To load a PDF as an array buffer in Standalone mode, instead of passing the document URL directly in the configuration object, you can retrieve it with fetch() using the required credentials options (PSPDFKit for Web uses credentials: same-origin), and then pass it to PSPDFKit.load() as an ArrayBuffer, like this:

fetch(url, { credentials: "include" })
  .then((res) => res.arrayBuffer())
  .then((arrayBuffer) => {
    PSPDFKit.load({
      container: targetSelector,
      document: arrayBuffer
    });
  });

You’ll find more details about the PSPDFKit.Configuration#document property in our API reference.

This has been tested with PSPDFKit for Web 2020.2.3