Dear team,
we need to find total images in given docx file, we are using below java code to find images
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))
{
System.out.println("All para :" + para.getText().toString());
if (para.getText().trim().startsWith(FIG) || para.getText().trim().startsWith(SCHEME)
|| para.getText().trim().startsWith(PLATE))
{
if (!(para.toString(SaveFormat.TEXT).trim().startsWith("Figure Captions")))
{
try
{
Table parentTable = (Table)para.getAncestor(NodeType.TABLE);
if (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();
}
}
but this code not found the images for few type of documents
input file : 1. Manuscript_Imoto_20220330_revise2_clean.docx (5.8 MB)
please do need full