使用EO.Pdf将.xls转换为.pdf

时间:2014-01-09 14:12:34

标签: c# pdf-generation

当我尝试转换小.xls个文件(30-200 kb)时,一切正常,但是当我尝试转换大.xls个文件(50 mb)时,我遇到了问题。< / p>

这是我的代码:

string filePathDoc = "C:\\Users\\vgocov\\Desktop\\testPDF\\freelimits_20140107.xls"; 
string filePathPdf = "C:\\Users\\vgocov\\Desktop\\testPDF\\freelimits_20140107.pdf";

HtmlToPdfOptions options = new HtmlToPdfOptions();
options.PageSize = EO.Pdf.PdfPageSizes.A4;

HtmlToPdf.ConvertHtml(File.ReadAllText(filePathDoc, filePathPdf, options); 

例外是:

System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

1 个答案:

答案 0 :(得分:0)

原因可能是因为您计算机上的用户帐户没有足够的权限来执行此操作,或者文件可能设置为ReadOnly。在localhost上,您可能正在使用管理员帐户,而在生产/实时服务器中则不是这样。

检查以下链接,看看是否有任何可能对您有所帮助:

http://social.msdn.microsoft.com/Forums/en-US/8789ea67-fbc5-4a7b-a4eb-d4a8a050d5c1/attempt-to-read-or-write-protected-memory-this-is-often-an-indicating-that-other-memory-is-corrupt

http://social.msdn.microsoft.com/Forums/vstudio/en-US/4f48c152-68cd-45ec-a11e-baa7de7f79c3/attempted-to-read-or-write-protected-memory?forum=csharpgeneral

System.AccessViolationException: Attempted to read or write protected memory