Skip to content

kevindenight/pspdfkit-server-example-nodejs

 
 

Repository files navigation

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.

Troubleshooting

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.

License

This software is licensed under a modified BSD license.

Contributing

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

About

Sample for PSPDFKit Server and Instant

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 61.1%
  • HTML 21.1%
  • CSS 17.3%
  • Dockerfile 0.5%