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);




Sharing Java Code

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Asynchronous Messaging Patterns for Microservices

how mastering basic will unlock surprisingly a lot of things for us.

Mono-microservices Hybrid Architecture

RoadToWebDev Day#2 — HTTP/HTTPS and APIs

Create your multiboot USB key using Syslinux

How to hide the source code of an HTML web page?

Group by weeks in SQL Server

ECM vs. CMS: Similarities and Differences Explained

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
Andrew Wilson

Andrew Wilson

Sharing Java Code

More from Medium

Bootstrap your application to use Hilt

Git and GitHub

Best Practices of REST API endpoint design

Browser Automation for Everyone: Free Tools You Can Use RIGHT NOW To Get Work Done Fast