PPTX (20+ Slides) to HTML/HTML5/PDF Conversion Takes 20 Seconds in C#

It’s very slow when convert ppt to html or html5 or pdf format about 20s using Aspose.Slides, and new Presentation action takes about 2s.

My Local env: windows 10 + netcore standard 2.1 + 16G, production env is CentOS 7.
Test document is 20+ pages about 3M+, see attachment file.

Is it better performance using Html5Options like this: Html5Options htmlOptions = new Html5Options(){ AnimateShapes = false, AnimateTransitions = false };?

It’s my code:

byte[] fileStreamBytes = File.ReadAllBytes({here is ppt file path});
using (MemoryStream stream = new MemoryStream(fileStreamBytes))
{
	using (Presentation document = new Presentation(stream))
	{
		using (var ms = new MemoryStream())
		{
			HtmlOptions htmlOptions = new HtmlOptions();
			document.Save(ms, Aspose.Slides.Export.SaveFormat.Html, htmlOptions);
			string contentType = "text/html";

			return File(ms.ToArray(), contentType);
		}
	}
}

简约实用教师公开课ppt模板.7z (2.9 MB)

Thanks

A post was split to a new topic: How to Show an Animation Effect from PPTX in Generated HTML or HTML5?

@davidxiao2008,
Thank you for contacting support.

Unfortunately, I was unable to reproduce the problem you described. I used the Stopwatch class to test your code and measure the conversion time with Aspose.Slides.NET 23.10 (for .NET Standard 2.1) like this:

Stopwatch watch = new Stopwatch();

watch.Start();

byte[] fileStreamBytes = File.ReadAllBytes("sample.pptx");
using (MemoryStream stream = new MemoryStream(fileStreamBytes))
{
    using (Presentation document = new Presentation(stream))
    {
        using (var ms = new MemoryStream())
        {
            HtmlOptions htmlOptions = new HtmlOptions();
            document.Save(ms, SaveFormat.Html, htmlOptions);
        }
    }
}

watch.Stop();

Console.WriteLine("Spent time: " + watch.Elapsed.TotalSeconds + " sec");

It is necessary to perform the measurement in a loop several times, since the first result will be longer than subsequent iterations due to the loading of static resources of the Presentation object.

I also tested the HTM5 and PDF conversion in a similar way.

In your case, also note that there is no need to copy the binary data of the presentation file into a byte array, then into a stream, and then into the Presentation object. You can load the presentation like this:

using (Presentation document = new Presentation("path_to_file"))
{
...
}

I did not find an improvement in performance using these options in your case.

Please check your results using the latest version of Aspose.Slides for .NET if possible. If the issue persists, please share the following additional information:

  • hardware description (CPU, RAM, SSD/HDD) where the conversion was performed
  • Aspose.Slides version you used
  • output files
  • any additional information

The problem taking 20s+ is exists in the first result. Is there a way to preheating and loading static resources in advance.
The second problem taking 10s+ is exists with the sample document in the subsequent iterations, it also takes a long time, what can do to imporve it?

My Local env: windows 10 + netcore standard 2.1 + SSD + 16G memory, production env is CentOS 7.
with Aspose.Slides.NET v23.10.0
preview.7z (855.4 KB)

My site is just preview web site, and the file is stored at other sites, so have to class httpclient to read file bytes. Is there a better way/ sample code to improve the performance for this remote class way?

@davidxiao2008,
Unfortunately, I was unable to reproduce the problem you described. We need more details.

Unfortunately, I don’t have information about this.

To my shame, it takes 6s after deploy to another windows server and not 20s anymore.
Could you share some suggues to impove the performance converting to html format?
Thanks.

@davidxiao2008,
Our developers are constantly working on the performance of file conversion using Aspose.Slides. Unfortunately, I can’t offer you a way to improve the performance of PPTX conversion to other formats.

Got it, Thank you

@davidxiao2008,
Thank you for using Aspose.Slides.