SetImage
Contents
[
Hide
]SetImage(string)
Changes the fill type to single image.
public void SetImage(string fileName)
Parameter | Type | Description |
---|---|---|
fileName | String | The path to the image file. |
Examples
Shows how to set shape fill type as image.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// There are several ways of setting image.
Shape shape = builder.InsertShape(ShapeType.Rectangle, 80, 80);
// 1 - Using a local system filename:
shape.Fill.SetImage(ImageDir + "Logo.jpg");
doc.Save(ArtifactsDir + "Shape.FillImage.FileName.docx");
// 2 - Load a file into a byte array:
shape.Fill.SetImage(File.ReadAllBytes(ImageDir + "Logo.jpg"));
doc.Save(ArtifactsDir + "Shape.FillImage.ByteArray.docx");
// 3 - From a stream:
using (FileStream stream = new FileStream(ImageDir + "Logo.jpg", FileMode.Open))
shape.Fill.SetImage(stream);
doc.Save(ArtifactsDir + "Shape.FillImage.Stream.docx");
See Also
- class Fill
- namespace Aspose.Words.Drawing
- assembly Aspose.Words
SetImage(Stream)
Changes the fill type to single image.
public void SetImage(Stream stream)
Parameter | Type | Description |
---|---|---|
stream | Stream | The stream that contains the image bytes. |
Examples
Shows how to set shape fill type as image.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// There are several ways of setting image.
Shape shape = builder.InsertShape(ShapeType.Rectangle, 80, 80);
// 1 - Using a local system filename:
shape.Fill.SetImage(ImageDir + "Logo.jpg");
doc.Save(ArtifactsDir + "Shape.FillImage.FileName.docx");
// 2 - Load a file into a byte array:
shape.Fill.SetImage(File.ReadAllBytes(ImageDir + "Logo.jpg"));
doc.Save(ArtifactsDir + "Shape.FillImage.ByteArray.docx");
// 3 - From a stream:
using (FileStream stream = new FileStream(ImageDir + "Logo.jpg", FileMode.Open))
shape.Fill.SetImage(stream);
doc.Save(ArtifactsDir + "Shape.FillImage.Stream.docx");
See Also
- class Fill
- namespace Aspose.Words.Drawing
- assembly Aspose.Words
SetImage(byte[])
Changes the fill type to single image.
public void SetImage(byte[] imageBytes)
Parameter | Type | Description |
---|---|---|
imageBytes | Byte[] | The image bytes array. |
Examples
Shows how to set shape fill type as image.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// There are several ways of setting image.
Shape shape = builder.InsertShape(ShapeType.Rectangle, 80, 80);
// 1 - Using a local system filename:
shape.Fill.SetImage(ImageDir + "Logo.jpg");
doc.Save(ArtifactsDir + "Shape.FillImage.FileName.docx");
// 2 - Load a file into a byte array:
shape.Fill.SetImage(File.ReadAllBytes(ImageDir + "Logo.jpg"));
doc.Save(ArtifactsDir + "Shape.FillImage.ByteArray.docx");
// 3 - From a stream:
using (FileStream stream = new FileStream(ImageDir + "Logo.jpg", FileMode.Open))
shape.Fill.SetImage(stream);
doc.Save(ArtifactsDir + "Shape.FillImage.Stream.docx");
See Also
- class Fill
- namespace Aspose.Words.Drawing
- assembly Aspose.Words