word2md
SHAPE wrong Turn it into pictures,SHAPE It could be text or it could be tables.
9-24_672a039b01feb.docx (3.0 MB)
@chenpeng2024 The behavior is expected since there is no meaningful way to output floating content to Markdown. So the shapes are rendered to to images to keep the shapes layout.
If it is required to output content as raw Markdown, you should move content outside the shape.
Is there any relevant api operation method? If I remove SHAPE Node, there will be nothing left
@chenpeng2024 You can try using code like the following:
Document doc = new Document("C:\\Temp\\in.docx");
// Loop through shapes and move content from shapes outside the shapes.
Node[] shapes = doc.getChildNodes(NodeType.SHAPE, true).toArray();
for (int i = 0; i < shapes.length; i++)
{
Shape s = (Shape)shapes[i];
if (s.isTopLevel() && s.getChildNodes(NodeType.PARAGRAPH, false).getCount() > 0)
{
Paragraph parentPara = s.getParentParagraph();
while (s.hasChildNodes())
parentPara.getParentNode().insertAfter(s.getLastChild(), parentPara);
s.remove();
}
}
doc.save("C:\\Temp\\out.md");
thank you very much
1 Like