Chat with Your PDFs Now!
Read More ↗

Secure Private Document Access with JWT Signature Tokens

CloudPDF utilizes JWT tokens for secure authentication of private documents. To access these documents, you'll need to generate a token from your backend and integrate it with the CloudPDF viewer. The viewer then sends the token to the CloudPDF server for validation. Upon successful verification, the document information is transmitted, and the document becomes visible. Refer to the provided Node.js example to learn how to generate a secure JWT token.

import { CloudPDF } from '@cloudpdf/api';
const cloudpdf = new CloudPDF({
apiKey: 'YOUR API KEY',
cloudName: 'YOUR CLOUD NAME',
signingSecret: 'YOUR SIGNING SECRET'
const key = cloudPDF.getViewerToken({
id: 'your document id',
download: "Allowed",
search: false,
selection: false,
watermarks: [{
fontFamily: 'sans-serif',
fontSize: 100,
text: 'Test watermark',
opacity: 20,
color: 'red',
type: 'diagonal'
}, '1h')

The first parameter of the function is an object which can have the following options:

  • id your document ID. where to find your document id?
  • download if set to "NotAllowed" the document is not downloadable. If set to "Allowed", the document is downloadable
  • search if set to false the document is not searchable
  • selection if set to false the document text is not selectable

The second parameter is the token expiry date and can have the following value:

Eg:60,"2 days","10h","7d". A numeric value is interpreted as a seconds count. If you use a string be sure you provide the time units (days, hours, etc), otherwise milliseconds unit is used by default ("120"is equal to"120ms").