问题描述
我正在使用 HiQPdf 插件在 ASP.NET MVC 应用程序上将页面(客户发票)转换为 pdf。它在本地主机上运行良好,但在我将其发布到 Godaddy 共享托管服务器后抛出错误。这是它抛出的错误:
错误 0x4EC。检查可以在 HiQPdf.dll 程序集附近找到“G:**\domain.com\Content\HiQPdf.dep”资源文件,并且用户对该文件具有读取和执行权限。如果您将 HiQPdf.dep 放在不同的位置,请调用 SetDepFilePath() 方法
我从昨天开始一直在搜索,但没有结果,我已经确认 HiQPdf.dep 存在于 Content 文件夹中,这些是我尝试过的并且都在本地工作,但都没有在 GoDaddy 上解决问题:
-
将 HiQPdf.dep 复制到 Content 文件夹并使用 SetDepFilePath() 方法引用它。
//初始化模型 var 模型 = _db.Invoice.Where(x => x.InvoiceId == invoiceId && !x.Draft) .ToArray().Select(x => new InvoiceVM(x)).FirstOrDefault();
// convert a page to string (update the path to the right page) string html = RenderViewToString(ControllerContext,"~/views/home/_InvoiceDoc.cshtml",model); // start creating pdf doc // the base URL to resolve relative images and css string thisPageUrl = this.ControllerContext.HttpContext.Request.Url.AbsoluteUri; string baseUrl = thisPageUrl.Substring(0,thisPageUrl.Length -"Home/ConvertThisPagetoPdf".Length); // instantiate the HiQPdf HTML to PDF converter HtmlToPdf htmlToPdfConverter = new HtmlToPdf(); htmlToPdfConverter.SetDepFilePath(Server.MapPath("~/Content/HiQPdf.dep")); // render the HTML code as PDF in memory byte[] pdfBuffer = htmlToPdfConverter.ConvertHtmlToMemory(html,baseUrl); // send the PDF file to browser FileResult fileResult = new FileContentResult(pdfBuffer,"application/pdf"); fileResult.FileDownloadName = "Invoice-" + model.InvoiceNumber + ".pdf"; return fileResult;
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)