We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Protected

Hi everyone,

My name is Evelyn I’d like to buy the aspose words lib, and I have a question…

I have a document and this document is totally unblocked, I’d like to block only some parts of this. Is there some feature in aspose words that I can use to solve this problem ?

Thank you for the help.

@evelynAlves You can mark part of document content in the document as editable, this is called editable range in MS Word. You can create editable ranges in documents using DocumentBuilder.startEditableRange and DocumentBuilder.EndEditableRange. For example see the following code:

Document doc = new Document();
doc.protect(ProtectionType.READ_ONLY, "MyPassword");

DocumentBuilder builder = new DocumentBuilder(doc);
builder.writeln("Hello world! Since we have set the document's protection level to read-only," +
        " we cannot edit this paragraph without the password.");

// Editable ranges allow us to leave parts of protected documents open for editing.
builder.startEditableRange();
builder.writeln("This paragraph is inside an editable range, and can be edited.");
builder.endEditableRange();

builder.writeln("This paragraph is outside the editable range, and cannot be edited.");

doc.save("C:\\Temp\\out.docx");

Also, in case of SDT, you can use StructuredDocumentTag.LockContents to prohibit a user from editing the contents of this SDT.