We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Converting large .docx to pdf

I am using the following code to convert a docx to pdf:
PdfDocument pdfDocument = new PdfDocument();
string filePath = Server.MapPath(new Uri(fileName).LocalPath);
if (fileName != null)
string fileExt = Path.GetExtension(fileName).Replace(".", "").ToUpper();
if (fileExt == EFileExtension.DOC.ToString() || fileExt == EFileExtension.DOCX.ToString())
DocToPDFConverter converter = new DocToPDFConverter();
Stream readFile = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read);
pdfDocument = converter.ConvertToPDF(readFile);
However when the size of the docx file is above 2mb, I am getting an out of memory error.
Any help please?

3 Replies

DB Dilli Babu Nandha Gopal Syncfusion Team February 8, 2019 06:54 AM UTC

Hi Alis, 

Thank you for contacting Syncfusion support. 

We suspect that the reported issue might be document specific i.e., elements presented in the document. So, kindly share us the issue causing input document which will be helpful for us to provide you a prompt solution at the earliest. 

If you have any confidential data in your Word document, please replace with some dummy data and provide us the same or send to support@syncfusion.com by mentioning this forum. We just need your document to recreate the problem you face. 

Dilli babu. 

AL Alis February 8, 2019 07:34 AM UTC

Hello Dilli,

I have attached the word document.  

Also the error message I am getting is:
System.OutOfMemoryException occurred
  Source=<Cannot evaluate the exception source>
<Cannot evaluate the exception stack trace>

Thank you for your help.

Attachment: Syncfusion_ee4bb9af.7z

VR Vijay Ramachandran Syncfusion Team February 11, 2019 12:09 PM UTC

Hi Alisha,

Thank you for your details.

We are unable to reproduce the reported OutOfMemoryException issue while converting the given Word document as PDF. Please find the project which we have used at our end to reproduce the issue from below.

Please find the machine configuration:
Windows 10 
8 GB 
Intel Core I5 
Visual Studio version 
Project target mode 
Product version 

Could you please provide us your machine configuration along with the product version details? Thereby we can setup the same environment and reproduce the issue.

Vijay R

Live Chat Icon For mobile
Up arrow icon