We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Aspose PDF "new Document(Steam input, LoadOptions options)" performance very slow

Using Aspose.PDF 18.9.1.0 for a .NET Core app. Using Aspose to create a PDF from a Stream in the following code:

            var options = GetHtmlOptions(pageWidth, pageHeight);
            var manager = new RecyclableMemoryStreamManager();

            Document pdfDoc = null;
            for (var index = 0; index < htmlPages.Count; index++) // using for loop instead of foreach to increase performance
            {
                var page = htmlPages[index];
                var sourceBuffer = Encoding.UTF8.GetBytes(page);
            using (var ms = manager.GetStream(null, sourceBuffer, 0, sourceBuffer.Length))
            {
                var doc = new Document(ms, options);
                if (pdfDoc == null) {
                    pdfDoc = doc;
                }
                else {
                    pdfDoc.Pages.Add(doc.Pages);
                }
            }
        }

The specific line: var doc = new Document(ms, options); takes a very long time to complete and causes a bottleneck for the rest of the application. What can I do to improve the performance of creating a new PDF?

@jkurian,

Can you please share source file so that we may further investigate to help you out. Also please try to use Aspose.PDF latest version 20.1 on your before sharing requested information.

1 Like

I donā€™t have the ability to update to Aspose.PDF 20.1 due to license restrictions. But I have attached the source file. PdfConversionService.zip (1.2 KB)

@jkurian,

I like to inform that support is always provided based on latest version. Please try to use latest version on your end. This will resolve your issue as well. You may use trial license with latest version of product.