Load a Minimal PDF Stub from a String

To load a minimal PDF stub from a string, use the basic set of information needed by PSPDFKit for Web to render a document. Some of the examples from this Stack Overflow thread work. Here’s one of them, which is converted to an array buffer passed in PSPDFKit.Configuration#document that can then be consumed and rendered by our API:

const PDFstub = `%PDF-1.0
1 0 obj<</Type/Catalog/Pages 2 0 R>>endobj 2 0 obj<</Type/Pages/Kids[3 0 R]/Count 1>>endobj 3 0 obj<</Type/Page/MediaBox[0 0 750 1000]>>endobj
xref
0 4
0000000000 65535 f
0000000010 00000 n
0000000053 00000 n
0000000102 00000 n
trailer<</Size 4/Root 1 0 R>>
startxref
149
%EOF`;
const uint8array = new TextEncoder().encode(PDFstub);
PSPDFKit.load({
  ...defaultConfiguration,
  document: uint8array.buffer
});
Warning

Internet Explorer 11 is no longer supported in our Web SDK as of version 2022.5. Edge 18 is no longer supported in our Web SDK as of version 2023.2.

This has been tested with PSPDFKit for Web 2019.4.1