public class ProtectionType
Example:
Document doc = new Document();
// Insert two sections with some text
DocumentBuilder builder = new DocumentBuilder(doc);
builder.writeln("Section 1. Unprotected.");
builder.insertBreak(BreakType.SECTION_BREAK_CONTINUOUS);
builder.writeln("Section 2. Protected.");
// Section protection only works when document protection is turned and only editing in form fields is allowed
doc.protect(ProtectionType.ALLOW_ONLY_FORM_FIELDS);
// By default, all sections are protected, but we can selectively turn protection off
doc.getSections().get(0).setProtectedForForms(false);
doc.save(getArtifactsDir() + "Section.Protect.docx");
Field Summary | ||
---|---|---|
static final int | ALLOW_ONLY_COMMENTS | |
User can only modify comments in the document.
|
||
static final int | ALLOW_ONLY_FORM_FIELDS | |
User can only enter data in the form fields in the document.
|
||
static final int | ALLOW_ONLY_REVISIONS | |
User can only add revision marks to the document.
|
||
static final int | READ_ONLY | |
No changes are allowed to the document. Available since Microsoft Word 2003.
|
||
static final int | NO_PROTECTION | |
The document is not protected.
|
public static final int ALLOW_ONLY_COMMENTS
public static final int ALLOW_ONLY_FORM_FIELDS
public static final int ALLOW_ONLY_REVISIONS
public static final int READ_ONLY
public static final int NO_PROTECTION