We are using Rotativa to save a permanent PDF copy of the page on the web server. Here is the ASP.NET MVC 4 code to build and save it:
var pdfResult = new ActionAsPdf("Index", new { orderId = orderValidated.orderID }) { FileName = filePath };
var binary = pdfResult.BuildPdf(ControllerContext);
// writes only if the file does not exist, we need to keep first authentic print of it.
if (System.IO.File.Exists(filePath) == false)
{
System.IO.File.WriteAllBytes(filePath, binary);
}
We use a specific 'css' file for printing in the page <head>
section:
<head>
<link media=all href="/Content/invoice.css" type=text/css rel=stylesheet>
<link media=print href="/Content/printInv.css" type=text/css rel=stylesheet>
</head>
The 'css' print version contains:
#logo {background: url(/assets/images/logo-plain.gif) no-repeat; height: 56px}
and the *.gif image is missing from the PDF document (on screen is present).
Any idea on the reason why it's missing?
Thanks.
As far as I know, Rotativa has problems with gif images. Try using jpg or png.