Open files from file system, sign, download and share pdf via mail

Hi,

Once you have uploaded a file using Axios you can set a file using instance.loadDocument() API. This API expects a string to the file path or a Blob. You can read this guide here for more information: PDF.js Express Viewer Integration Best Practices | Documentation

Using our react sample, which uses hooks, you could have the current file be a state variable and have a useEffect hook that loads the new document on file state change like so:

useEffect( () => {
  if(file) {
   instance.loadDocument(file);
  }
},[file])

To download a pdf with a signature, you will need to merge the annotation XFDF data into the PDF. You can do so using our Rest Utility package. Here is a guide using our Rest Utility package and the npm package file-saver to download the file:

https://pdfjs.express/api/utils/tutorial-Adding%20a%20download%20button.html

Once you have merged the file data, you can download it using the example above or use another service to email the merged file.

Cheers,
Dustin

1 Like