public class ProtectionType
extends java.lang.Object
Examples:
Shows how to turn off protection for a section.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.writeln("Section 1. Hello world!");
builder.insertBreak(BreakType.SECTION_BREAK_NEW_PAGE);
builder.writeln("Section 2. Hello again!");
builder.write("Please enter text here: ");
builder.insertTextInput("TextInput1", TextFormFieldType.REGULAR, "", "Placeholder text", 0);
// Apply write protection to every section in the document.
doc.protect(ProtectionType.ALLOW_ONLY_FORM_FIELDS);
// Turn off write protection for the first section.
doc.getSections().get(0).setProtectedForForms(false);
// In this output document, we will be able to edit the first section freely,
// and we will only be able to edit the contents of the form field in the second section.
doc.save(getArtifactsDir() + "Section.Protect.docx");
| Modifier and Type | Field and Description |
|---|---|
static int |
ALLOW_ONLY_COMMENTS
User can only modify comments in the document.
|
static int |
ALLOW_ONLY_FORM_FIELDS
User can only enter data in the form fields in the document.
|
static int |
ALLOW_ONLY_REVISIONS
User can only add revision marks to the document.
|
static int |
length |
static int |
NO_PROTECTION
The document is not protected.
|
static int |
READ_ONLY
No changes are allowed to the document.
|
| Modifier and Type | Method and Description |
|---|---|
static int |
fromName(java.lang.String protectionTypeName) |
static java.lang.String |
getName(int protectionType) |
static int[] |
getValues() |
static java.lang.String |
toString(int protectionType) |
public static int ALLOW_ONLY_COMMENTS
public static int ALLOW_ONLY_FORM_FIELDS
public static int ALLOW_ONLY_REVISIONS
public static int READ_ONLY
public static int NO_PROTECTION
public static int length