Add PDF functionality with Flutter

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 Web SDK into your project. By the end, you’ll be able to render a PDF document in the user interface (UI).

Installing the Nutrient dependency

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 to the <head> section of your web/index.html file:

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

Rendering a PDF

  1. Import the PSPDFKit package:

    import 'package:nutrient_flutter/nutrient_flutter.dart';
  2. Display a PDF document inside your Flutter app:

    Scaffold(
    body: NutrientView(
    documentPath: 'https://www.nutrient.io/downloads/nutrient-web-demo.pdf',
    ),
    );
  3. Run the app:

    Terminal window
    flutter run

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.