Hi
Please help me or share me the code which i can use to add HTML content example
<html><body><h1>Test1</h1><br/><p>TestTest</p></body></html> to a docx file.
Thanks!
// Add an altChunk
// .. the part
String html = "<html><head><title>Import me</title></head><body><p>Hello World!</p></body></html>";
AlternativeFormatInputPart afiPart = new AlternativeFormatInputPart(new PartName("/hw.html") );
afiPart.setBinaryData(html.getBytes());
afiPart.setContentType(new ContentType("text/html"));
Relationship altChunkRel = wordMLPackage.getMainDocumentPart().addTargetPart(afiPart);
// .. the bit in document body
CTAltChunk ac = Context.getWmlObjectFactory().createCTAltChunk();
ac.setId(altChunkRel.getId() );
wordMLPackage.getMainDocumentPart().addObject(ac);
// .. content type
wordMLPackage.getContentTypeManager().addDefaultContentType("html", "text/html");
//injectDocPropsCustomPart(wordMLPackage);
Users browsing this forum: Bing [Bot], Google [Bot] and 70 guests