Add PDF functionality with ASP.NET

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 user interface (UI).

Installation

You can load Nutrient Web SDK directly from Nutrient’s content delivery network (CDN). Nutrient maintains the CDN for customers, and it’s our recommended way to get started. For more control and flexibility, use the local installation option.

  1. Add the following script tag in your view — for example, Views/Home/Index.cshtml:

    <script src="https://cdn.cloud.pspdfkit.com/pspdfkit-web@1.10.0/nutrient-viewer.js"></script>
  2. You’re now ready to use Nutrient Web SDK and reference window.NutrientViewer in your views.

Rendering a PDF

Integrate Nutrient Viewer in your view, Views/Home/Index.cshtml:

  1. Add an empty <div> element with a defined width and height to where nutrient-viewer will be mounted:

    <div id="nutrient-container" style="width: 100%; height: 100vh;"></div>
  2. Initialize Nutrient Viewer by calling window.NutrientViewer.load():

    <script>
    window.NutrientViewer.load({
    container: "#nutrient-container",
    document: "https://www.nutrient.io/downloads/nutrient-web-demo.pdf",
    })
    .then(function (instance) {
    console.log("Nutrient Viewer loaded", instance);
    })
    .catch(function (error) {
    console.error(error.message);
    });
    </script>
  3. To run the app, select Run > Start Debugging. This will start your app and open it in your default browser.

Troubleshooting

If you encounter issues, refer to the common issues guide.

Note for developers using AI coding assistants: To get accurate troubleshooting help, copy the content from the troubleshooting guide and include it in your prompt, along with your specific error.