Java/Set Editing Restrictions in Word

import com.spire.doc.Document;
import com.spire.doc.FileFormat;
import com.spire.doc.ProtectionType;

public class RestrictEditing {
public static void main(String[] args){
//Create a Document instance
Document document = new Document();
//Load the Word document
document.loadFromFile("Input 1.docx");

//No changes (Read only)
document.protect(ProtectionType.Allow_Only_Reading, "123456");

//Allow only comments
//document.protect(ProtectionType.Allow_Only_Comments, "123456");

//Allow only filling in forms
//document.protect(ProtectionType.Allow_Only_Form_Fields, "123456");

//Allow only tracked changes
//document.protect(ProtectionType.Allow_Only_Revisions, "123456");

//Save the result document
document.saveToFile("RestrictEditing.docx", FileFormat.Docx_2013);



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store