Dear team,
We need to find all images using aspose java. please find the below source code which we are using
source code :
private static void findAllfigures(Document initDoc, String nameAppend) throws NullPointerException
{
String matches = "Fig.*(?:[ \\r\\n\\t].*)+|Scheme.*|Plate.*|Abbildung.*";
try {
for (Paragraph para : (Iterable<Paragraph>)initDoc.getChildNodes(NodeType.PARAGRAPH, true))
{
if ((para.getText().trim().startsWith(FIG) || para.getText().trim().startsWith(SCHEME)
|| para.getText().trim().startsWith(PLATE)) && !AIE.supplymentryCheck(para.toString(SaveFormat.TEXT).trim()))
{
if (!(para.toString(SaveFormat.TEXT).trim().startsWith("Figure Captions"))
&& (!(para.toString(SaveFormat.TEXT).trim().startsWith("Figures and captions"))))
{
try
{
Table parentTable = (Table)para.getAncestor(NodeType.TABLE);
if ((((Paragraph)para.getNextSibling()).getChildNodes(NodeType.SHAPE, true).getCount() > 0)
|| (((Paragraph)para.getPreviousSibling()).getChildNodes(NodeType.SHAPE, true).getCount() > 0)
&& parentTable != null && parentTable.getChildNodes(NodeType.SHAPE, true).getCount() > 0)
{
String allFignames = null;
{
allFignames = formatImgcaption(para.toString(SaveFormat.TEXT).trim(), nameAppend);
}
allimages.add(allFignames);
}
}
catch (NullPointerException e)
{
logger.info("Exception ", e.getMessage());
// e.printStackTrace();
}
}
}
}
initDoc.save(interim);
} catch (Exception e) {
logger.info("Exception ", e.getMessage());
// e.printStackTrace();
}
input : Figures.docx (216.3 KB)
Please do needful