API https://api.pdfjs.express/xfdf/extract takes too long to respond and returns an error

Which product are you using?
PDF.js Express Plus

PDF.js Express Version

Detailed description of issue
I am using pdf.js express plus with angular.
It very often happens (around 80-90% of the time) that the API https://api.pdfjs.express/xfdf/extract takes too long to respond and returns an error:

Since I always worked on only one document and since it has never been edited, I assumed that the problem was coming from the API, especially because occasionally it works.

Expected behaviour
The request should return a valid response or at least include a more descriptive error text.

Does your issue happen with every document, or just one?
As previously stated, I only worked with a document, that is the demo.pdf from the angular project sample.

Link to document

Code snippet

The code I used for calling the endpoint is the same as the one on the tutorial page.

The only difference is that the file does not come from a path, but from a blob file:

Hi m.curatitoli,

I followed the angular sample repository GitHub - pdfjs-express/pdfjs-express-angular-sample and setup the extract API Extract XFDF using the Express REST API | Documentation
and I was able to get the annotations loaded in the console:

I will need additional details to further troubleshoot:

  1. Are you able to reproduce the error if you use the API without the utils (similar to above screenshot)
  2. Do you have server/client keys setup? PDF.js Express Utils Home
  3. Are you able to reproduce this error if the file was loaded from a path rather than a blob file?
  4. Are you able to find out which error code the API returns: PDF.js Express API Errors | Documentation

Best Regards,

Kevin Kim
Web Development Support Engineer
PDFTron Systems, Inc.

Hi kkim,

Thank you for your quick response.
Since I cannot upload more than one media file at a time, I will answer in 3 steps.

  1. I used the API without utils but the same error is returned

  2. Yes, I generated the keys and added them correctly.

  1. I tried to create the file and open it from a local path, but it gives me another error ({“error”:{“code”:21,“message”:“Cannot retrieve file from URL.”}}), even though the file gets initially loaded in the document:

Some other useful information:

  1. I am working in a local environment (localhost).
  2. The file I generated for the question 3. is served by the back-end that runs in localhost.
  1. The problem is that the API does not return any error:

Thank you for the support,
I hope to have provided enough information.

Hi there,

I tried reproducing your issue with the code you provided and unfortunately cannot reproduce either. Here is the code I used:

instance.Core.documentViewer.addEventListener('documentLoaded', async () => {
     const fileData = await documentViewer.getDocument().getFileData({});
     const blob = new Blob([fileData], {type: 'application/pdf'})

     const data = new FormData();
     data.append("file", blob);

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

    const { xfdf } = response;

The error you are seeing is “ERR_CONNECTION_RESET” which indicates this is an issue on your end, most likely with your network. Are you using a VPN, proxy for firewall that might be interfering with requests? Do you have any chrome extensions that might be blocking requests?


Hello Logan,

I tried to switch the network to the personal hotspot and the export worked.
The problem was most likely due to our firm’s firewall.
Can I ask you which port is used by your server, in order to enable it by configuration?

Thank you very much for the debugging,

Hi Mattia,

You can use Port 443 (HTTPS) to connect.

Best Regards,

Kevin Kim
Web Development Support Engineer
PDFTron Systems, Inc.