@shelf/pspdfkit-ssr

Utilities to work with PSPDFKit's server-side rendering

Usage no npm install needed!

<script type="module">
  import shelfPspdfkitSsr from 'https://cdn.skypack.dev/@shelf/pspdfkit-ssr';
</script>

README

pspdfkit-ssr CircleCI npm (scoped)

Install

$ yarn add @shelf/pspdfkit-ssr

Usage

const {createReadStream} = require('fs');
const {uploadPDF, getJWTForDocumentPreview} = require('@shelf/pspdfkit-ssr');

const documentId = await uploadPDF({
  documentId: 'some-custom-document-id',
  fileStream: createReadStream('./file.pdf'),
  fileSize: 1024
});

const jwt = getJWTForDocumentPreview(documentId);

Note: this library relies upon following environment variables:

  • PSPDFKIT_SERVER_URL
  • PSPDFKIT_SERVER_AUTH_TOKEN
  • PSPDFKIT_SERVER_JWT_KEY
  • PSPDFKIT_SERVER_JWT_PASSPHRASE

Note: this library tries to be idempotent. Unlike PSPDFKit server, it catches errors when document with provided ID was already uploaded.

See Client Authentication section of PSPDFKit documentation for details.

License

MIT © Shelf