Free Support Forum - aspose.com

Meta file reading

Hi

May i know how to read a word document in java using Aspose.word and need to read meta files in a word file

Kindly requested to reply as soon as possible

Hi

Thanks for your inquiry. I think that the following code snippet could be useful for you.

//Open document

Document doc = new Document("in.doc");

NodeCollection shapes = doc.getChildNodes(NodeType.SHAPE, true, false);

for (int imageIndex = 0; imageIndex<shapes.getCount(); imageIndex++)

{

Shape shape = (Shape)shapes.get(imageIndex);

if (shape.hasImage())

{

String type = "";

switch ( shape.getImageData().getImageType())

{

case 0:

type = "no_image";

break;

case 1:

type = "unknown";

break;

case 2:

type = "emf"; //Windows Enhanced Metafile.

break;

case 3:

type = "wmf"; //Windows Metafile.

break;

case 4:

type = "pict";

break;

case 5:

type = "jpeg";

break;

case 6:

type = "png";

break;

case 7:

type = "bmp";

break;

}

String imageFileName = String.format("Image.ExportImages.%1$s Out.%2$s", String.valueOf(imageIndex), type);

shape.getImageData().save(imageFileName);

}

}

Best regards.