Rotativa is a great tool used to convert your html views to PDF files in web projects, it works fine with ASP.Net webforms and MVC where razor views can be converted to readable pdf, more information about Rotativa in the link below:
Rotativa Official website
You can Also download Rotativa for ASP.Net Nuget package in this link.
Rotativa Nuget
While working on different servers I have an error with unhandled exception when using rotativa, the error was:
Exception Description:: System.Exception at Rotativa.WkhtmltopdfDriver.Convert(String wkhtmltopdfPath, String switches, String html) at Rotativa.WkhtmltopdfDriver.Convert(String wkhtmltopdfPath, String switches) at Rotativa.AsPdfResultBase.CallTheDriver(ControllerContext context) at Rotativa.AsPdfResultBase.BuildPdf(ControllerContext context) at Rotativa.AsPdfResultBase.ExecuteResult(ControllerContext context) at System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass1e.<>c__DisplayClass28.b__19() at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass1e.b__1b(IAsyncResult asyncResult)
After investigating with the issue, I start thinking of running the Rotativa execution program from the Command Prompt, like this:
wkhtmltopdf.exe README.txt test.pdf
So I Got an error:
This error is a missing C++ redistributable Package for Visual studio 2013 file called (MSVCP120.dll).
To solve the issue:
1. Open the C++ redistributable Package for Visual studio 2013 downloadable link below:
download Visual C++ Redistributable Packages for Visual Studio 2013
2. Click Download and choose the file (vcredist_x86.exe) even if you are running X64 bit server version.
3. Install the file.
this will add the missing dll file mentioned above, and the problem is now solved.
Happy Codding.
Rotativa Official website
You can Also download Rotativa for ASP.Net Nuget package in this link.
Rotativa Nuget
While working on different servers I have an error with unhandled exception when using rotativa, the error was:
Exception Description:: System.Exception at Rotativa.WkhtmltopdfDriver.Convert(String wkhtmltopdfPath, String switches, String html) at Rotativa.WkhtmltopdfDriver.Convert(String wkhtmltopdfPath, String switches) at Rotativa.AsPdfResultBase.CallTheDriver(ControllerContext context) at Rotativa.AsPdfResultBase.BuildPdf(ControllerContext context) at Rotativa.AsPdfResultBase.ExecuteResult(ControllerContext context) at System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass1e.<>c__DisplayClass28.b__19() at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass1e.b__1b(IAsyncResult asyncResult)
After investigating with the issue, I start thinking of running the Rotativa execution program from the Command Prompt, like this:
wkhtmltopdf.exe README.txt test.pdf
So I Got an error:
This error is a missing C++ redistributable Package for Visual studio 2013 file called (MSVCP120.dll).
To solve the issue:
1. Open the C++ redistributable Package for Visual studio 2013 downloadable link below:
download Visual C++ Redistributable Packages for Visual Studio 2013
2. Click Download and choose the file (vcredist_x86.exe) even if you are running X64 bit server version.
3. Install the file.
this will add the missing dll file mentioned above, and the problem is now solved.
Happy Codding.
Hi Jalal... Thank you very much for your post.
ReplyDeleteBut I can't install this file on server. Is there a way to do this work just adding this dll as reference to my project?
Thank you
Hello Thiago, thanx for asking.
DeleteReally i didn't tried to use only the dll file as reference to the project, but i'm not sure it will work, because at the end the dll will call the wkhtmltopdf.exe to execute the conversion.
So I think you have to install the Rotativa Nuget.
u need to buy vps server , bec on that u can connect to server through remote desktop connection , and it will be a whole computer as u will have in local .
DeleteJalal Hijazi Blog: Solving Rotativa Unhandled Exception Error >>>>> Download Now
Delete>>>>> Download Full
Jalal Hijazi Blog: Solving Rotativa Unhandled Exception Error >>>>> Download LINK
>>>>> Download Now
Jalal Hijazi Blog: Solving Rotativa Unhandled Exception Error >>>>> Download Full
>>>>> Download LINK Gd
Hi Jilal,
ReplyDeleteI am also facing the same issue..Is it sufficient to install that exe file on my sever ..???
Thanks Advance.:-)
Hi Hari krishna Allu, did you fix your problem just installing the .exe file on your server?
DeleteHello Hari, Elvis
DeleteI think you need to copy the Nuget folder which contains the Rotativa dll and exe files to your server and run the wkhtmltopdf.exe, it should work
Hello, thanks, I just fix the problem copying the following file to the Rotativa folder in the server.
Deletehttps://drive.google.com/file/d/0BzI_u_O3vUM1aEppb3ZVZXNsc28/view
Thank you Elvis Rocha... this fix the problem.
DeleteThanx Buddy Elvis Rocha. I have this file in my rotativa folder but still not working then I downlead your link file and replace there and its worked for Me
DeleteGreat post - thank you! I had exactly this issue.
ReplyDeleteFollowing your comments, I just copied msvcp120.dll and msvcr120.dll to the folder containing wkhtmltopdf.exe and all worked fine.
Thanks for your help,
Clive
I'm glad that it helped you in some way.
DeleteHappy Coding :)
Thanks!!!
DeleteThis is really working: "I just copied msvcp120.dll and msvcr120.dll to the folder containing wkhtmltopdf.exe and all worked fine"
Thank you! - You saved my morning! :)
ReplyDeleteI'm very happy to help others.
DeleteThanks Very much for the fix. I appreciate it. I copied the dlls into published Rotativa folder on hosting server as @Clive N said and it fixed the problem.
ReplyDeleteGlad to hear that.
DeleteThank you very much! This saved me a lot of time!
ReplyDeleteBest regards, Janno
You are welcome any time
DeleteThanks @jalal. After installing C++ redistributable Package for Visual studio 2013 on server I fixed my issue
ReplyDeleteNot a problem... Glad I have helped you
DeleteThx!!!
ReplyDeleteThx!! Its work for me by replacing 'wkhtmltopdf.exe' in Rotativa Folder.
ReplyDeleteHi Omprakash I don't understand by what you replaced the 'wkhtmltopdf.exe'
DeleteSincere appreciation here... I added the 2 DLL files to the Rotativa folder on my server, and everything is working as expected!
ReplyDelete32 or 64 bits?
DeleteThis comment has been removed by the author.
ReplyDeleteThis really saved my day ... I did an update of the NuGet package and it broke down
ReplyDeleteThanks a million !
Happy it helped you in some way
Deleteserver is not giving permission to wkhtmltopdf.exe
ReplyDeletemaybe you may install it using administrator privileges.
Deletethanks guys that really helped me..I was also having the same error
ReplyDelete:) Glad it helped you
Deletethanks guys.. it really helped me.I was planning to change the solution for generating pdf.But at last it works.. !!! - Vivek
ReplyDeleteGood job! it really helped me...
ReplyDeleteGood, keep coding :)
DeleteThanks it worked..!!
ReplyDeleteThanks a lot! You saved my day!
ReplyDeleteI'm happy to hear that.
DeleteThanks Jalal.
ReplyDeleteSuccess :)
:) Glad to help you
DeleteI am having shared hosting, Not allow to upload rotativa.exe, is any other solution.
ReplyDeletecan somebody tell me where i can find these files in the system so that i can copy them to the server. Thanks ,
ReplyDeleteThanks a lot :)
ReplyDeleteI love you
ReplyDeleteIm afraid, that copying the two .dll files to my server did NOT solve my problem. I still get System.Exception error :-(
ReplyDeleteIs there any other things i can try. I have no access to installing things on server.
Same here, did you end up resolving this Johnny?
DeleteInstall from https://wkhtmltopdf.org/downloads.html (in my case I have downloaded - MSVC 2015 win64 Installer for Windows Vista or later
ReplyDeleteFrom installer path I copied wkhtmltoimage.exe, wkhtmltopdf.exe, wkhtmltox.dll to Rotativa folder and it worked.
wowwwww i though that this article was worthless but this comment is damn osm. i downloaded the dlls for my window server from
Deletethis https://wkhtmltopdf.org/downloads.html and paste into www/Rotativa folder and its worked on aws. woww..
Hello Jalal , i faced the same issue i tried your solution but i am using 2 diffrent domain for same site and its working for one and not working for another also the application is also not working when i click on download.
ReplyDeleteHave you got answer,i am also facing the same
DeleteHi,
ReplyDeleteWhat a fantastic post! This is so chock full of useful information. I can’t wait to dig deep and start utilizing the resources you have given me. This information will definitely help me.
Hello Jalal.
ReplyDeleteI have published my file locally in IIS , I am trying to generate in Hindi and English language . It works fine while I run my program but after publish all Hindi letter converts into black square. I have checked all the possible solution but didn't help.
please help me on this .
I am facing the same issue but I am getting this error when i am running on my local but after deploying its working fine what to do?
ReplyDelete