4

Working locally the css and images are loaded in pdf correctly. But as soon as i migrate code on the server, these are not loaded in the generated pdf.

I am using ViewAsPDF(). There are some partial views in my code so I cannot use Server.Map.

Would really appreciate your help.

Regards

ozz
  • 5,098
  • 1
  • 50
  • 73
Abhishek
  • 41
  • 4
  • Your question sounds like crossposting? I'd say you've sent it to the maintainer already and I'd suggest you to wait for threir response first since they will likely help you faster than Stackoverflow can. – try-catch-finally Jul 15 '14 at 09:28

3 Answers3

1

Old post I know, but hopefully can help someone in the future.

This situation can occur when your site uses windows authentication.

You need to give access to your CSS files in the web.config as follows:

<location path="content">
    <system.web>
      <authorization>
        <allow users="*" />
      </authorization>
    </system.web>
  </location>
ozz
  • 5,098
  • 1
  • 50
  • 73
0

You need the Rotativa folder in the root of the web app, or if different provide the path in web.config.

habiat
  • 1,245
  • 3
  • 16
  • 22
0

I had the same problem, fixed up by service account or server logon user name and password on ViewAsPdf customswitches.

eg.

return new ViewAsPdf("PdfInvoice", model)
{
    CustomSwitches = string.Format("--username \"{1}\" --password \"{2}\" --footer-center \"Page [page] of [toPage] - {0}\" --footer-font-size \"8\" ", "Receipt Number :" + model.ReceiptId.ToString(), serviceAccountUsername.ToString(), serviceAccountPassword.ToString())
}; 
iikkoo
  • 2,810
  • 6
  • 33
  • 38