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.

Fri Oct 13, 2017 7:59 am

Hello,

An issue has been found while generating presentations using spire.

For example: We have ten different presentations present in our project. We want to add one slide from each presentation to our new presentation using Presentation.Slides.Append method with just the slide parameter. When adding, every master slide associated with the added slide is inserted into the new presentation. The result is a presentation containing 10 (or 11) master slides which is fairly large in size on disk.

One case was a presentation that was generated from sixty different presentations, and it was around 100 MB.

If you need further clarification, we would be available for an online meeting on workdays (Monday through Friday) from 8 AM to 4 PM CEST.

Kind Regards,
Dusan

dmilic
 
Posts: 11
Joined: Wed Aug 16, 2017 8:27 am

Fri Oct 13, 2017 9:08 am

Dear Dusan,

Thanks for your inquiry.
As for the memory usage, if you're loading/generating huge PowerPoint document via Spire, more memory than file size would be required. This is because during processing, the document needs to be held wholly in memory. Usually, Spire.Presentation needs 10 times more memory than the original document size to build a DOM in the memory. So, for your issue, I am afraid it is difficult for us to do the optimization for the memory at present.

To help us do further investigation on our side, please provide us with the input documents and the code you were using, we will investigate if there's other approaches.

Moreover, our working time is GMT+8 9:00 AM to 17:30 PM from Monday to Friday.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Mon Oct 16, 2017 10:03 am

Dear Betsy,

Sorry I wasn't clear enough. We do not have system memory issues, but the size of the generated presentation on the hard drive issues.

Here are the code and a sample presentation.

Code: Select all
            Presentation testPresentation = new Presentation();
            Presentation presentationFromDisk = new Presentation();
            Presentation smallerPresentation = new Presentation();
            Presentation largerPresentation = new Presentation();
           
            string fileName = @"C:\SpireTest.pptx";

            smallerPresentation.Slides.RemoveAt(0);
            smallerPresentation.Masters.RemoveAt(0);

            largerPresentation.Slides.RemoveAt(0);
            largerPresentation.Masters.RemoveAt(0);

            using (FileStream fs = File.Open(fileName, FileMode.Open))
            {
                presentationFromDisk.LoadFromStream(fs, FileFormat.Auto);
            }

            for (int i = 0; i < presentationFromDisk.Slides.Count; i++)
            {
                smallerPresentation.Slides.Append(presentationFromDisk.Slides[i]);
            }

            smallerPresentation.SaveToFile(@"C:\Result.pptx", FileFormat.Auto);

            for (int i = 0; i < presentationFromDisk.Slides.Count; i++)
            {
                Presentation oneSlidePresentation = new Presentation();
                oneSlidePresentation.Slides.RemoveAt(0);
                oneSlidePresentation.Masters.RemoveAt(0);
                oneSlidePresentation.Slides.Append(presentationFromDisk.Slides[i]);
               
                largerPresentation.Slides.Append(oneSlidePresentation.Slides[0]);
            }

            largerPresentation.SaveToFile(@"C:\BadResult.pptx", FileFormat.Auto);


The resulting presentations are different in size, although seemingly the same in content. BadResult.pptx takes up several times more disk space than Result.pptx. This is because BadResult.pptx has more master slides than the Result.pptx. I know this specific code doesn't seem like a realistic scenario, but there are scenarios when you have to add slides from different presentations to the result, and the result becomes a large file. This is because every slide copies its master to the new presentation. I don't know if there is a way to remove unnecessary master slides or master slide layout components to reduce the size of the result. We've found a workaround for this issue for our project, but we wanted to notify you that this can become an potential issue.

If there is any need for additional clarification, feel free to ask.

All the best,
Dusan
You do not have the required permissions to view the files attached to this post.

dmilic
 
Posts: 11
Joined: Wed Aug 16, 2017 8:27 am

Tue Oct 17, 2017 8:32 am

Dear dmilic,

Thanks for your information.
The code "Presentation oneSlidePresentation = new Presentation();" would create a new file with a master every times. When appending the slide, it would add the master by default if you don't pass the master. To avoid it, please pass a master while appending the slide.
Code: Select all
            Presentation largerPresentation = new Presentation();
            largerPresentation.Slides.RemoveAt(0);           
            for (int i = 0; i < presentationFromDisk.Slides.Count; i++)
            {               
                Presentation oneSlidePresentation = new Presentation();
                oneSlidePresentation.Slides.RemoveAt(0);
                oneSlidePresentation.Slides.Append(presentationFromDisk.Slides[i]);
                largerPresentation.Slides.Append(oneSlidePresentation.Slides[0], largerPresentation.Masters[0]);
            }

Hope it helps. If there is any question, please let me know.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Wed Oct 18, 2017 7:02 am

Dear dmilic,

Greetings from e-iceblue.
Has your issue been resolved?
Your feedback would be greatly appreciated.

Thanks,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Mon Oct 23, 2017 7:03 am

Hello,

We've found our workaround for our needs.

Thanks for your help,

Dusan

dmilic
 
Posts: 11
Joined: Wed Aug 16, 2017 8:27 am

Mon Oct 23, 2017 7:54 am

Hi Dusan,

Thanks for your feedback.
Any question, please feel free to contact us.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Return to Spire.Presentation