HI,
i want to replace the html text in a docx file but preverse the docx Ol numbering instead of ol numberin present in new Html String. My code and Test document Zip attached below.new.zip (25.3 KB)
@hariomgupta73 You can do it in the following way.
StructuredDocumentTag headSdt = (StructuredDocumentTag)doc.getChild(NodeType.STRUCTURED_DOCUMENT_TAG, 1, true);
// Get the target list para.
Paragraph headPara = (Paragraph)headSdt.FirstChild;
for (Object st : document.getChildNodes(NodeType.STRUCTURED_DOCUMENT_TAG, true)) {
StructuredDocumentTag std = (StructuredDocumentTag)st;
if (std.getSdtType() == SdtType.RICH_TEXT && std.getTag().equals("BASIC__101__4352__138__138")) {
std.removeAllChildren();
Paragraph para = new Paragraph(document);
std.appendChild(para);
documentBuilder.moveTo(std.getFirstChild());
documentBuilder.insertHtml(modifiedText, false);
// Set the target list.
para.getListFormat().setList(headPara.getListFormat().getList());
Node lastChild = std.getLastChild();
if (("\r").equals(lastChild.getText())) {
std.removeChild(lastChild);
}
}
thank you, Vadim.Saltykov