# Internal server error

**URL:** <https://pdfjs.community/t/internal-server-error/113>\
**Category:** Technical Support\
**Created:** [July 6, 2020, 4:46am UTC](https://pdfjs.community/t/internal-server-error/113 "2020-07-06T04:46:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jithinkp](https://avatars.discourse-cdn.com/v4/letter/j/ecae2f/32.png) [@jithinkp](https://pdfjs.community/u/jithinkp)\
**Post date:** [July 6, 2020, 4:46am UTC](https://pdfjs.community/t/internal-server-error/113/1 "2020-07-06T04:46:30Z")

</div>

I have implemented merge api ,It working fine 1 page pdf and small size pdf bleow 1MB. Unfortunately above 1 mb or more page pdf getting error.

```
WebViewer({
    disableFlattenedAnnotations: true,
    path: 'lib', // path to the PDFTron 'lib' folder on your server
    licenseKey: 'Insert license key here', // optional
    // initialDoc: 'https://pdftron.s3.amazonaws.com/downloads/pl/webviewer-demo.pdf',
    initialDoc: 'test2.pdf', // You can also use documents on your server
}, document.getElementById('viewer'))
    .then(function(instance) {
        var docViewer = instance.docViewer;
        var annotManager = instance.annotManager;

        instance.setHeaderItems(function(header) {
            header.push({
                type: 'actionButton',
                img: '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M0 0h24v24H0z" fill="none"/><path d="M17 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V7l-4-4zm-5 16c-1.66 0-3-1.34-3-3s1.34-3 3-3 3 1.34 3 3-1.34 3-3 3zm3-10H5V5h10v4z"/></svg>',
                onClick: function() {

                    onSave();
                    async function onSave() {

                        var xfdf = await annotManager.exportAnnotations({ links: false, widgets: false });
                        var fileData = await docViewer.getDocument().getFileData({});
                        var blob = new Blob([fileData], {type: 'application/pdf'});

                        var data = new FormData();
                        data.append('xfdf', xfdf);
                        data.append('file', fileData);
                        data.append('file', blob);
                        data.append('license', '');

                        // Process the file
                        var response = await fetch('https://api.pdfjs.express/xfdf/merge', {
                            method: 'post',
                            body: data
                        }).then(resp => resp.json());

                        var { url, key, id } = response;

                        // Download the file
                        var mergedFileBlob = await fetch(url, {
                            headers: {
                                Authorization: key
                            }
                        }).then(resp => resp.blob())

                        var fd = new FormData();
                        fd.append('fname', 'test.pdf');
                        fd.append('data', mergedFileBlob);
                        var data = new FormData();
                        data.append('mydoc.pdf', mergedFileBlob, 'mydoc.pdf');

                        var req = new XMLHttpRequest();
                        req.open("POST", '/pdf_editor/test/upload.php', true);
                        req.onload = function (oEvent) {
                            // Uploaded.
                        };

                        req.send(data);

                        // Do something with blob...
                        // save(mergedFileBlob)
                    }

                }
            });
        });
    });

```

I have tried1.75 mb pdf file and edit some content and requested to merge api.But i got error .“Internal server error” .Also when i try above 3mb pdf file igot another error HTTP content length exceeded 10485760 bytes.

 ![Annotation 2020-07-04 143948](https://canada1.discourse-cdn.com/flex031/uploads/pdfjscommunity/original/1X/92821353eeaab3bd46b043ef4992db9f2424321b.png)

---

<div class="post-metadata">

**Author:** ![Logan](https://yyz1.discourse-cdn.com/flex031/user_avatar/pdfjs.community/logan/32/13_2.png) [@Logan](https://pdfjs.community/u/Logan)\
**Post date:** [July 6, 2020, 2:07pm UTC](https://pdfjs.community/t/internal-server-error/113/2 "2020-07-06T14:07:01Z")

</div>

Hi there,

Thanks for the info. We will look into the internal server error issue and get back to you when its resolved.

Thanks,  
Logan

---

<div class="post-metadata">

**Author:** ![Logan](https://yyz1.discourse-cdn.com/flex031/user_avatar/pdfjs.community/logan/32/13_2.png) [@Logan](https://pdfjs.community/u/Logan)\
**Post date:** [July 6, 2020, 4:06pm UTC](https://pdfjs.community/t/internal-server-error/113/3 "2020-07-06T16:06:08Z")

</div>

Hi!

You are appending the ‘file’ data twice to your request which will combine `fileData` and `blob` together which is creating invalid (and large) data.

```javascript
data.append('file', fileData); // you can remove this line
data.append('file', blob);

```

Thanks!  
Logan
