Load a PDF as an ArrayBuffer | Nutrient
To load a PDF as an array buffer in Nutrient Web SDK, instead of passing the document URL directly in the configuration object, you can retrieve it with fetch() using the required credentials options (Nutrient Web SDK uses credentials: same-origin), and then pass it to NutrientViewer.load() as an ArrayBuffer, like this:
fetch(url, { credentials: "include" }) .then((res) => res.arrayBuffer()) .then((arrayBuffer) => { NutrientViewer.load({ container: targetSelector, document: arrayBuffer }); });Nutrient Web SDK takes ownership of the ArrayBuffer it’s given, transferring rather than copying it — this detaches the original and leaves it at zero length, so reusing it for a second load fails. To load the same document again, keep a separate copy of the bytes before the first load and pass a fresh copy, such as arrayBuffer.slice(0), to each load.
You’ll find more details about the NutrientViewer.Configuration#document property in our API reference.
This has been tested with Nutrient Web SDK 2020.2.3.