Thank you for the snippet, @asad.ali.
The code snippet you provided seems to be for the .Net version. I forgot to specify that I was using the Java version, my apologies.
I took the snippet and rewrote it in Java, and added
contentEditor.save(fileName) at the end, to save the changes to a file, and it worked.
However, I tried using
contentEditor.save(contentEditor.getDocument().getFileName()) to save the changes to the same file, but doing so gets me this error when I try to open the file in Adobe Acrobat Reader:
Screenshot 2021-08-24 153106.png (9.1 KB)
Note that this issue only happens when I save the changes to the same file, using
contentEditor.save(contentEditor.getDocument().getFileName()). It does not occur when I save the changes to a new file. Do you have any idea why this issue might be occurring?