Spire.Presentation is a professional PowerPoint® compatible library that enables developers to create, read, write, modify, convert and Print PowerPoint documents from any .NET(C#, VB.NET, ASP.NET, .NET Core) application and Java (J2SE and J2EE) application.

Wed Aug 15, 2018 2:33 pm

Hi,

One more bug related to SVG export. When trying to position picture relatively to plot area I get some weird results.
When trying to align just right outside of plot area - picture is shifted a bit right on svg, despite being perfectly placed on pptx (check picture in attachment for better visualization)
Capture1.PNG


When trying to put picture on the left - it works as expected. So it seems some cumulative error or plot area width is off

Check code snippet and presentation attached

Code: Select all
        static void Main(string[] args)
        {
            string fileName = "D://test2.pptx";
            var presentation = new Presentation(fileName, FileFormat.Ppsx2013);

            var chart = presentation.Slides[0].Shapes[0] as IChart;
            var picture = presentation.Slides[0].Shapes[1] as IShape;

            picture.Left = chart.Left + chart.PlotArea.Left + chart.PlotArea.Width;
            picture.Top = chart.Top + chart.PlotArea.Top;

            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);
            }

            presentation.SaveToFile("D://test.pptx", FileFormat.Pptx2013);

            Process.Start("D://test.pptx");
            Process.Start("D://result0.svg");
        }
You do not have the required permissions to view the files attached to this post.

Stecya
 
Posts: 27
Joined: Wed Jan 10, 2018 2:36 pm

Thu Aug 16, 2018 10:08 am

Hello Stecya,

Thanks for your inquiry.
I have reproduced the issue and already posted it to our Dev team for investigating and fixing, If there is any progress, we will share with you immediately. Sorry for the inconvenience caused.

Thanks and Regards,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1045
Joined: Wed Apr 25, 2018 3:20 am

Fri Sep 21, 2018 8:16 am

Hello Stecya,

Thanks for your patient waiting.
For your reported issue, we added a new "PlotAreaWidthOfCalculated" property in Spire.Presentation Pack Hotfix Version:3.9.5, Please download it and change your code
Code: Select all
picture.Left = chart.Left + chart.PlotArea.Left + chart.PlotArea.Width;

to:
Code: Select all
picture.Left = chart.Left + chart.PlotArea.Left + chart.PlotAreaWidthOfCalculated;

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1045
Joined: Wed Apr 25, 2018 3:20 am

Tue Sep 25, 2018 6:23 am

Hi,

I will check your fix.
Can you tell me the difference between PlotArea.Width and PlotAreaWidthOfCalculated in order to know when to use appropriate one

Regards

Stecya
 
Posts: 27
Joined: Wed Jan 10, 2018 2:36 pm

Tue Sep 25, 2018 9:53 am

Hello Stecya,

Thanks for your feedback.
Please kindly note that chart.PlotArea.Width gets the width of chart plotArea in PPTX, but during the process of converting to SVG, the width of the chart plotArea will change. At this moment, the width need to be recalculated and you need use chart.PlotAreaWidthOfCalculated to get the updated width. If there is any doubt, welcome to write back.

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1045
Joined: Wed Apr 25, 2018 3:20 am

Return to Spire.Presentation