Lock Headers and footers in word

Hi,

We have custom document properties inserted into the word (2013 & 2016) header & footer. We want to lock it down so end users don’t accidentally delete them because we are updating them through out the approval process. I’d there a way we can lock the headers and footers using ASPOSE but still able to update the properties programmatically?
Thanks and appreciate it
Mahesh

Hi Mahesh,


Thanks for your inquiry. EditableRangeStart class represents a start of an editable range in a Word document. EditableRangeEnd class represents an end of an editable range in a Word document.

A complete editable range in a Word document consists of a EditableRangeStart and a matching EditableRangeEnd with the same Id. EditableRangeStart and EditableRangeEnd are just markers inside a document that specify where the editable range starts and ends.

Following code example shows how to protect header and footer of first section of document. Hope this helps you.

<pre style=“background-color: rgb(255, 255, 255); font-family: “Courier New”; font-size: 9pt;”>Document doc = new Document(MyDir + “in.docx”);
doc.protect(ProtectionType.READ_ONLY);

DocumentBuilder builder = new DocumentBuilder(doc);
builder.moveToParagraph(0, 0);
builder.startEditableRange();
builder.moveToParagraph(doc.getFirstSection().getBody().getParagraphs().getCount() -1, -1);
builder.endEditableRange();

doc.save(MyDir + “Out.docx”);

A post was split to a new topic: Lock Header and Footer of document