# Merge XFDF and file data gets error with large file

**URL:** <https://pdfjs.community/t/merge-xfdf-and-file-data-gets-error-with-large-file/767>\
**Category:** Technical Support\
**Tags:** pdfjs-express\
**Created:** [May 14, 2021, 6:59am UTC](https://pdfjs.community/t/merge-xfdf-and-file-data-gets-error-with-large-file/767 "2021-05-14T06:59:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Steven](https://avatars.discourse-cdn.com/v4/letter/s/94ad74/32.png) [@Steven](https://pdfjs.community/u/Steven)\
**Post date:** [May 14, 2021, 6:59am UTC](https://pdfjs.community/t/merge-xfdf-and-file-data-gets-error-with-large-file/767/1 "2021-05-14T06:59:46Z")

</div>

```
// Get the annotations and the documents data
var xfdf = await instance.annotManager.exportAnnotations({ links: false, widgets: false });
var fileData = await instance.docViewer.getDocument().getFileData({});
// Set the annotations and document into the Utility SDK, then merge them together
var resp = await utils.setFile(fileData).setXFDF(xfdf).merge();
// Get the resulting blob from the merge operation
var mergedBlob = await resp.getBlob();

```

This is my code to merge XFDF and file data  
It’s work properly with small files but when I select large size file (19 MB) It is not working, throws an error.

 ![image](https://canada1.discourse-cdn.com/flex031/uploads/pdfjscommunity/original/1X/44e6a4bb1f5c065e50b3539bb33ffbb5217b86ae.png)

I also tried with API which gives below error

 ![Annotate API Error](https://canada1.discourse-cdn.com/flex031/uploads/pdfjscommunity/original/1X/9f38446b0f5639527e23247c1e42c05532b26a5d.png)

Please Provide solution for this.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex031/uploads/pdfjscommunity/original/1X/ffbcd25c7d423db8d5acd5db201c272f4db306dd.png) [@system](https://pdfjs.community/u/system)\
**Post date:** [May 14, 2021, 6:59am UTC](https://pdfjs.community/t/merge-xfdf-and-file-data-gets-error-with-large-file/767/2 "2021-05-14T06:59:49Z")

</div>

**Hello, I’m Ron, an automated tech support bot 🤖**

While you wait for one of our customer support representatives to get back to you, please check out some of these documentation pages:

Guides:
- [Set XFDF using the Express REST API - Body params](https://pdfjs.express/documentation/utils/set#body-params)
- [Import and export annotations using a database](https://pdfjs.express/documentation/annotation/import-export/database)
- [Import & export annotations](https://pdfjs.express/documentation/annotation/import-export/overview)

APIs:
- [ExternalAnnotationMerger - getTransformFunction()](https://pdfjs.express/api/ExternalAnnotationMerger.html#getTransformFunction__anchor)
- [Annotations - setCustomSerializeHandler(annotationClass, serializeHandler)](https://pdfjs.express/api/Annotations.html#.setCustomSerializeHandler__anchor)
- [CoreControls.DocumentViewer - setDocumentXFDFRetriever(retriever)](https://pdfjs.express/api/CoreControls.DocumentViewer.html#setDocumentXFDFRetriever__anchor)

Forums:
- [Merging XFDF using the Express REST API length exceeded error](https://pdfjs.community/t/merging-xfdf-using-the-express-rest-api-length-exceeded-error/185/2)
- [How to set Note(‘stickyToolGroupButton’) annotation to custom button](https://pdfjs.community/t/how-to-set-note-stickytoolgroupbutton-annotation-to-custom-button/208/1)
- [Xpdf merger bot working for large files](https://pdfjs.community/t/xpdf-merger-bot-working-for-large-files/581/1)

---

<div class="post-metadata">

**Author:** ![driley](https://avatars.discourse-cdn.com/v4/letter/d/13edae/32.png) [@driley](https://pdfjs.community/u/driley)\
**Post date:** [May 14, 2021, 5:17pm UTC](https://pdfjs.community/t/merge-xfdf-and-file-data-gets-error-with-large-file/767/3 "2021-05-14T17:17:03Z")

</div>

Hi Steven,

The max request size for the API is 5.5MB, which is why that error is happening. If you want to merge PDFs larger than that, you will have to upload them to a server (Amazon S3 for example) and provide a URL to the PDF instead of sending the raw data.

Cheers,  
Dustin

---

<div class="post-metadata">

**Author:** ![Steven](https://avatars.discourse-cdn.com/v4/letter/s/94ad74/32.png) [@Steven](https://pdfjs.community/u/Steven)\
**Post date:** [May 18, 2021, 3:51am UTC](https://pdfjs.community/t/merge-xfdf-and-file-data-gets-error-with-large-file/767/4 "2021-05-18T03:51:35Z")

</div>

This worked. I was able to use this API [PDF.js Express Utils Home](https://pdfjs.express/api/utils/)

Thank you.

---

<div class="post-metadata">

**Author:** ![driley](https://avatars.discourse-cdn.com/v4/letter/d/13edae/32.png) [@driley](https://pdfjs.community/u/driley)\
**Post date:** [May 18, 2021, 4:47pm UTC](https://pdfjs.community/t/merge-xfdf-and-file-data-gets-error-with-large-file/767/5 "2021-05-18T16:47:53Z")

</div>


