Sample for PSPDFKit Server and Instant
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
assets
bin
config
db
public
routes
util
views
.dockerignore
.eslintignore
.eslintrc
.gitignore
Dockerfile
LICENSE
README.md
app.js PSPDFKit for Web Node.js Example Sep 5, 2018
docker-compose.yml
package-lock.json
package.json
yarn.lock

README.md

PSPDFKit Server Example – Node.js

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.

Prerequisites

Getting Started with Docker

Prerequisites

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.

Resetting the server

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

Running the example locally

You can also run the example app directly on your machine, outside of a Docker container.

Prerequisites

Getting Started

$ 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.

License

This software is licensed under a modified BSD license.

Contributing

Please ensure you signed our CLA so we can accept your contributions.