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
close icon

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. 

Regards, 
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
  HResult=0x8007000E
  Source=<Cannot evaluate the exception source>
  StackTrace:
<Cannot evaluate the exception stack trace>

Thank you for your help.
Alisha


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.
http://www.syncfusion.com/downloads/support/forum/142517/ze/Test653358828

Please find the machine configuration:
 
OS 
Windows 10 
RAM 
8 GB 
Processor 
Intel Core I5 
Visual Studio version 
2017 
Project target mode 
X86 
Product version 
16.2.0.41 

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.

Regards,
Vijay R


Loader.
Live Chat Icon For mobile
Up arrow icon