ImageDataSetImage Method (Stream) |
Namespace: Aspose.Words.Drawing
Document doc = new Document(); // We can get an image from a file, set it as the image of a shape and append it to a paragraph Image srcImage = Image.FromFile(ImageDir + "Logo.jpg"); Shape imgShape = new Shape(doc, ShapeType.Image); doc.FirstSection.Body.FirstParagraph.AppendChild(imgShape); imgShape.ImageData.SetImage(srcImage); srcImage.Dispose(); // We can also open an image file using a stream and set its contents as a shape's image using (Stream stream = new FileStream(ImageDir + "Logo.jpg", FileMode.Open, FileAccess.Read)) { imgShape = new Shape(doc, ShapeType.Image); doc.FirstSection.Body.FirstParagraph.AppendChild(imgShape); imgShape.ImageData.SetImage(stream); imgShape.Left = 150.0f; } doc.Save(ArtifactsDir + "Drawing.ImportImage.docx");