If you would like to merge XFDF client-side and not use the REST API, PDFTron’s WebViewer can perform merging without any server-side dependencies.
PDFTron’s WebViewer uses PDFTron’s proprietary rendering engine, without reliance on open-source technologies and allows for more advanced capabilities like flattening annotations directly in a browser.
Please follow the guide to migrate to PDFTron’s WebViewer.
Once you have PDFTron’s WebViewer up and running you can reference the guide for flattening annotations.