Page 1 of 1

how can i get protection mode?

PostPosted: Thu Mar 30, 2017 4:44 pm
by eoikj
i need to get current protection mode from a docx file.
if the file is protected with STDocProtect.FORMS then delete all comments.
but each time i execute those code it returns null.

Code: Select all
    public static STDocProtect getProtectionType(MainDocumentPart mdp) throws Docx4JException {
        DocumentSettingsPart ds = mdp.getDocumentSettingsPart();
        CTSettings cs = ds.getContents();
        CTDocProtect cp = cs.getDocumentProtection();       
        return cp.getEdit();
    }


how can i do this correctly?

Re: how can i get protection mode?

PostPosted: Sun Apr 02, 2017 8:45 am
by jason
That is to be expected if it is not set in the input docx.

So to start with, please manually check that it is set: unzip the docx and inspect the relevant settings part.