首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在MVC中使用HiQPdf转换为PDF时出错

在MVC中使用HiQPdf转换为PDF时出错
EN

Stack Overflow用户
提问于 2016-01-06 14:42:56
回答 2查看 2.6K关注 0票数 2

我试图使用HiQPdf将我的html代码转换为PDF。但我的错误越来越少了。尽管"HiQPdf.dep“和"HiQPdf.dll”是相同的位置。

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

以下是方法:

代码语言:javascript
复制
 // 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;

请在这个问题上提供帮助。

你好,阿南德

EN

回答 2

Stack Overflow用户

发布于 2019-05-27 11:55:11

我解决了这个错误,在我的主机提供程序中授予App_Data、Bin和Content (其中我保存pdf文件)文件夹的写权限。

票数 1
EN

Stack Overflow用户

发布于 2016-02-16 09:34:51

引发此错误是因为您试图将该库用于32位计算机上的64位环境。您必须使用与32位和64位计算机兼容的库的正常版本,或者更好的是,您可以在64位计算机上运行转换器。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34635841

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档