2

I am trying to use HiQPdf for converting my html code to PDF. but i am getting below error. Even though "HiQPdf.dep" and "HiQPdf.dll" are same location.

An exception of type 'System.Exception' occurred in HiQPdf.dll but was not handled in user code Additional information: Error 0xD8. Check the HiQPdf.dep resource file can be found near the HiQPdf.dll assembly and the user has read and execute permissions for this file. Call SetDepFilePath() method if you placed the HiQPdf.dep in a different location

Below is the method:

 // 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;

Please help on the issue.

Regards, Anand

Anand
  • 171
  • 2
  • 4
  • 12

2 Answers2

1

I solved this error granting write permission in App_Data, Bin and Content (where I save the pdf file) folders in my host provider.

Almeida
  • 1,254
  • 12
  • 26
0

The error is thrown because you are trying to use the library for 64-bit environments on a 32-bit machine. You have to use the normal version of the library which is compatible with both 32-bit and 64-bit machines or even better you can run the converter on a 64-bit machine.

HiQPdf
  • 142
  • 5