2016-01-06 50 views
0

我正在尝试使用HiQPdf将我的html代码转换为PDF。但我越来越低于错误。即使“HiQPdf.dep”和“HiQPdf.dll”是相同的位置。在MVC中使用HiQPdf转换为PDF时出现错误

在HiQPdf.dll中发生了“System.Exception”类型的异常,但未在用户代码中处理 附加信息:错误0xD8。检查HiQPdf.dep资源文件可以在HiQPdf.dll程序集附近找到,并且用户已经读取并执行此文件的权限。呼叫SetDepFilePath()方法,如果你放在HiQPdf.dep在不同的位置

下面是方法:

// get the HTML code of this view 
     string htmlToConvert = RenderViewAsString("GetHTMLView", null); 

     // the base URL to resolve relative images and css 
     String thisPageUrl = this.ControllerContext.HttpContext.Request.Url.AbsoluteUri; 
     String baseUrl = thisPageUrl.Substring(0, thisPageUrl.Length - "tblWSRDetails/ConvertWSRReportToPdf".Length); 

     // instantiate the HiQPdf HTML to PDF converter 
     HtmlToPdf htmlToPdfConverter = new HtmlToPdf(); 

     // hide the button in the created PDF 
     htmlToPdfConverter.HiddenHtmlElements = new string[] { "#ConvertReportToPdf" }; 

     // render the HTML code as PDF in memory 
     byte[] pdfBuffer = htmlToPdfConverter.ConvertHtmlToMemory(htmlToConvert, baseUrl); 

     // send the PDF file to browser 
     FileResult fileResult = new FileContentResult(pdfBuffer, "application/pdf"); 
     fileResult.FileDownloadName = "WSR.pdf"; 

     return fileResult; 

对这个问题请帮助。

问候, 阿南德

回答

0

,因为你要使用64位环境库中的32位机器上的错误被抛出。您必须使用与32位和64位计算机兼容的库的正常版本,或者甚至可以在64位计算机上运行该转换器。

相关问题