Hi Team,
I’ve extracted the image from the document. The extracted document is partially hidden. How can I determine if the image fits on the page, and how can I resolve this issue?
Document: Fig0005.docx (709.4 KB)
Regards,
Mahi
Hi Team,
I’ve extracted the image from the document. The extracted document is partially hidden. How can I determine if the image fits on the page, and how can I resolve this issue?
Document: Fig0005.docx (709.4 KB)
Regards,
Mahi
@Mahi39 To get an actual shape position, you can use LayoutCollector and LayoutEnumerator classes. For example see the following code:
Document doc = new Document("C:\\Temp\\in.docx");
LayoutCollector collector = new LayoutCollector(doc);
LayoutEnumerator enumerator = new LayoutEnumerator(doc);
// Get the first shape.
Shape s = (Shape)doc.getChild(NodeType.SHAPE, 0, true);
// Get actual bounds of the shape.
enumerator.setCurrent(collector.getEntity(s));
Rectangle2D rect = enumerator.getRectangle();
System.out.println("Page:" + enumerator.getPageIndex() + "; X=" + rect.getX() + "; Y=" + rect.getY() + "; Width=" + rect.getWidth() + "; Height=" + rect.getHeight());
Then you can check whether the resutned rectangle fully fits the page rectangle.
Hi @alexey.noskov, Thanks,. Can you confirm that a negative y-value will prevent an image from fitting on the page?