@Mahesh39 You should process each column in your table to get the desired output. For example see the following code:
Document doc = new Document("C:\\Temp\\in.docx");
// Update list labels since captions in the document are list with FigX label.
doc.updateListLabels();
// Get the table.
Table table = doc.getFirstSection().getBody().getTables().get(0);
// Suppose each row in the table has the same number of cells.
for (int colIdx = 0; colIdx < table.getFirstRow().getCells().getCount(); colIdx++)
{
// Suppose the last row contains a cation and the first row contains the shape.
String caption = table.getLastRow().getCells().get(colIdx).toString(SaveFormat.TEXT).trim();
System.out.println(caption);
if (caption.startsWith("Fig"))
{
// Get the shape.
Node image = table.getFirstRow().getCells().get(colIdx).getChild(NodeType.SHAPE, 0, true);
if (image == null)
continue;
// Save the shape.
Document tmp = (Document)doc.deepClone(false);
tmp.ensureMinimum();
Node dstImage = tmp.importNode(image, true, ImportFormatMode.USE_DESTINATION_STYLES);
tmp.getFirstSection().getBody().getFirstParagraph().appendChild(dstImage);
tmp.save("C:\\Temp\\" + caption + "_" + colIdx + ".pdf");
}
}
1 Like
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
Enables storage, such as cookies, related to analytics.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.