I am using Rotativa to generate a single PDF file for single invoice, in Asp.Net MVC application. I am using the command --header-html with CustomSwitches of ViewAsPdf to include header for each page of an Invoice as follows,
public ActionResult GenerateSingleInvoicePDF(string invoiceId)
{
var invoiceViewModel = new InvoicePDFModel();
... // get content from database;
...
...
ViewBag.InvoiceDetail = invoiceViewModel;
string customSwitches = string.Format("--print-media-type --allow {0} --header-html {0} --page-offset \"0\" --header-spacing \"1\" ", Url.Action("InvoiceHeader", "Order", new { invNumber =
invoiceViewModel.invNo, invDate = invoiceViewModel.InvoiceDateString, shippAddr = invoiceViewModel.DeliveryAddr, billingAddress = invoiceViewModel.BillingAddr }, "http"));
return new ViewAsPdf("~/SingleInvoiceView.cshtml")
{
FileName = "SingleInvoice.pdf",
PageSize = Size.A4,
CustomSwitches = customSwitches
};
}
This works perfectly without any issue. Now my need is how to generate a single PDF for multiple invoice. I tried the above code for multiple invoice as follows,
public ActionResult GenerateMultipleInvoicePDF(string invoiceIds)
{
var invoiceList = new List<InvoicePDFModel>
... // get list of content from database;
...
...
ViewBag.InvoiceList = invoiceList;
string customSwitches = // don't know how to define header view for multiple invoice.
return new ViewAsPdf("~/MultiInvoiceView.cshtml")
{
FileName = "MultiInvoice.pdf",
PageSize = Size.A4,
CustomSwitches = customSwitches
};
}
But I am stuck at the header part. Because, header content varies for each invoice. Any suggestions how to do this?