Hi,
I want to convert a text stream to docx. Can you please tell me how I will achieve this??
CODE:
Document doc = new Document(getPathToTemplateDoc());
System.out.println("Template fields ::" + doc.getMailMerge().getFieldNames());
NodeCollection shapes = doc.getChildNodes(NodeType.SHAPE, true, false);
System.out.println(shapes.getCount());
for (Shape shape : (Iterable)shapes)
if (shape != null)
{
if (shape.hasImage())
{
shape.remove();
}
}
ByteArrayOutputStream dstStream = new ByteArrayOutputStream();
doc.save(dstStream, SaveFormat.TEXT);
ByteArrayInputStream srcStream = new ByteArrayInputStream(dstStream.toByteArray());
Document docx = new Document(srcStream);
return docx;