Gets or sets the height of the containing block of the shape.
[Visual Basic]Public Property Height As
Double [C#]public
double Height {get; set;}
Remarks
For a top-level shape, the value is in points.
For shapes in a group, the value is in the coordinate space and units of the parent group.
The default value is 0.
Example
Shows how to resize an image shape.
[C#]
DocumentBuilder builder = new DocumentBuilder();
// By default, the image is inserted at 100% scale.
Shape shape = builder.InsertImage(MyDir + "Aspose.Words.gif");
// It is easy to change the shape size. In this case, make it 50% relative to the current shape size.
shape.Width = shape.Width * 0.5;
shape.Height = shape.Height * 0.5;
// However, we can also go back to the original image size and scale from there, say 110%.
ImageSize imageSize = shape.ImageData.ImageSize;
shape.Width = imageSize.WidthPoints * 1.1;
shape.Height = imageSize.HeightPoints * 1.1;
builder.Document.Save(MyDir + "Image.ScaleImage Out.doc");
[Visual Basic]
Dim builder As DocumentBuilder = New DocumentBuilder()
' By default, the image is inserted at 100% scale.
Dim shape As Shape = builder.InsertImage(MyDir & "Aspose.Words.gif")
' It is easy to change the shape size. In this case, make it 50% relative to the current shape size.
shape.Width = shape.Width * 0.5
shape.Height = shape.Height * 0.5
' However, we can also go back to the original image size and scale from there, say 110%.
Dim imageSize As ImageSize = shape.ImageData.ImageSize
shape.Width = imageSize.WidthPoints * 1.1
shape.Height = imageSize.HeightPoints * 1.1
builder.Document.Save(MyDir & "Image.ScaleImage Out.doc")
Shows how to insert a floating image and specify its position and size.
[C#]
// This creates a builder and also an empty document inside the builder.
DocumentBuilder builder = new DocumentBuilder();
// By default, the image is inline.
Shape shape = builder.InsertImage(MyDir + "Hammer.wmf");
// Make the image float, put it behind text and center on the page.
shape.WrapType = WrapType.None;
// Make position relative to the page.
shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page;
shape.RelativeVerticalPosition = RelativeVerticalPosition.Page;
// Make the shape occupy a band 50 points high at the very top of the page.
shape.Left = 0;
shape.Top = 0;
shape.Width = builder.CurrentSection.PageSetup.PageWidth;
shape.Height = 50;
builder.Document.Save(MyDir + "Image.CreateFloatingPositionSize Out.doc");
[Visual Basic]
' This creates a builder and also an empty document inside the builder.
Dim builder As DocumentBuilder = New DocumentBuilder()
' By default, the image is inline.
Dim shape As Shape = builder.InsertImage(MyDir & "Hammer.wmf")
' Make the image float, put it behind text and center on the page.
shape.WrapType = WrapType.None
' Make position relative to the page.
shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page
shape.RelativeVerticalPosition = RelativeVerticalPosition.Page
' Make the shape occupy a band 50 points high at the very top of the page.
shape.Left = 0
shape.Top = 0
shape.Width = builder.CurrentSection.PageSetup.PageWidth
shape.Height = 50
builder.Document.Save(MyDir & "Image.CreateFloatingPositionSize Out.doc")
Opens an HTML document with images from a stream with a base URI.
[C#]
// We are opening this HTML file:
/*
<html>
<body>
<p>Simple file.</p>
<p><img src="Aspose.Words.gif" width="80" height="60"></p>
</body>
</html>
*/
string fileName = MyDir + "Document.OpenFromStreamWithBaseUri.html";
// Open the stream.
Stream stream = File.OpenRead(fileName);
// Open the document. Note the Document constructor detects HTML format automatically.
// Pass the URI of the base folder so any images with relative URIs in the file can be found.
Document doc = new Document(stream, MyDir);
// You can close the stream now, it is no longer needed because the document is in memory.
stream.Close();
// Lets make sure the image was imported successfully into a Shape node.
// Get the 1st shape node in the document.
Shape shape = (Shape)doc.GetChild(NodeType.Shape, 0, true);
// Verify some properties of the image.
Assert.IsTrue(shape.IsImage);
Assert.IsNotNull(shape.ImageData.ImageBytes);
Assert.AreEqual(80.0, ConvertUtil.PointToPixel(shape.Width));
Assert.AreEqual(60.0, ConvertUtil.PointToPixel(shape.Height));
// Save in the DOC format.
doc.Save(MyDir + "Document.OpenFromStreamWithBaseUri Out.doc");[Visual Basic]
' We are opening this HTML file:
'
'<html>
'<body>
'<p>Simple file.</p>
'<p><img src="Aspose.Words.gif" width="80" height="60"></p>
'</body>
'</html>
'
Dim fileName As String = MyDir & "Document.OpenFromStreamWithBaseUri.html"
' Open the stream.
Dim stream As Stream = File.OpenRead(fileName)
' Open the document. Note the Document constructor detects HTML format automatically.
' Pass the URI of the base folder so any images with relative URIs in the file can be found.
Dim doc As Document = New Document(stream, MyDir)
' You can close the stream now, it is no longer needed because the document is in memory.
stream.Close()
' Lets make sure the image was imported successfully into a Shape node.
' Get the 1st shape node in the document.
Dim shape As Shape = CType(doc.GetChild(NodeType.Shape, 0, True), Shape)
' Verify some properties of the image.
Assert.IsTrue(shape.IsImage)
Assert.IsNotNull(shape.ImageData.ImageBytes)
Assert.AreEqual(80.0, ConvertUtil.PointToPixel(shape.Width))
Assert.AreEqual(60.0, ConvertUtil.PointToPixel(shape.Height))
' Save in the DOC format.
doc.Save(MyDir & "Document.OpenFromStreamWithBaseUri Out.doc")See Also
ShapeBase Class | Aspose.Words.Drawing Namespace