Stackoverflow Exception converting from docx

Hi,

I am hitting a stackoverflow exception inside the TryConvert() call when trying to convert a docx file using the following code :

private static PDFDoc GeneratePDF(MemoryStream docStream)
        {
            var pdfDoc = new PDFDoc();
            pdfDoc.InitSecurityHandler();

            try
            {
                docStream.Seek(0, SeekOrigin.Begin);
                var streamBytes = docStream.ToArray();

                using (var memoryFilter = new MemoryFilter(0, false))
                using (var filterWriter = new FilterWriter(memoryFilter))
                {
                    filterWriter.WriteBuffer(streamBytes);
                    filterWriter.FlushAll();

                    var conversion = pdftron.PDF.Convert.WordToPDFConversion(pdfDoc, memoryFilter, null);
                    var result = conversion.TryConvert();

                    if (result != DocumentConversionResult.e_document_conversion_success)
                    {
                        throw new InvalidOperationException(conversion.GetErrorString());
                    }
                }
            }
            catch (Exception ex)
            {
                pdfDoc.Dispose();
                throw ex;
            }

            return pdfDoc;
        }

PDFNet version 6.8.56.6513
This seems to be true of any docx containing an image.
It only seems to be happening when PDFNet is running on a webserver (IIS)
I put together a Console Project to recreate it and the conversion works without any issues. Same code, same docx, same PDFNet version. It always fails on the webserver.

It's a stackoverflow so I've got very little to go on in the exception itself and obviously I've got no insight into what's happening in the TryConvert() method.

Any ideas?

Thanks,

Andrew

The issue is that IIS defaults to 256KB which is too small for this type of document conversion.
https://support.microsoft.com/en-us/help/932909/by-default-the-maximum-stack-size-of-a-thread-that-is-created-in-a-nat
https://blogs.msdn.microsoft.com/tom/2008/03/31/stack-sizes-in-iis-affects-asp-net/

Please increase the default size to something higher, e.g. 1MB.

Hi @Ryan, i’m using flask, i got the file FileStorage from request form-data. How can I parse FileStorage to MemoryStream? i need that for converting to pdf file like this post. Thank you