Verify the Restrict Editing Password of a Word Document in Java

This article demonstrates how to verify if the restrict editing password of a Word document is correct using Spire.Doc for Java.

import com.spire.doc.Document;

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

        //Verify if the password is valid
        boolean result = document.checkProtectionPassWord("123");

        if(!result) {
            System.out.println("Oops! The password is invalid.");
        }
        else {
            System.out.println("Congrats! The password is valid.");
        }
    }
}

Output:

Verify the Restrict Editing Password of a Word Document in Java