0

i have some trouble to get the header AND the footer at the same time in the generated PDF in rotativa asp.net core .

here my controller code :

   string customSwitches = string.Format(" --header-html {0} --footer-html {1}   ",

                              Url.Action("PDFHeader", "PDF", new { vinum = VINUM, YEAR="2018" }, "https") ,

                               Url.Action("PDFFooter", "PDF", new { }, "https"));

                    return new ViewAsPdf(res)
                    {
                        PageSize = Size.A4,
                        PageOrientation = Orientation.Portrait,
                        CustomSwitches = customSwitches ,
                         PageMargins = { Left = 20, Bottom = 20, Right = 20, Top = 20 }  

                    };

if i remove the footer the header show correctly . if i remove the header the footer show correctly .

as you can see the header and footer are dynamically generated .

any idea on what's going on ?

Rotativa version : 1.0.6

wkhtmltopdf version : 0.12.5 (with patched qt)

thanks .

user2475096
  • 350
  • 3
  • 19
  • 1
    This link might help you [Displaying headers and footers in a PDF generated by Rotativa](https://stackoverflow.com/questions/15250505/displaying-headers-and-footers-in-a-pdf-generated-by-rotativa) – John Jan 23 '19 at 08:18

1 Answers1

1

after lot of troubles, this what worked for me :

 string customSwitches = string.Format("--header-spacing \"0\" --footer-spacing \"0\" --header-html {0} --footer-html {1}   ",

            Url.Action("PDFHeader", "PDF", new { vinum = VINUM, YEAR="2018" }, "https") ,

            Url.Action("PDFFooter", "PDF", new { }, "https"));

            return new ViewAsPdf(res)
            {
                PageSize = Size.A4,
                PageOrientation = Orientation.Portrait ,
                CustomSwitches = customSwitches ,


       PageMargins = { Left = 10, Bottom = 33, Right = 10, Top = 50 }  

        }; 

it's all about spacing wierd parameters:)

user2475096
  • 350
  • 3
  • 19