Resizing shapes to fit page size

Hey folks,

with Aspose.Word 13.5 for Java what would be the right way to:
a. parse all images and OLEs in the document
b. resize them to fit the page

And as a related question, is it possible to distinguish between an image and OLE?

Regards,
Dragos

Actually I have figured out the answers to 1 and also how to tell if the Shape is OLE ( getShapeType), I would only like to know what is the most efficient way to resize the image to ensure it fits the page.

Regards,
Dragos

Hi Dragos,

Thanks for your inquiry. You can use the following code to detect OLE shapes. You can determine type of an OLE object using getProgId method.

Please use the Shape.setHeight and Shape.setWidth properties to set the height and width of Shape. You can get the page height/width by using PageSetup.getPageHeight and PageSetup.getPageWidth methods. Please read following documentation links for your kind reference.
https://reference.aspose.com/words/java/com.aspose.words/shape
https://reference.aspose.com/words/java/com.aspose.words/PageSetup

Document doc = new Document("C:\\Temp\\in.docx");
for (Shape shape : (Iterable<Shape>)doc.getChildNodes(NodeType.SHAPE, true))
{
    if (shape.getOleFormat() != null)
    {
        if (shape.getOleFormat().getProgId().equals("Package"))
        {
            int i = 0;
            shape.getOleFormat().save("C:\\temp\\img" + i + ".jpg");
            i++;
        }
    }
}