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
Install the Nutrient dependency. In the terminal app, change the location of the current working directory to your project and run the following command to add the Nutrient dependency to your project:
Terminal window flutter pub add pspdfkit_flutterDownload 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 theweb/assets
directory or any other folder of your choice inside the web subfolder.Make sure your
assets
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
Create a
PDFs
directory inassets
. Rename the PDF document you want to display in your application todocument.pdf
, and place it in thePDFs
directory. You can use this demo document as an example.Specify the
assets
directory inpubspec.yaml
:# The following section is specific to Flutter.flutter:+ assets:+ - PDFs/...Include the Nutrient library in your
index.html
file:<script src="assets/nutrient-viewer.js"></script>Import the PSPDFKit package:
import 'package:pspdfkit_flutter/pspdfkit_flutter.dart';Display a PDF document inside your Flutter app:
Scaffold(body: PspdfkitWidget(documentPath: 'file:///path/to/Document.pdf',),);Run the app:
Terminal window flutter run