I want to generate a .pdf file using Rotativa, my ajax call is as follows:
$.ajax({
type: "POST",
url: "Home/Index",
data: { nome: inputName, laudos: laudos, imagem: imgSelecionada },
});
And the code in Action is this:
[HttpPost]
public ActionResult Index(UsuarioViewModel user)
{
string header = Server.MapPath("~/Views/Home/Header2.html");
string footer = Server.MapPath("~/Views/Home/Footer.html");
string customSwitches = string.Format("--header-html \"{0}\" " +
"--header-spacing \"0\" " +
"--footer-html \"{1}\" " +
"--footer-spacing \"5\" ", header, footer);
var pdf = new ViewAsPdf
{
ViewName = "Modelo",
Model = user,
CustomSwitches = customSwitches
};
return pdf;
}
Is it really possible to do something like this or should I use another approach? After much research, I have seen in some places that the Rotativa does not work very well with ajax requests.