PDF.js Express Plusplay_arrow

Professional PDF.js Viewing & Annotations - Try for free

side menu

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

Getting a processed file

The following features are available in:

check

PDF.js Express Viewer

help_outline

PDF.js Express Viewer is a free viewer with limited capabilities compared to PDF.js Express Plus

check

PDF.js Express Plus

help_outline

PDF.js Express Plus is a commercial PDF SDK for viewing, annotating, signing, form filling and more

In order to get a processed file from the API, the proper authorization header must be set.

This header is returned from any endpoint that creates a new file (set, merge), and is returned as key.

In order to get the file, you must set the Authorization header to be equal to the returned key.

Example:

const { docViewer, annotManager } = instance;

  // a callback function to some "download" button
  const onSave = async () => {
    const xfdf = await annotManager.exportAnnotations({ links: false, widgets: false });
    const fileData = await docViewer.getDocument().getFileData({});

    const data = new FormData();
    data.append('xfdf', xfdf);
    data.append('file', fileData);
    data.append('license', my_license_key);

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

    const { url, key, id } = response;

    // Download the file
    const mergedFileBlob = await fetch(url, {
      headers: {
        Authorization: key
      }
    }).then(resp => resp.blob())
  }
const { documentViewer, annotationManager } = instance.Core;

  // a callback function to some "download" button
  const onSave = async () => {
    const xfdf = await annotationManager.exportAnnotations({ links: false, widgets: false });
    const fileData = await documentViewer.getDocument().getFileData({});

    const data = new FormData();
    data.append('xfdf', xfdf);
    data.append('file', fileData);
    data.append('license', my_license_key);

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

    const { url, key, id } = response;

    // Download the file
    const mergedFileBlob = await fetch(url, {
      headers: {
        Authorization: key
      }
    }).then(resp => resp.blob())
  }