Hi,
Aspose library : Aspose-words-15.9
Microsoft Office 2013.
I’m working with file protect against modification with password. I have just upgraded Aspose library from 14.5 to 15.9.
Since I have upgraded the library, when I create a file with Aspose, I’ve got a problem with the password: I can’t unprotect the file. The password seems to have changed. Even if I lock the file with code, the password is still incorrect.
Here is the simple test code to reproduce the problem: The password is test:
public static void main(String[] args) {
try {
License license = new License();
license.setLicense(“Aspose.Total.Java.lic”);
String fileName = “D:\ASPOSETEST\blankmodel.docx”;
Document doc = new Document(fileName);
replacePlaceHolderText(doc);
} catch (Exception e) {
System.err.print(e);
}
}
public static void replacePlaceHolderText(Document doc) throws Exception {
String destFile = “D:\ASPOSETEST\asposefilledmodel.docx”;
DocumentBuilder builder = new DocumentBuilder(doc);
NodeCollection sdtNodes = doc.getChildNodes(NodeType.STRUCTURED_DOCUMENT_TAG, true);
Iterator it = sdtNodes.iterator();
while (it.hasNext()) {
StructuredDocumentTag sdt = (StructuredDocumentTag) it.next();
Run run = (Run) sdt.getChild(NodeType.RUN, 0, true);
if (run != null) {
run.setText(“Hello”);
}
}
// doc.unprotect();
// doc.protect(ProtectionType.READ_ONLY, “test”);
doc.save(destFile);
}
Thank you for your help.