The document is not getting opened in lower version(MS word below 2010)
Clients are not ready to upgrade MS word.
Kindly let me know is there any alternate to open the doc created by docx4j in lower version itself.
Please assit on the above
String stringFromFile = FileUtils.readFileToString(new File(destFolder
+ "/" + xhtmlFileName), "UTF-8");
WordprocessingMLPackage docxOut = WordprocessingMLPackage
.createPackage();
AlternativeFormatInputPart afiPart = new AlternativeFormatInputPart(
new PartName("/hw.html"));
afiPart.setBinaryData(stringFromFile.getBytes());
afiPart.setContentType(new ContentType("text/html"));
Relationship altChunkRel = docxOut
.getMainDocumentPart().addTargetPart(
afiPart);
// .. the bit in document body
CTAltChunk ac = Context.getWmlObjectFactory()
.createCTAltChunk();
ac.setId(altChunkRel.getId());
docxOut.getMainDocumentPart().addObject(ac);
// .. content type
docxOut.getContentTypeManager()
.addDefaultContentType("html", "text/html");
customizeDocx(docxOut);
MainDocumentPartMceIgnorableHelper mdhelper=new MainDocumentPartMceIgnorableHelper();
Document wmlDocumentEl = (Document) docxOut.getMainDocumentPart()
.getContents();
Body body = wmlDocumentEl.getBody();
mdhelper.getMceIgnorable(body);
docxOut.save(new File(destFolder + "/" + docxFileName));
Users browsing this forum: No registered users and 61 guests