Stackoverflow Exception converting from docx


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();

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

                using (var memoryFilter = new MemoryFilter(0, false))
                using (var filterWriter = new FilterWriter(memoryFilter))

                    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)
                throw ex;

            return pdfDoc;

PDFNet version
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?



The issue is that IIS defaults to 256KB which is too small for this type of document conversion.

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