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.