Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Tue Jan 12, 2016 1:21 pm

Hi,

In some cases, when I try to convert a document with format docx to pdf, the code throws the exception "An unhandled exception of type 'System.StackOverflowException' occurred in System.Drawing.dll".

I don't know if this exception is generated for the content of document.

I attach the document, that I can't convert to pdf.

The code:

public static void conversionDoc() {

string fileRoot = @"C:\Legalitas_Temp\20160112125241_Multa1.docx";
FileInfo f = new FileInfo(fileRoot);
Document doc = new Document();
doc.LoadFromFile(fileRoot,Spire.Doc.FileFormat.Doc);
string fileName = f.Name;
fileName = fileName.Replace(".doc", ".pdf");
string newFileToSave = f.FullName.Replace(f.Name, fileName);
doc.SaveToFile(newFileToSave, Spire.Doc.FileFormat.PDF);
}


Thanks!

Blanquita_84
 
Posts: 44
Joined: Tue Oct 13, 2015 8:58 am

Wed Jan 13, 2016 3:43 am

Hi,

Thanks for your posting.
I tested your word document with Spire.Office Platinum (Hot Fix) Version:2.12.8. There was any error and the result was correct. Please try the version.
There is a line doc.LoadFromFile(fileRoot,Spire.Doc.FileFormat.Doc); in your code, please modify to the correct version, likes doc.LoadFromFile(fileRoot,Spire.Doc.FileFormat.Docx2013);.

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 3046
Joined: Wed Jun 27, 2012 8:50 am

Thu Jan 14, 2016 8:50 am

Hi,

Has your issue been resolved?
Thanks for your feedback.

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 3046
Joined: Wed Jun 27, 2012 8:50 am

Return to Spire.Doc