# RestAPI Failing when document size \> 100MB

**URL:** <https://pdfjs.community/t/restapi-failing-when-document-size-100mb/3330>\
**Category:** Technical Support\
**Tags:** pdfjs-express\
**Created:** [June 26, 2024, 6:39am UTC](https://pdfjs.community/t/restapi-failing-when-document-size-100mb/3330 "2024-06-26T06:39:57Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![retrotech](https://avatars.discourse-cdn.com/v4/letter/r/a9a28c/32.png) [@retrotech](https://pdfjs.community/u/retrotech)\
**Post date:** [June 26, 2024, 6:39am UTC](https://pdfjs.community/t/restapi-failing-when-document-size-100mb/3330/1 "2024-06-26T06:39:57Z")

</div>

**Which product are you using?**  
PDF.js Express Plus - REST API

**PDF.js Express Version**  
N/A

**Detailed description of issue**  
Error “Failed to fetch” received when linking a 100mb+ file.

**Does your issue happen with every document, or just one?**  
Issue occurs when the document size \> 100mb

**Code snippet**

```javascript
let xfdfString = '' //Actual XFDF XML
const utils = new ExpressUtils({
  serverKey: 'key',
  clientKey: 'key'
})
utils
  .setFile('http://someurl.com')
  .setXFDF(xfdfString);
(async function () {
  try {
    const response = await utils.merge();  
    const mergedFile = await response.getBlob();
    let file = new File([mergedFile], fileName, {lastModified: new Date().getTime(), type: mergedFile.type})
    let url = window.URL.createObjectURL(file);
    let tempLink = document.createElement('a');
    tempLink.href = url;
    tempLink.setAttribute('download', fileName);
    tempLink.click();
  } catch (e) {
    LoaderService.setData(false)
    return alert(e.message)
  }
})()

```

---

<div class="post-metadata">

**Author:** ![kkim](https://avatars.discourse-cdn.com/v4/letter/k/3ab097/32.png) [@kkim](https://pdfjs.community/u/kkim)\
**Post date:** [June 26, 2024, 3:00pm UTC](https://pdfjs.community/t/restapi-failing-when-document-size-100mb/3330/3 "2024-06-26T15:00:13Z")

</div>

Hi there,

What is the error message you are getting from the response? Are you getting any errors in the console?  
Can you share the URL for us to take a look?

Best regards,  
Kevin Kim

---

<div class="post-metadata">

**Author:** ![retrotech](https://avatars.discourse-cdn.com/v4/letter/r/a9a28c/32.png) [@retrotech](https://pdfjs.community/u/retrotech)\
**Post date:** [June 27, 2024, 12:26pm UTC](https://pdfjs.community/t/restapi-failing-when-document-size-100mb/3330/4 "2024-06-27T12:26:07Z")

</div>

Link to document: [LINK](http://141.95.97.208:2109/_Temp/0389bef9-6320-49b5-b4ac-9011bea6f5bb/Files/ESS01%20V01%20TNK%20RPO%200001%20Rev%20B%20IRN%20and%20Mill%20test%20certificates.pdf)

Error in console: `POST https://api.pdfjs.express/xfdf/merge net::ERR_FAILED 502 (Bad Gateway)`

The above error is only when the file size is higher.

---

<div class="post-metadata">

**Author:** ![kkim](https://avatars.discourse-cdn.com/v4/letter/k/3ab097/32.png) [@kkim](https://pdfjs.community/u/kkim)\
**Post date:** [June 27, 2024, 5:24pm UTC](https://pdfjs.community/t/restapi-failing-when-document-size-100mb/3330/5 "2024-06-27T17:24:11Z")

</div>

Hi there,

This may be due to the complexity of the document itself, when loading this document on pdf.js express, and scrolling to the bottom of the document, this puts a heavy workload on the viewer and results in an error message regarding memory:

 ![image](https://canada1.discourse-cdn.com/flex031/uploads/pdfjscommunity/original/2X/2/2e4de08c806df7ea2c25029c0ae0a5df3ea1cfd4.jpeg)

Best regards,  
Kevin Kim

---

<div class="post-metadata">

**Author:** ![retrotech](https://avatars.discourse-cdn.com/v4/letter/r/a9a28c/32.png) [@retrotech](https://pdfjs.community/u/retrotech)\
**Post date:** [June 28, 2024, 6:29am UTC](https://pdfjs.community/t/restapi-failing-when-document-size-100mb/3330/6 "2024-06-28T06:29:01Z")

</div>

So how can this issue be resolved?

---

<div class="post-metadata">

**Author:** ![kkim](https://avatars.discourse-cdn.com/v4/letter/k/3ab097/32.png) [@kkim](https://pdfjs.community/u/kkim)\
**Post date:** [June 28, 2024, 3:25pm UTC](https://pdfjs.community/t/restapi-failing-when-document-size-100mb/3330/7 "2024-06-28T15:25:15Z")

</div>

We can definitely add this to the backlog to investigate, but we also recommend potentially switching to our new WebViewer-ecommerce platform: [WebViewer: JavaScript Document SDK | Apryse](https://apryse.com/products/webviewer)

Best regards,  
Kevin Kim
