I know that this topic has been discuss on several articles, but none of the solution help me.
I have this action:
public ActionResult DownloadViewPDF(string userId)
{
var model = db.MyCvs.FirstOrDefault(u => u.UserId == userId);
if (model != null)
return new Rotativa.ViewAsPdf("ViewUserCv", model) { FileName = model.FirstName + model.LastName + "_CV.pdf" };
return Content("there is no Cv to download");
}
Using the above action I am downloading a view as pdf, and everything is working as expected on my computer.
After deploying the project on the server, this action is not working, is returning an error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
I am using Visual Studio Community 2015.
On the server I have the Rotativa.dll
and also the Folder in the root directory named Rotativa with the file inside named wkhtmltopdf.exe
.
I do not know how to handle this error, can you give me some sugestions?
I found a very simple tutorial how to fix my issue with rotativa, for those which have the same issue, please follow this tutorial:
Sample process to generate PDF with Rotativa in Asp.Net MVC
based on this tutorial, all we need to do is to:
Upload dlls:
because Rotativa need component of "Visual C++ Redistributable for Visual Studio".
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Packages\Debugger\X64\msvcp120.dll
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Packages\Debugger\X64\msvcr120.dll
You can refer above path on your local with your own specified path to find it. Upload them to "Rotativa" folder.
What worked for me was, I had files missing in the Rotativa folder,
help-wkhtmltoimage.txt
help-wkhtmltopdf.txt
msvcp120.dll
msvcp140.dll
msvcr120.dll
vcruntime140.dll
wkhtmltoimage.exe
wkhtmltopdf.exe
wkhtmltox.dll
Once I put those files in, it worked like a charm
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With