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\""
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\""
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.
© 2022 - 2024 — McMap. All rights reserved.