Free Support Forum - aspose.com

DocumentProtection.Edit equivalent API in Aspose.Words for Java

Hey,

how can I access this OpenXml.Wordprocessing.DocumentProtection.Edit with Aspose for Word Java to set his value?

Thank you!

@urdasdaniel

Please read the following article about protecting and unprotecting documents
Protecting Documents

Moreover, the EditableRange class represents a single editable range. EditableRange is a “facade” object that encapsulates two nodes EditableRangeStart and EditableRangeEnd in a document tree and allows to work with an editable range as a single object.

You need to add EditableRangeStart and EditableRangeEnd nodes into document that you want to edit and protect the document using Document.Protect method.

Following code example shows how to make the document as read only except the second paragraph.

Document doc = new Document(MyDir + "in.docx");
doc.Protect(ProtectionType.ReadOnly);

DocumentBuilder builder = new DocumentBuilder(doc);
builder.MoveToParagraph(1, 0);
builder.StartEditableRange();
builder.MoveToParagraph(1, -1);
builder.EndEditableRange();

doc.Save(MyDir + "Out.docx");