Reputation: 426
I am using HiQPdf plugin to convert a page (a customer invoice) to pdf on ASP.NET MVC app. It works fine on localhost but throws error after I publish it to Godaddy shared hosting server. This is the error it throws:
Error 0x4EC. Check the 'G:**\domain.com\Content\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
I have been searching since yesterday with no avail, I have confirmed that the HiQPdf.dep exist in Content folder, these are what I've tried and all worked locally but none solved the issue on GoDaddy:
Copied the HiQPdf.dep to Content folder and used the SetDepFilePath() method to refer to it.
// init model var model = _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;
I changed permissions for both the HiQPdf.dep file and Content folder on GoDaddy to full control, didn't work too.
I have set the trust level to Full in the web.config, still solving the issue.
Upvotes: 3
Views: 851
Reputation: 6056
I have same issue. I fixed it by copying the file HiQPdf.dep file in "bin" folder.
Upvotes: 0