I have a Word file (in docx format) with restricted editing and password settings. Some of the content can be edited, but when ASPose reads it and saves it again, the password for the restricted editing of the new file is lost. sdk version:aspose-words-19.4-jdk17.jar。The code example is as follows:
Document doc = new Document("input.docx");
doc.save("output.docx", SaveFormat.DOCX);
When working with Word documents that have restricted editing and password settings, it’s important to note that Aspose.Words allows you to protect documents and specify passwords. However, if you are experiencing issues where the password for restricted editing is lost after saving the document, you may need to explicitly set the protection again after loading the document.
Here’s how you can do it:
Load the document.
Set the protection type and specify the password.
Save the document.
Here’s a code example that demonstrates this:
import com.aspose.words.Document;
import com.aspose.words.ProtectionType;
public class ProtectDocumentExample {
public static void main(String[] args) throws Exception {
// Load the document
Document doc = new Document("input.docx");
// Protect the document with a password
doc.protect(ProtectionType.AllowOnlyFormFields, "your_password_here");
// Save the document
doc.save("output.docx");
}
}
In this example, replace "your_password_here" with the actual password you want to use for restricted editing. This should help retain the password settings when saving the document again.
If you continue to face issues, consider checking the version of Aspose.Words you are using, as there may have been updates or bug fixes in later versions that address this behavior.
But I don’t know the password that restricts editing in Word. After processing with ASPose, the password that restricts editing has been removed, which poses a great risk
@leocao Thank you for additional information. Unfortunately, I cannot reproduce the problem on my side using the latest 24.9 version of Aspose.Words and the following simple code:
Document doc = new Document("C:\\Temp\\in.docx");
doc.save("C:\\Temp\\out.docx", SaveFormat.DOCX);
The output document has the same restrictions as the input document. Here is the output document produced on my side: out.docx (17.6 KB)
No, no, there is also a problem with the file you generated. Clicking on “Protect Document” in Word can unlock editing restrictions without entering a password. The original text required a password to remove editing permissions
@leocao
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): WORDSNET-27395
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
Thanks! Have you confirmed that the bug has been handled by the current APS? How long does it take to provide feedback on the internal problem investigation cycle.
@leocao We have managed to reproduce the problem on our side. The issue is currently in the queue for analysis. Unfortunately, at the moment is is difficult how long it might take to fix the problem. We will keep you update and let you know once the issue is resolved or we have more information for you.