I found a couple of issues with charts created using ASPOSE Words that are saved as PDF.
The code below creates a simple column chart using a single series. The output in MS Word is correct, but if you save the same document as PDF, then there are two issues:
- The legend is displayed, but should not due to the LegendPosition.None setting.
- The data label for the last column is not displayed, but should display a zero.
I’m using ASPOSE Words v21.3.
Here’s the code to reproduce the issue:
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Shape shape = builder.InsertChart(ChartType.Column, 432, 252);
// Set chart options.
Chart chart = shape.Chart;
chart.Title.Text = "Simple Chart";
chart.Legend.Position = LegendPosition.None;
// Clear default series.
ChartSeriesCollection seriesColl = chart.Series;
seriesColl.Clear();
// Add series data and options.
string[] categories = new string[]
{
"1Q2020",
"2Q2020",
"3Q2020",
"4Q2020"
};
double[] values = new double[]
{
477,
475.75,
480,
0
};
ChartSeries series = seriesColl.Add("Test Series", categories, values);
series.HasDataLabels = true;
series.DataLabels.ShowValue = true;
string folder = TestUtils.GetOutputFolder();
string fileName = "SimpleColumnChart.docx";
string filePath = Path.Combine(folder, fileName);
doc.Save(filePath);
Process.Start(filePath);
filePath = filePath.Replace(".docx", ".pdf");
doc.Save(filePath, SaveFormat.Pdf);
Process.Start(filePath);