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

Free Support Forum - aspose.com

Aspose.Pdf.Document Save Null exception on heavy load

Under heavy load sometimes the Save(Stream outputStream, SaveOptions options) method throws a null exception.

I am unable to reproduce this consistently however, it does happen occasional when there is many concurrent conversions are happening at the same time.

Unfortunately the stack trace does not help much since the dlls are obfuscated.

at ​.(Stream )
at ​.()
at .()
at .(Document , Stream , DocSaveOptions )
at Aspose.Pdf.Document.(Stream , SaveOptions )
at Aspose.Pdf.Document.Save(Stream outputStream, SaveOptions options)

Calling code:

            using (var tmpStream = new MemoryStream())
               var tmpDoc = new Document(inputStream, true);
				if (tmpDoc.Pages.Count > pageLimit)
                    tmpDoc = TruncatePDFDocument(tmpDoc, pageLimit);

                tmpDoc.OptimizeResources(new Document.OptimizationOptions {
                    LinkDuplcateStreams = true,
                    RemoveUnusedObjects = true,
                    RemoveUnusedStreams = true,

                    tmpDoc.Save(tmpStream, new DocSaveOptions()
                        Format = DocSaveOptions.DocFormat.DocX,
                        Mode = DocSaveOptions.RecognitionMode.Textbox

                catch(Exception e)

                var result = ConvertWordToSVG(tmpStream, pageLimit, true);
                if(result == null)
                    _log.Error($"Failed PDF conversion, fallback to text.");
                    result = ConvertWordToSVG(tmpStream, pageLimit, false);

                return result;


Thank you for contacting support.

We are unable to compile the code snippet shared by you as it includes some undefined methods and variables. Would you please create a sample application along with source files reproducing this issue so that we may try to reproduce and investigate it in our environment. Also, elaborate heavy load scenario for our reference.