how to set image on Header or Footer in Rotativa PDF
Asked Answered
B

1

5

I need to insert some image on Header or Footer using Rotativa PDF.

I'm using C# MVC4 with Razor

I already tried: CustomSwitches = "--print-media-type --header-center \"text\""

Below answered 1/10, 2014 at 19:5 Comment(0)
N
8

If you wanted to display a View instead of text in the header/footer then you could add the image to the View.

public ActionResult ViewPDF()
{
      string cusomtSwitches = string.Format("--print-media-type --allow {0} --footer-html {0}"
                Url.Action("Footer", "Document", new { area = ""}, "https"));


     return new ViewAsPdf("MyPDF.cshtml", model)
                {
                    FileName = "MyPDF.pdf",
                    CustomSwitches = customSwitches
                };
}

[AllowAnonymous]
public ActionResult Footer()
{
    return View();
}

Don't forget to add the [AllowAnonymous] attribute on the Footer action otherwise Rotatina can't get access to the path.

Nevernever answered 24/10, 2014 at 10:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.