How to Extract Images from a Document
All images are stored inside Shape nodes in a Document. To extract all images or images having specific type from the document, follow these steps:
- Use the Document.getChildNodes method to select all Shape nodes.
- Iterate through resulting node collections.
- Check the Shape.hasImage boolean property.
- Extract image data using the Shape.ImageData property.
- Save image data to a file.
How to Insert Barcode on each Page of a Document
This example lets you add same or different barcodes on all or specific pages of a Word document. There is no direct way to add barcodes on all pages of a document but you can use DocumentBuilder.moveToSection, DocumentBuilder.moveToHeaderFooter and DocumentBuilder.insertImage (http://www.aspose.com/api/java/words/com.aspose.words/classes/documentbuilder/methods/insertImage(byte\[\])/) methods to move to any section or headers/footers and insert the barcode images as you can see in the following code. Below example Inserts a barcode image on each page of a document.
Lock Aspect Ratio of Image
The aspect ratio of a geometric shape is the ratio of its sizes in different dimensions. You can lock aspect ratio of an image using Shape.AspectRatioLocked. The default value of shape's aspect ratio is depend on the ShapeType. It is true for ShapeType.Image and false for other shape types.
How to Get Actual Bounds of Shape in Points
If you want the actual bounding box of the shape as rendered on the page, you can achieve this by using NodeRendererBase.BoundsInPoints property. Below code example shows how to use this property.