Dear team,
I have tried to find images located pages, page numbers. But i’m notable to get proper page numbers> please find below source code
public static int pagenumber(Document interimdoc, String sd) throws Exception {
Document doc = interimdoc;
int pageNumber = 0;
String figure = "";
String fig = "";
StringTokenizer sd1 = new StringTokenizer(sd, "@@");
while (sd1.hasMoreTokens()) {
String fg = sd1.nextToken();
if (fg.startsWith("Fig")) {
fig = fg;
fig = fig.replace("Fig", "Fig. ");
Pattern pattern1 = Pattern.compile("0");
Matcher matcher1 = pattern1.matcher(fig);
fig = matcher1.replaceAll("");
figure = fg;
figure = figure.replace("Fig", "Figure ");
Pattern pattern = Pattern.compile("0");
Matcher matcher = pattern.matcher(figure);
figure = matcher.replaceAll("");
}
}
NodeCollection<Paragraph> paragraphs = doc.getChildNodes(NodeType.PARAGRAPH, true);
for (Paragraph paragraph : (Iterable<Paragraph>) paragraphs) {
try {
if ((paragraph.toString(SaveFormat.TEXT).trim().startsWith(figure))
|| (paragraph.toString(SaveFormat.TEXT).trim().startsWith(fig))) {
LayoutCollector lc = new LayoutCollector(doc);
pageNumber = lc.getStartPageIndex(paragraph);
}
} catch (Exception e) {
}
}
return pageNumber;
}
input file : Supporting information_Girard-Sahun et al._revised.docx (1.7 MB)
please do need full