Hi Team,
I am facing issue while fetching nodes when the document contains href.(hyper link). I have a html , which i insert in the document using document.insertHtml(). And then i read nodes from the document and then copy them to new/main document. Issue is occuring when href is there in document. For href , it is giving 2 nodes and when nodes are copied into main document , href is not working and duplicate text is shown.
"HYPERLINK "http://qa.dev.com:8080/ux/" \l "/update/tblclause/5153?update=5" \t "_blank" http://qa.dev.com:8080/ux/#/update/tblclause/5153?update=5"
Code that i use to fetch nodes :
private static void insertParagraphChildNodes(DocumentBuilder builder, Paragraph paragraphNode, boolean parentNodeCell) throws Exception {
NodeCollection nodes = paragraphNode.getChildNodes();
Iterator iterator = nodes.iterator();
builder.getFont();
while (iterator.hasNext()) {
Node childNode = (Node) iterator.next();
if (childNode.getNodeType() == NodeType.RUN) {
Run runNode = (Run) childNode;
builder.getFont().setBold(runNode.getFont().getBold());
builder.getFont().setItalic(runNode.getFont().getItalic());
builder.getFont().setUnderline(runNode.getFont().getUnderline());
builder.getFont().setColor(runNode.getFont().getColor());
builder.getFont().setHighlightColor(runNode.getFont().getHighlightColor());
if (runNode.getFont().getShading() != null) {
builder.getFont().getShading().setForegroundPatternColor(runNode.getFont().getShading().getForegroundPatternColor());
builder.getFont().getShading().setBackgroundPatternColor(runNode.getFont().getShading().getBackgroundPatternColor());
}
builder.write(runNode.getText());
} else if (childNode.getNodeType() == NodeType.SHAPE) {
Shape shapeNode = (Shape) childNode;
if (shapeNode.hasImage()) {
try {
builder.insertImage(shapeNode.getImageData().getImageBytes(), shapeNode.getWidth(), shapeNode.getHeight());
} catch (Exception e) {
}
}
}
}
if (!parentNodeCell)
builder.writeln();
}
Attached file testDoc.docx (12.1 KB)