I am using docx4j API's to generate a docx. I am programmatically inserting HTML code in the docx at a given index.
The issue which I am facing is that I want to use 'o.table footnote' style for the paragraph which contains the HTML.
- Code: Select all
Relationship altChunkRel1 = documentTemplate.getMainDocumentPart().addTargetPart(DocumentUtil.showHtml((new String(section.getSectionNotes().toCharArray())), index));
CTAltChunk ac1 = Context.getWmlObjectFactory().createCTAltChunk();
ac1.setId(altChunkRel1.getId());
documentTemplate.getMainDocumentPart().getContent().add(index, ac1);
and method DocumentUtil.showHtml is as follows
- Code: Select all
public static AlternativeFormatInputPart showHtml(String notes, int index) {
try {
StringBuilder htmlComment = new StringBuilder();
htmlComment.append("<html><span style=\"font-family: Arial Narrow;font-size : 7pt;\">");
notes =replaceSpecialChars(notes);
htmlComment.append(notes);
htmlComment.append("</span></html>");
AlternativeFormatInputPart afiPart = new AlternativeFormatInputPart(new PartName("/hw" + index + ".html"));
afiPart.setBinaryData(htmlComment.toString().getBytes("UTF-8"));
afiPart.setContentType(new ContentType("text/html"));
return afiPart;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
A styled paragraph created programmatically
<w:p w:rsidR="001A6852" w:rsidRDefault="001A6852">
<w:pPr>
<w:pStyle w:val="otablefootnote"/>
</w:pPr>
</w:p>
A HTML content converted into docx format
<w:p w:rsidR="001A6852" w:rsidRDefault="001A6852">
<w:pPr>
<w:divId w:val="1629387063"/>
</w:pPr>
<w:r>
<w:rPr>
<w:sz w:val="14"/>
<w:szCs w:val="14"/>
</w:rPr>
<w:t>Section Notes : Data</w:t>
</w:r>
</w:p>
Please help.
Thanks
Tarique