Nutrient Web SDK is a JavaScript PDF library for viewing, annotating, and editing PDFs directly in the browser. Use it to add PDF capabilities to any web app.
This guide walks you through the steps to integrate Nutrient into your project. By the end, you'll be able to render a PDF document in the UI.
Installation
Nutrient Viewer for Web library files are distributed as an archive that you extract manually:
Download the framework here. The download will start immediately and will save a
.tar.gz
archive likePSPDFKit-Web-binary-1.0.0.tar.gz
to your computer.Once the download is complete, extract the archive and copy the entire contents of its
dist
folder to thewwwroot/lib
directory in your project.Make sure your
wwwroot/lib
folder contains the filenutrient-viewer.js
and anutrient-viewer-lib
directory with library assets.Make sure your server has the
Content-Type: application/wasm MIME
typeset. Read more about this in the troubleshooting section of our guides.
Render a PDF
Integrate Nutrient Viewer in your view, Views/Home/Index.cshtml
:
Include
nutrient-viewer.js
. The path is relative to thewwwroot
directory:<script src="/lib/nutrient-viewer.js"></script>Add an empty
<div>
element with a definedwidth
andheight
to wherenutrient-viewer
will be mounted:<div id="nutrient" style="width: 100%; height: 100vh;"></div>Initialize Nutrient Viewer by calling
NutrientViewer.load()
:<script>NutrientViewer.load({container: "#nutrient",document: "document.pdf",}).then(function(instance) {console.log("Nutrient Viewer loaded", instance);}).catch(function(error) {console.error(error.message);});</script>Rename the PDF document you want to display in your application to
document.pdf
, and place it in thewwwroot
directory. You can use this demo document as an example.Select Run > Start Debugging. This will start your app and open it in your default browser.