I have used below tags to make the file readonly.
document.getWriteProtection().setReadOnlyRecommended(true);
document.protect(ProtectionType.READ_ONLY);
With above property, I’m able to open the file in readonly mode with popup “” the author would like to open this as read-only unless u need to make changes. open as readonly?" . How can i suppress this popup?
@Niki136 This message is shown when you specify document write protection using the following line of code:
doc.getWriteProtection().setReadOnlyRecommended(true);
If you would like to protect document as read-only, you can use the following code:
Document doc = new Document("C:\\Temp\\in.docx");
doc.protect(ProtectionType.READ_ONLY);
doc.save("C:\\Temp\\out.docx");
Thanks @alexey.noskov its working.
Also is there any way to remove “enable Editing” section from top of page?
Actually ,my header dims out if i click on enable editing.
image.png (4.8 KB)
@Niki136 Unfortunately the attached image is not accessible. Could you please reattach it here in the forum. Simply drag and drop the file into the message.
@Niki136 Unfortunately, there is no way to avoid this message. it is shown by MS Word when you open document downloaded from internet due to security reasons.
@alexey.noskov Got you thanks. Also, is it possible to show mouse sign instead of current cursor sign on moving mouse over the text? currently in MS office , i have to click “ctrl + click” to show mouse sign and do redirection. Otherwise its showing as a cursor.
@Niki136 Aspose.Words does not control MS Word UI behavior. Since Aspose.Words works with document files, it can control only setting stored in the document. Cursor appearance is not stored in the document.