Select a product

PDF.js Express Free Viewerplay_arrow

Professional PDF.js Viewing - Free

PDF.js Express Plusplay_arrow

Professional PDF.js Viewing & Annotations - Try for free

Get Started

play_arrow

Learn more

play_arrow

Common use cases

play_arrow

Open a document

play_arrow

Save a document

play_arrow

Viewer

play_arrow

UI Customization

play_arrow

Annotations

play_arrow

Collaboration

play_arrow

Forms

play_arrow

Signature

play_arrow

Searching

play_arrow

Measurement

play_arrow

Compare

play_arrow

Advanced Capabilities

play_arrow

PDF.js Express REST API

play_arrow

Migration Guides

play_arrow

Forwarding headers

The following features are available in:

check

PDF.js Express Viewer

help_outline

PDF.js Express Viewer is a free viewer that has limited capabilities compared to PDF.js Express Pro

check

PDF.js Express Plus

help_outline

PDF.js Express Plus is a paid product that supports annotating, signing, form filling and more

All endpoints accept a URL as a file, and sometimes headers will be required in order to fetch these files. For example, if you are using a protected endpoint, it might require an Authorization header to be set.

All endpoints accept a headers field, which should come in the form as stringified JSON. These headers will be forwarded when we make a GET request to download your file.

For example:

const data = new FormData();
  data.append('file', 'http://my-protected-endpoint.com/file.pdf');
  data.append('license', my_license_key);
  data.append('headers', JSON.stringify({
    Authorization: 'my_auth_code'
  }))

  // Process the file
  const response = await fetch('https://api.pdfjs.express/xfdf/extract', {
    method: 'post',
    body: data
  }).then(resp => resp.json());

The API will now pass the Authorization header when it tries to fetch http://my-protected-endpoint.com/file.pdf.

Chaining APIs

This feature also allows you to chain API calls easily. Since getting a file from our API requires an Authorization header to be set, forwarding this header is necessary.

For example, to merge XFDF and then watermark you could do something like this:

const data = new FormData();
  data.append('file', 'http://my-protected-endpoint.com/file.pdf');
  data.append('license', my_license_key);
  data.append('xfdf', my_xfdf);

  // Process the file
  const response = await fetch('https://api.pdfjs.express/xfdf/merge', {
    method: 'post',
    body: data
  }).then(resp => resp.json());

  const {url, key} = response;

  const watermarkData = new FormData();
  watermarkData.append('file', 'url');
  watermarkData.append('headers', JSON.stringify({
    Authorization: key
  }))
  watermarkData.append('text', 'my watermark')

  const watermarkResponse = await fetch('https://api.pdfjs.express/watermark', {
    method: 'post',
    body: data
  }).then(resp => resp.json());