using below code
- Code: Select all
String stringFromFile = FileUtils.readFileToString(new File(destFolder
+ "/" + xhtmlFileName), "UTF-8");
WordprocessingMLPackage docxOut = WordprocessingMLPackage
.createPackage();
NumberingDefinitionsPart ndp = new NumberingDefinitionsPart();
docxOut.getMainDocumentPart().addTargetPart(ndp);
ndp.unmarshalDefaultNumbering();
XHTMLImporterImpl XHTMLImporter = new XHTMLImporterImpl(docxOut);
XHTMLImporter.setHyperlinkStyle("Hyperlink");
docxOut.getMainDocumentPart().getContent()
.addAll(XHTMLImporter.convert(stringFromFile, null));
docxOut.save(new java.io.File(destFolder + "/" + docxFileName));
Conversion is success.
Need to create it in protected mode,so using below code
- Code: Select all
DocumentSettingsPart dsp = wordMLPackage.getMainDocumentPart().getDocumentSettingsPart();
ObjectFactory factory = new ObjectFactory();
CTDocProtect protection = factory.createCTDocProtect();
protection.setEdit(STDocProtect.READ_ONLY);
protection.setEnforcement(true);
dsp.getContents().setDocumentProtection(protection);
dsp.getcontent coming as null.Kindly let me know whether i m missing anything