Search code examples
asp.net-mvcmodel-view-controllerrotativa

Footer Html is not showing on PDF generated using Rotativa 1.6.1


I am using Rotativa 1.6.1 version for converting views to PDF. Now I am trying to show footer text with images on all pages. I used following code snippets:

string customSwitches = string.Format("--header-html  \"{0}\" " +
                               "--header-spacing \"0\" " +
                               "--footer-html \"{1}\" " +
                               "--footer-spacing \"10\" " +
                               "--footer-font-size \"10\" " +
                               "--header-font-size \"10\" ", header, footer);

        return new Rotativa.ViewAsPdf("_PDF_Desgin.cshtml", List)//_PDF_Desgin.cshtml is control Page
        {
            FileName = "PdfFileName.pdf",
            PageSize = Size.A4,
            PageOrientation = Orientation.Landscape,
            CustomSwitches = customSwitches
        }; 

But unfortunately it is not working in my case. Can you help me to figure out the correct usage for displaying footer text with images on all generated PDF files.

Thanks and regards, Viju.


Solution

  • I have figure out the issue and displayed the footer template by using PageMargins attribute.

    return new Rotativa.ViewAsPdf("_PDF_Desgin.cshtml", List)//_PDF_Desgin.cshtml is control Page
    {
        FileName = fileName,
        IsJavaScriptDisabled = false,
        CustomSwitches = customSwitches,
        // CustomSwitches = "--no-stop-slow-scripts --print-media-type --javascript-delay 5000 --disable-smart-shrinking",
        PageOrientation = Rotativa.Options.Orientation.Portrait,
        PageSize = Rotativa.Options.Size.A4,
        PageMargins = new Margins(0, 3, 32, 3),
    };
    

    Thanks and regards, Viju