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

Saving a document as a blob

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

Documents can be exported from PDF.js Express by using the Document.getFileData API.

Please note that PDF.js Express does not have the ability to bake annotations into a PDF file on the client, so getFileData will not include annotations. For instructions on baking annotations into the document, please see this guide.

A use case for this may be saving a file a user has uploaded to your own server, allowing them to reuse it later.

The function can be used as follows:

Webviewer({
  ...options
}, document.getElementById('viewer')).then(instance => {

  const { docViewer } = instance;

  // must wait for the document to be loaded before you can save the file
  docViewer.on('documentLoaded', async () => {
    const documentStream = await docViewer.getDocument().getFileData({});
    const documentBlob = new Blob([documentStream], { type: 'application/pdf' });

    // Example function that saves a blob to the server
    saveBlobToServer(documentBlob);
  })
});
Webviewer({
  ...options
}, document.getElementById('viewer')).then(instance => {

  const { documentViewer } = instance.Core;

  // must wait for the document to be loaded before you can save the file
  documentViewer.addEventListener('documentLoaded', async () => {
    const documentStream = await documentViewer.getDocument().getFileData({});
    const documentBlob = new Blob([documentStream], { type: 'application/pdf' });

    // Example function that saves a blob to the server
    saveBlobToServer(documentBlob);
  })

});