This example shows how to integrate PSPDFKit Server and PSPDFKit for Web into a Node.js / Express app.
Note: This example demonstrates the usage of PSPDFKit for Web in a Node.js application and is not optimized for production deployments. For information on how to set up PSPDFKit for Web in production, please refer to our guides instead.
- A PSPDFKit Server license. If you don't already have one you can request a free trial here.
We recommend you use Docker to get all components up and running quickly.
The provided docker-compose.yml
and Dockerfile
will allow you to edit the example app on your
host and it will live-reload.
$ git clone https://github.com/PSPDFKit/pspdfkit-server-example-nodejs.git
$ cd pspdfkit-server-example-nodejs
$ ACTIVATION_KEY=YOUR_ACTIVATION_KEY_GOES_HERE docker-compose up
If you are using Windows make sure to set the environment variables accordingly. For this replace the line starting with PSPDFKIT_ACTIVATION_KEY="...
with:
$ SET "PSPDFKIT_ACTIVATION_KEY=YOUR_ACTIVATION_KEY_GOES_HERE"
$ docker-compose up
Make sure to replace YOUR_ACTIVATION_KEY_GOES_HERE
with your PSPDFKit Server activation key. You only have
to provide the activation key once, after that the server will remain activated until you reset it.
The example app is now running on http://localhost:3000. You can access PSPDFKit Server's
dashboard at http://localhost:5000/dashboard using dashboard
// secret
.
Upload a PDF via the button in the top-left, then click on the cover image to see PSPDFKit for Web in action.
You can reset the server by first tearing down its containers and volumes and then recreating them.
$ docker-compose down --volumes
$ ACTIVATION_KEY=YOUR_ACTIVATION_KEY_GOES_HERE docker-compose up
If you are using Windows make sure to set the environment variables accordingly. For this replace the line starting with PSPDFKIT_ACTIVATION_KEY="...
with:
$ SET "PSPDFKIT_ACTIVATION_KEY=YOUR_ACTIVATION_KEY_GOES_HERE"
$ docker-compose up
You can also run the example app directly on your machine, outside of a Docker container.
- Node.js (with npm or Yarn)
- PSPDFKit Server running on http://localhost:5000 with the default configuration
$ git clone https://github.com/PSPDFKit/pspdfkit-server-example-nodejs.git
$ cd pspdfkit-server-example-nodejs
$ npm install
$ npm start
The example app is now running on http://localhost:3000.
Upload a PDF via the button in the top-left, then click on the cover image to see PSPDFKit for Web in action.
You can quit the running containers with Ctrl-C.
If you want to test PSPDFKit for Web on different devices in your local network, you need
to edit the PSPDFKIT_SERVER_EXTERNAL_URL
environment variable in the docker-compose.yml
and set it to an address that's reachable from your device.
Occasionally running the docker-compose
scripts will result in errors because some containers are in a broken state. To resolve this, you can reset all containers and their attached volumes by running the following command:
docker-compose down --volumes
If you have further troubles, you can always reach out to us via our support platform.
This software is licensed under a modified BSD license.
Please ensure you signed our CLA so we can accept your contributions.