I'm trying to save presentation into SVG, and have problems with datalabels in Chart.
While on pptx everything looks fine in svg there are a lot of issues:
- No border
- No leader lines
- Size of data label is different
- No paragraphs and text is shifted together
- No background color
Please refer to this code snippet:
- Code: Select all
static void Main(string[] args)
{
var presentation = new Presentation();
var slide = presentation.Slides[0];
var chart = slide.Shapes.AppendChart(ChartType.ScatterStraightLinesAndMarkers, new RectangleF(50, 50, 500, 500));
ChartDataLabel cd = chart.Series[0].DataLabels.Add();
cd.X = -0.40f;
cd.Y = -0.25f;
cd.ID = 2;
cd.TextFrame.Paragraphs[0].Text = "hello";
cd.TextFrame.Paragraphs.Append(new TextParagraph() {Text = "second line"});
cd.TextFrame.Paragraphs.Append(new TextParagraph() { Text = "third line" });
cd.Fill.FillType = FillFormatType.Solid;
cd.Fill.SolidColor.Color = Color.FromArgb(200, Color.Red);
cd.Line.FillFormat.FillType = FillFormatType.Solid;
cd.Line.FillFormat.SolidFillColor.Color = Color.FromArgb(55, 96, 146);
cd.LabelValueVisible = true;
chart.Series[0].DataLabels.LeaderLinesVisible = true;
presentation.SaveToFile("D://test.pptx", FileFormat.Pptx2013);
var svgBytes = presentation.SaveToSVG();
int len = svgBytes.Count;
for (int i = 0; i < len; i++)
{
FileStream fs = new FileStream($"D://result{i}.svg", FileMode.Create);
byte[] bytes1 = svgBytes.Dequeue();
fs.Write(bytes1, 0, bytes1.Length);
}
Process.Start("D://test.pptx");
Process.Start("D://result0.svg");
}