Aspose .Net PDF library is taking too much time to convert any html string to pdf

Hi team,
We’ve an Aspose total license. We’re trying to generate PDF from HTML template string but Aspose document pdf library is taking lot of time to generate PDF out of it. We’re getting a lot of negative feedbacks from our clients because of pdf generation slowness.
We’re using Aspose pdf version 24.1.0

For converting sample html string to pdf, the library is taking almost 40 to 50 seconds for 20 pages pdf with and without images as well.

We’re using Aspose.Pdf.Document(Stream input, LoadOptions options) method for converting html string to pdf.
We’re using below logic for Html to pdf conversion -

string htmlStr = “Sample html string”;

            HtmlLoadOptions options1 = new()
            {
                // set Print or Screen mode
                HtmlMediaType = HtmlMediaType.Print,
                IsEmbedFonts = true,
                //PageInfo = { Width = 794, Height = 1191, IsLandscape = true }
                PageInfo = {
                    Width = Aspose.Pdf.PageSize.A4.Width,
                    Height = Aspose.Pdf.PageSize.A4.Height,
                     Margin = { Left = 10, Right = 10 }
                }
            };

            byte[] byteArray = Encoding.UTF8.GetBytes(htmlStr);
            MemoryStream htmlStrStream = new(byteArray);

            Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(htmlStrStream, options1);
            await htmlStrStream.DisposeAsync();

            pdfDocument.SetTitle(obj.CedingCompany);

        

            string headerText = obj.Company + " - " + obj.Title + " - " + obj.No;

            AddHeaderToDocument(pdfDocument, headerText);
            AddPageNumberToDocument(pdfDocument);
            pdfDocument.FreeMemory();

OptimizationOptions optimizeOptions = new();

                ////Set CompressImages option
                optimizeOptions.ImageCompressionOptions.CompressImages = true;
                optimizeOptions.ImageCompressionOptions.ImageQuality = 80;
                optimizeOptions.ImageCompressionOptions.Version = ImageCompressionVersion.Fast;

                ////Keeping below Encoding option commented as it can reduce pdf size to great extent but increases processing time. So keeping it commented for now.
                ////optimizeOptions.ImageCompressionOptions.Encoding = ImageEncoding.Flate

                optimizeOptions.UnembedFonts = true;
                optimizeOptions.CompressObjects = true;
                optimizeOptions.RemoveUnusedObjects = true;
                optimizeOptions.RemoveUnusedStreams = true;
                optimizeOptions.LinkDuplcateStreams = true;
                optimizeOptions.AllowReusePageContent = true;

                ////Optimize PDF document using OptimizationOptions
                pdfDocument.OptimizeResources(optimizeOptions);
           

            MemoryStream ms = new();
            pdfDocument.Save(ms);
            pdfDocument.Dispose(); //Disposing Aspose PDF object instance to free memory

            byte[]? pdfByteArr = ms.ToArray();
            await ms.DisposeAsync();

            DateTime endTime2 = DateTime.Now;
            TimeSpan elapsedTime2 = endTime2 - startTime2;
            _logger.LogInformation("ReferralIntegrationController:UpdateAssociatedReferrals:GeneratePdfDocument:Function - actualPdfCreation ended at : {endTime} Elapsed Time : {elapsedTime} seconds for summaryId: {id}", endTime2, elapsedTime2.Seconds, id);

We’re providing the sample HTML template we’ve used to generate PDF with and without images.
Aspose_Support_Ticket_Sample_Data.zip (3.7 MB)

We are getting a lot of performance issues due to pdf generation slowness. This consistent slowness has caused negative impact on our client business. So we are very worried about it.
Team can you please help us to get it fixed as soon as possible. Please provide an ETA as earliest.

@tusharsahu

We will surely log a dedicated ticket for your case. Can you please share the environment details like OS Name and Version, installed RAM Size, Application Type, .NET Framework, etc.? It would help us in investigating the case accordingly.

@asad.ali below are the requested details -

OS Name - Windows,
Application Type - dot net,
.NET Framework - 6
image.png (24.4 KB)

@tusharsahu

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): PDFNET-56374

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

@asad.ali My organization has purchased Aspose Paid Support Service. Let me know how can we link this ticket to paid support?

@tusharsahu

You should now be able to login into Paid Support Forum. Please create a topic/post there with the reference of issue ID attached here and your issue will be escalated accordingly.

Hi @asad.ali, any updates this issue?
Our product releases are getting impacted due to this slowness issue & clients are pushing onto us for getting it fixed ASAP. We are very short of time.
Please share an update as earliest.

@tusharsahu

We really afraid the ticket is not yet investigated. Please note that the ticket has been logged under free support model and it will be prioritized on a first come first serve basis. We have recorded your concerns and will surely inform you once we make some progress towards its resolution. Please spare us some time.

We are sorry for the inconvenience.

A post was split to a new topic: How we can update email address