Hi Team,
I am able extract and save the images(jpeg,png) as pdf .Iam using paragraph node for extraction.but some of the images above the images type that will not getting extracted and able to save.
NodeCollection shapes = doc.getChildNodes(NodeType.SHAPE, true);
for (Shape shape : (Iterable<Shape>)shapes)
{
if (shape.hasImage() && shape.getParentParagraph().getNextSibling() != null
&& shape.getParentParagraph().getNextSibling().getNodeType() == NodeType.PARAGRAPH)
{
if (shape.getParentParagraph().getNextSibling().toString(SaveFormat.TEXT).startsWith("Fig")
|| shape.getParentParagraph().getNextSibling().toString(SaveFormat.TEXT).startsWith("Sch"))
{
caption = shape.getParentParagraph().getNextSibling().toString(SaveFormat.TEXT);
ArrayList nodes = extractContent(shape.getParentParagraph(), shape.getParentParagraph(), true);
filename = folder_name + "Fig" + i + "_" + name + ".docx";
generateDocument(doc, nodes).save(filename);
Paragraph fig = (Paragraph)shape.getParentParagraph().getNextSibling();
/**
* REMOVAL OF NODE(START,END) FROM SOURCE WORD DOC START
**/
shape.getParentParagraph().insertBefore(new BookmarkStart(doc, "Image_" + i), shape);
fig.appendChild(new BookmarkEnd(doc, "Image_" + i));
i++;
I am using above code for extraction.
Thank you,
kind regards,
priyanga