我正在尝试使用 HiQPdf 将我的 html 代码转换为 PDF。但我得到以下错误。即使“HiQPdf.dep”和“HiQPdf.dll”在同一个位置。
HiQPdf.dll 中出现“System.Exception”类型的异常,但未在用户代码中处理附加信息:错误 0xD8。检查 HiQPdf.dep 资源文件可以在 HiQPdf.dll 程序集附近找到,并且用户具有该文件的读取和执行权限。如果您将 HiQPdf.dep 放在不同的位置,请调用 SetDepFilePath() 方法
下面是方法:
// 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;
请帮助解决这个问题。
问候,阿南德