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

Free Support Forum - aspose.com

Charts are converted incorrectly after DOCX to DOC/RTF using .NET

Hi Aspose support,
In our product we have functionality that converts Charts to images and replace Chart shape with resulted image shape.
Similar to what MS Word do when converts DOCX document with Chart into DOC/RTF format.
After testing this approach we were faced with the different issues. Please see the list:

Case#1:
After conversion Chart to image, Chart has wrong title (left side - how it was converted with Word, right side - with Aspose):
WrongChartTitle.png (71.3 KB)

The issue is critical

Source document: Case#1.zip (22.1 KB)
Resulted document after conversion: Case#1_Converted.zip (33.3 KB)
Expected result: Converted to image Chart should have correct title;

Case#2:
After conversion Chart to image, Chart has wrong style:
WrongChartStyle8.png (64.3 KB)
WrongChartStyle11.jpg (180.8 KB)

Source document: Case#2.zip (23.1 KB)
Resulted document after conversion:Case#2_Converted.zip (85.4 KB)
Expected result: Converted to image Chart should have the same style;

Case#3:
After conversion Chart to image, gradient fill is not applied to the Chart elements and text Effects (shadow, glow, etc.) are not shown on the Chart
TextEffectsAndPatternFillIssues.png (104.9 KB)

Source document:Case#3.zip (22.1 KB)
Resulted document after conversion:Case#3_Converted.zip (29.7 KB)
Expected result: Converted to image Chart should have the same gradient fill for elements and text effects;

Case#4:
After conversion Chart to image, Y-axis value is more than in Word
YAxisIsWrong.png (40.9 KB)

Critical problem.
Source document:Case#4.zip (19.7 KB)
Resulted document after conversion:Case#4_Converted.zip (17.5 KB)
Expected that the value should stay the same;

Case#5:
After conversion Chart to image, wrong angle of slope of 3-D Charts
ChartWrongSlopeAngle.png (74.8 KB)

Source document:Case#5.zip (28.5 KB)
Resulted document after conversion:Case#5_Converted.zip (53.3 KB)
Expected that the angle value should stay the same;

Case#6:
After conversion Chart with custom combination to image, Chart has cropped content
CroppedChartContent.png (64.4 KB)

Source document:Case#6.zip (20.0 KB)
Resulted document after conversion:Case#6_Converted.zip (20.6 KB)
Expected that all content will be shown with the same scale as in original document;

Case#7:
After conversion Counter Chart to image, Chart becomes different and wrong
WrongCounterChartIssue.png (95.8 KB)

Source document:Case#7.zip (23.1 KB)
Resulted document after conversion:Case#7_Converted.zip (49.7 KB)

Expected that Chart should stay the same after conversion to image;

Case#8:
After conversion Pie Chart to image, Chart has incorrect border width of Chart pieces
WrongBorderOfChartPieces.png (77.4 KB)

Source document:Case#8.zip (19.3 KB)
Resulted document after conversion:Case#8_Converted.zip (24.2 KB)

Expected that Chart pieces’ width should stay the same.

Conversion whole document to DOC format does not work for us and it does not solve the problem. Format should stay the same, but Charts should become images.
Tested on Aspose.Words.dll v19.8

Code sample:

ImageSaveOptions optionsPng = new ImageSaveOptions(SaveFormat.Png);
optionsPng.Scale = 2;

DocumentBuilder builder = new DocumentBuilder(_doc);
	ReplaceShapes(_doc, optionsPng, builder);


	
	private void ReplaceShapes(Document doc, ImageSaveOptions options, DocumentBuilder builder)
{
    NodeCollection shapes = doc.GetChildNodes(NodeType.Shape, true);
    // Loop from last one to first one
    for (int i = shapes.Count - 1; i >= 0; i--)
    {
        try
        {
            Shape shape = (Shape)shapes[i];

            if (!(shape.HasChart || shape.HasSmartArt)) continue;
      
            using (MemoryStream stream = new MemoryStream())
            {                       
               shape.GetShapeRenderer().Save(stream, options);

               shape.AnchorLocked = true;
				   builder.MoveTo(shape);

				   InsertImage(builder, stream, shape);
    		   shape.Remove();            
            }
        }
        catch (Exception e)
        {                    
        }
    }
}
	
	private Shape InsertImage(DocumentBuilder builder, Stream imgContent, Node sourceNode)
{
    Shape image = null;

    Shape sourceShape = (Shape)sourceNode;
		if (sourceShape.IsInline)
    {
			image = builder.InsertImage(imgContent, sourceShape.Width, sourceShape.Height);
    }
    else
    {
			image = builder.InsertImage(imgContent, sourceShape.RelativeHorizontalPosition, sourceShape.Left,
                        sourceShape.RelativeVerticalPosition, sourceShape.Top, sourceShape.Width, sourceShape.Height,
                        sourceShape.WrapType);
           
    }
                
    return image;
}          

Please help with these problems.
Thanks.

@licenses

We have logged this problem in our issue tracking system as WORDSNET-19169. You will be notified via this forum thread once this issue is resolved. We apologize for your inconvenience.

@licenses

Your issues has been logged in our issue tracking system. Following are the issues IDs.

The issue ID is WORDSNET-19170.

The issue ID is WORDSNET-19171.

The issue ID is WORDSNET-19172.

@licenses

We have managed to reproduce following issues at our end. We have logged these issues in our issue tracking system. You will be notified via this forum thread once these issues are resolved. We apologize for your inconvenience.

The issue ID is WORDSNET-19174.

The issue ID is WORDSNET-19175.

The issue ID is WORDSNET-19176.

The issue ID is WORDSNET-19177.

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

@licenses

Regarding WORDSNET-19171, there are different issues when source document is converted to PDF. One of them is the colors of the glow effects in output PDF. We have logged separate issue for it. The new issue ID is WORDSNET-20638.

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

Thanks for the response, checked on Aspose.Words.dll and confirm that following cases are fixed:

  • WORDSNET-19171 - Wrong chart title;
  • WORDSNET-19169 - Wrong pattern fill for Chart element;
  • WORDSNET-19177 - Wrong border width for chart piece.

@licenses

Thanks for your confirmation. We will inform you via this forum thread when the other issues are fixed.

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

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

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