Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rotativa pdf not working after deploying to IIS on server

I'm using Rotativa for converting html to pdf on my asp.net mvc website. It works fine locally, but after I deploy on the server, it just returns a text saying "Rotativa.ViewAsPdf", that is the method name I'm calling in my C# code. There's no exception/errors, nothing in the logs and event viewer.

I have given full permissions to wkhtmltodf.exe, the Rotativa folder too. There's also Rotativa.dll present inside the bin directory. Also, I have installed MSCVP120.dll on the server, but I'm not able to figure out what could be the problem. Please help.

like image 900
sharath.g Avatar asked Sep 26 '22 06:09

sharath.g


2 Answers

Found the solution! :) Thanks https://stackoverflow.com/a/21690696/1542798

I'm using System.Web.Mvc 5.2.3, so I had to change the binding redirect in my web.config form 5.0.0 to 5.2.3

<dependentAssembly>
    <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
    <bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.2.3.0"/>
  </dependentAssembly>
like image 117
sharath.g Avatar answered Sep 27 '22 20:09

sharath.g


c:\inetpub\wwwroot\DummyProject\Rotativa\wkhtmltopdf.exe d:\Pdf\Dummy.html d:\Pdf\Dummy.pdf

you can try to run this line on the cmd to check the problem

replace the "c:\" path with the project path and the HTML path with any of your HTML files and the pdf path with any place you want to replace your path

this will make you check what's the problem

in my case there's missing ddls that required to be installed "msvcp120.dll"

if it's the same problem with you, you can check these steps to solve it

https://www.smarterasp.net/support/kb/a1702/sample-process-to-generate-pdf-with-rotativa-in-asp_net-mvc.aspx

like image 32
Sandy Elkassar Avatar answered Sep 27 '22 19:09

Sandy Elkassar