Rotativa ignoring Boostrap CSS when published to the server
Asked Answered
P

4

5

Rotativa correctly shows and renders a PDF with my Bootstrap when hosted locally, but not once it is posted to the server. The rendered PDF shows some CSS, but no Bootstrap. I have seen other posts about this, but the suggestions did not work. The Rotativa folder is in the root of the web app as suggested.

Piggish answered 5/6, 2015 at 13:44 Comment(1)
make sure your files path on the server matches the ones locally. or at least adjust your code.Inherit
H
23

I had the same issue, and solved it by changing it to something like:

<link href="@Server.MapPath("~/Content/bootstrap.min.css")" rel="stylesheet" />
Hallvard answered 20/7, 2015 at 14:40 Comment(2)
I eventually did just have to include the style sheet explicitly on that page, not the layout page. It worked.Piggish
Server.MapPath was the key for me, for images as well.Firestone
I
0

If you are using bundles, .min files are ignored by default so my best guess will be to use this:

bundles.IgnoreList.Clear();

I don't know if you have already created the bundles:

<!--Create route for the bundles like this:-->
bundles.Add(new StyleBundle("~/Content/css").Include(
            "~/Content/bootstrap.min.css",
            "~/Content/main.css"));
Inherit answered 5/6, 2015 at 13:59 Comment(1)
I have both the bundle you suggested and the IgnoreList.Clear(); I have just tried creating a user in Active Directory and passing the credentials as Custom Switches, but so far that does not work either. According to research I just did, adding Active Directory authentication breaks Rotativa. Any suggestions on how to circumvent that would be helpful and thanks for the above ideas.Piggish
U
0

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>
Unbearable answered 22/8, 2016 at 16:14 Comment(0)
D
0

One of these 3 things fixed this issue for us. we used https://www.w3schools.com/w3css/w3css_validation.asp to validate our css, and found some minor problems, which we corrected.

We used Ozz's fix.

As before, it worked normally for us in IIS Express on our desktops.

Then we published the app to the webserver and noticed that it was now working.

So it was either

  1. Ozz's fix
  2. Rotativa freaked out at our malformed css (but why only on the webserver?)
  3. just recopying the app up from our local desktops to the web server "unclogged" something.

We're still testing, but first pass it looks like this worked.

Deathbed answered 30/6, 2021 at 23:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.