Hi Aspose Team,
one of our customers reported an issue with setting the document protection. We use ProtectionType.AllowOnlyFormFields
as protection type.
I already did some analysis with the document they provided and noticed some strange behaviours.
- The error also occurs if you replace all document content
- If you are using MS Word itself to protect the document (only allowing fields) the protection works fine.
- If you add protection using MS Word, remove protection and save the document, Aspose.Words does not fail any more
I attached the documents for you:
input.docx: Original word document which fails (only content is replaced)
input2.docx: Original word document but it has been protected and unprotected via MS Word once
out.docx: Output document of input.docx generated by Aspose with the following code
out2.docx: Output document of input2.docx generated by Aspose with the following code
var doc = new Document(@"S:\input.docx");
doc.Protect(ProtectionType.AllowOnlyFormFields);
doc.Save(@"S:\out.docx", SaveFormat.Docx);
doc = new Document(@"S:\input2.docx");
doc.Protect(ProtectionType.AllowOnlyFormFields);
doc.Save(@"S:\out2.docx", SaveFormat.Docx);
As word can set a protection on the input.docx I would expect Aspose to be able, too, so I I hope you can provide a fix for this. I also would appreciate if you can tell what is causing this issue (or may have damaged the original document) so we may give our customers a hint what they maybe have done wrong to destroy the document and avoid such issues in future.
Kind Regards,
Daniel
documents.zip (51.3 KB)