Load a minimal PDF stub from a string

Q: How can I load a minimal PDF stub from a string?

A: You can use the basic set of information needed by PSPDFKit for Web to render a document. Some of the examples from this StackOverflow thread do indeed work. Here’s one of them, converted to an array buffer passed in PSPDFKit.Configuration#pdf that can 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
0 4
0000000000 65535 f
0000000010 00000 n
0000000053 00000 n
0000000102 00000 n
trailer<</Size 4/Root 1 0 R>>
// TextEncoder() needs to be polyfilled in IE11, see
// https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder
const uint8array = new TextEncoder().encode(PDFstub);
  document: uint8array.buffer

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