We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Set Border to Image

Hi,

How to set border for Image in aspose.word…?
builder.InsertImage(path,50, 50);

Thanks
Narendran


Hi Narendran,

Thanks for your inquiry. The Shape.Stroke property defines a stroke for a shape. Please use this property as shown below to get the desired output.

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);

Shape shape = builder.InsertImage(MyDir + "input.jpg");

Stroke stroke = shape.Stroke;

stroke.On = true;

stroke.EndCap = EndCap.Square;

shape.Stroke.Weight = 2;

stroke.LineStyle = ShapeLineStyle.Single;

stroke.Color = Color.Blue;

doc.Save(MyDir + "17.2.0.docx");

Shape shape= builder.InsertImage(str, newWidth, newHeight);

Stroke stroke = shape.Stroke;
stroke.On = true;
stroke.EndCap = EndCap.Square;
shape.Stroke.Weight = 10;
stroke.LineStyle = ShapeLineStyle.Double;
stroke.Color = Color.Black;


This is my code...
I can't get border to image IN WORD
But i got border in pdf,jpeg

Thanks,
Narendran
Hi Narendran,

Thanks for your inquiry. We have tested the scenario and have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-14971. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

Hi Narendran,

Thanks for your patience. You are facing this issue due to missing feature WORDSNET-14095 (Cannot add a border to a DML shape). We will inform you via this forum thread once this feature is available.

Please use following workaround to get the desired output. Hope this helps you.

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);

// Prepare and insert a shape.

Shape shape = new Shape(doc, ShapeType.Image);

shape.ImageData.ImageBytes = File.ReadAllBytes(MyDir + @"image.png");

shape.Top = 0;

shape.Left = 0;

shape.WrapType = WrapType.Inline;

shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Default;

shape.RelativeVerticalPosition = RelativeVerticalPosition.TextFrameDefault;

builder.InsertNode(shape);

// Set borders for a shape.

shape.ImageData.Borders.Color = Color.Black;

shape.ImageData.Borders.LineStyle = LineStyle.Double;

shape.ImageData.Borders.LineWidth = 2;

doc.Save(MyDir + "17.2.0.docx");

The issues you have found earlier (filed as WORDSNET-14095) have been fixed in this Aspose.Words for .NET 19.4 update and this Aspose.Words for Java 19.4 update.