Error 504 trying to merge xfdf - Urgent

Which product are you using?

PDF.js Express Version
8.4.0

Detailed description of issue
Trying to merge form data into a PDF which has had form data merged into it multiple times in the past fails with error 504 from https://api.pdfjs.express/xfdf/merge

Does your issue happen with every document, or just one?
Every document once a certain amount of past merges have happened

Link to document
Copy of PDF being edited, XML payload sent with merge request, and an entire cURL bash command pulled from the dev tools for the failed request:
https://wyliesystems-my.sharepoint.com/:f:/g/personal/r_ewen_wyliesystems_ca/EkcJbZw3grpHsib8tKmz-bgB-r_maSTbVrBV_LNjxp5MgA?e=1sPPYD

Code
We’re using pdfjs-express-utils 1.3.1

    const get_blob = async () => {
        const fileData = await viewer.docViewer.getDocument().getFileData({})
        const xfdf = await viewer.annotManager.exportAnnotations({})
        const resp = await viewer_utils
            .setFile(fileData)
            .setXFDF(xfdf)
            .merge()

        return await resp.getBlob()
    }

Hello, I’m Ron, an automated tech support bot :robot:

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

Guides:APIs:Forums:

Hey there,

Thanks for the report - we will investigate and back to you with any news.

Logan

OK thanks Logan, it’s fairly critical to us, as the company that reported the problem is just starting up with our software.

Please reply all to this email if you need any clarification on the problem.

Will.

Outlook-qlxszx3e.png

Hi Logan,

Any progress on this?

Will.

Hi there,

No progress yet, I have not had time to get to this yet. Ill try to have something for you tomorrow or friday.

Logan

That would be much appreciated Logan. We have trained our clients to just edit the pdf and re-save with each change, but after they do this 2 or 3 times, it hangs when they try to open it.

Will.

Hey there!

I unfortunately cannot reproduce your issue no matter how many times I try merging annotations into the document, even with the file and XFDF you sent over.

Are you able to give me access to the environment where you can reproduce this? Are you able to provide exact steps to reproduce?

Thanks,
Logan

Hi Logan - the cURL request given is one of the actual requests that was sent and then returned with error 504. I captured it from the Chrome Developer Tools.

I could PM you login info to reproduce it from in our software if you would like.

Ryan (via Will’s account)

Yes, did you want to set up a video call today so I can show you Logan.

Will.

Hey,

I cannot reproduce your issue even with the exact XML and document you provided.

The only weird thing I see in your request that I don’t see in mine is the thousands of \r in the file’s binary in your request - I am not sure where those are coming from and I don’t see that on my end.

If you could DM me credentials that would be great.

Thanks,
Logan

Hi Logan, I don’t see a way to DM you on here. Could you email r.ewen@wyliesystems.ca ?

Please respond Logan this is a critical items for our customers.

Will

Logan we now have multiple customers with this bug, this is critical for us please respond - you wanted us to DM you credentials and we wanted to know a secure way to do that

Hey there,

I am able to reproduce the problem in your environment but I cannot reproduce the issue on my end still.

A 504 error indicates that the process is timing out which means the operation you’re trying to do is too complex, which usually indicates an issue with the document, form, or the XFDF.

I believe the issue is something to do with the document itself or some kind of customization you have made. If you could send over any other code you are calling to customize the document, form, or XFDF, that would be great. Also, if you could send me the exact document that’s getting sent to the server that would be great (the document you have sent me does not appear to match the document I see in your environment).

Thanks!
Logan

Thanks Logan! I’m handing this over to Ryan to respond.

Will.

Outlook-qlxszx3e.png

Hi Logan, this is Ryan - I emailed you a link which demonstrates the issue with minimal code (and the code can be viewed by inspecting the page).

As of just a few moments I have updated the link so if you have taken a look at it between receiving the email and now, please disregard what you saw earlier.

What you will see when going to the link now is that PDF JS Express loads a PDF that our customer uses as a template. This PDF is fresh from Acrobat, never run through PDF Express JS before. Once PDF JS Express loads up, press the Save button at the bottom. A new Blob will be generated using the PDF JS Express API, and if successful, PDF JS Express will close and the new Blob will be loaded into a new PDF JS Express instance. Repeat the process. Each time the new Blob is loaded, press Save again, and after 2-3 iterations you will notice that it stops working due to the 504 error.

Thanks for taking a look

  • Ryan

Hey guys,

Just letting you know that I can finally reproduce your issue on my end. I’ll investigate and get back to you ASAP. Thanks for setting up that environment for me and thanks for your patience.

Logan

OK that’s good news, we are desperate to get this fixed Logan.

Hey guys,

Update - this is a pretty complex problem that we’re not sure the root cause of at the moment. I’m working with our core team to try and find a solution but it might be a while before we find a good fix.

As a temporary solution, you can try using the set endpoint instead of merge - this should resolve the problem. The only side effect is that any annotations that are baked into the document that you are not extracting will be removed (since set replaces all the annotations on the document with the XFDF you provide). I would give it a try and see if it works for you for now.

Thanks!
Logan