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

Free Support Forum - aspose.com

Bottom and Right Border is lost after Shape to Image conversion using .NET


I am using Aspose.Words 21.2 to replace Charts/SmartArt with images in a document. When running on the attached doc with a chart object, the right and bottom borders no longer appear after replacement. I am using .NET Framework 4.7.2. Sample code is below. I noticed that when using .NET Core 3.1, the borders don’t disappear, so there seems to be some issue with Aspose.Words and the .NET Framework at play here.
chart_convertedImages_borderIssue.zip (33.5 KB)

    public static int ExtractShapesAsposeWords(string filePath, string fileName)
        Document doc = new Document(filePath);
        List<Shape> shapes = doc.GetChildNodes(NodeType.Shape, true).Cast<Shape>().ToList();
        Dictionary<string, Shape> shapesToReplace = new Dictionary<string, Shape>();
        int numShapes = 0;

        foreach (Shape shape in shapes)
            if (!(shape.HasChart || shape.HasSmartArt)) continue;
            DocumentBuilder builder = new DocumentBuilder(doc);
            ImageSaveOptions options = new ImageSaveOptions(SaveFormat.Png);
            options.UseHighQualityRendering = true;
            options.UseAntiAliasing = true;
            using (MemoryStream stream = new MemoryStream())
                shape.GetShapeRenderer().Save(stream, options);

                InsertImageIntoDoc(builder, stream, shape);

        if (!string.IsNullOrEmpty(ExtractDir) && numShapes > 0)
            Console.WriteLine(fileName + "- DONE Aspose Extraction. " + numShapes + " artifacts were replaced.");
            doc.Save( filePath);

        return numShapes;
    private static Shape InsertImageIntoDoc(DocumentBuilder builder, Stream imgContent, Shape sourceShape)
        Shape shapeWithImage = null;

        if (sourceShape.IsInline)
            shapeWithImage = builder.InsertImage(imgContent, sourceShape.Width, sourceShape.Height);
            shapeWithImage = builder.InsertImage(imgContent, sourceShape.RelativeHorizontalPosition, sourceShape.Left,
                sourceShape.RelativeVerticalPosition, sourceShape.Top, sourceShape.Width, sourceShape.Height,
        return shapeWithImage;


We have tested the scenario and managed to reproduce this issue at our side. We have logged this problem in our issue tracking system as WORDSNET-21782. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

The issues you have found earlier (filed as WORDSNET-21782) have been fixed in this Aspose.Words for .NET 21.11 update also available on NuGet.