Hey there! Thanks for your interest in PDF.js Express.
PDF form data and annotations are serialized in XFDF format, which is just a XML like string that can imported/exported into the viewer.
To export the annotations into a XFDF string, you can use the exportAnnotations API.
WebViewer({...options}, ele).then(instance => {
const { annotManager, docViewer } = instance;
// Call this when you want to save
const saveAnnots = async () => {
const xfdfString = await annotManager.exportAnnotations();
// send XFDF to server for saving via AJAX here
}
})
Later on, to load those form fields, you can simply call importAnnotations.
WebViewer({...options}, ele).then(instance => {
const { annotManager, docViewer } = instance;
docViewer.on('documentLoaded', async () => {
// load XFDF string from server here
const xfdf = await fetchXFDFFromServer();
await annotManager.importAnnotations(xfdf);
})
})
If you have any more questions feel free to let me know.
Thanks,
Logan