Borders around inserted images


#1

Hi to Roman and the other forum members

there are appears to be an issue when inserting images with the third of the possible .InsertImage options and trying to have a border around the image.

Here is a code snippet to illustrate the problem:

'------------------------------------------------
builder.Font.Border.LineWidth = 5
builder.Font.Border.DistanceFromText = 0
builder.Font.Border.LineStyle = LineStyle.Emboss3D
builder.Font.Border.Color = System.Drawing.Color.DarkGreen

Dim image As System.Drawing.Image
image = System.Drawing.Image.FromFile("c:\temp\intranet_.jpg")
builder.InsertImage(image)
builder.Writeln(Aspose.Word.ControlChar.Cr)
builder.InsertImage(image, 200, 200)
builder.Writeln(Aspose.Word.ControlChar.Cr)
builder.InsertImage(image, RelativeHorizontalPosition.Page, 50, RelativeVerticalPosition.Page, 350, 200, 200, WrapType.None, WrapSide.Largest, True)
builder.Writeln(Aspose.Word.ControlChar.Cr & "Meaningless words here")

builder.Font.Border.ClearFormatting()
'-------------------------------------------

The first two images that are inserted into the document have borders as expected but the third image does not have the border.

Is it possible to get this fixed or is there something that I have overlooked where the image positioning overrides the possibility of a border.

Thanks very much

Ralph P.


#2

Font.Border specifies border around characters (inline).

First two overloads of InsertImage insert an image inline with text (as a character) and thus Font.Border works for the image too.

The last InsertImage overload inserts the image as a floating object and Font.Border does not apply there. In MS Word, it will be something like Shape.Border, but we dont’ have this functionality not yet exposed.

I will log this request, but I’m not yet sure what’s the best way to add this to DocumentBuilder API.

Maybe as a workaround you can actually draw a border on the image (using Graphics) before inserting it into the document.