Search code examples
c#pdfmodel-view-controllerrotativa

Margin options in Pdf with Rotativa Mvc


I have been reading that to put or remove the margins of a PDF the following line is used:

PageMargins = new Rotativa.Core.Options.Margins(0,0,0,0)

But, when I enter them I get the following:

enter image description here

'ViewAsPDF' does not contain a definition for 'PageMargins'

Any solution?

This is the complete code:

return new ViewAsPdf("Pdf48", c.cargarDatosPDF(solicitud))
                    {
                        CustomSwitches = "--header-html " + _headerUrl + " --header-spacing 0 " +
                                 "--footer-html " + _footerUrl + " --footer-spacing 0",
                       PageMargins = new Rotativa.Core.Options.Margins(0,0,0,0)                
                    };

Solution

  • Solution:

    return new PartialViewAsPdf("Pdf48", c.cargarDatosPDF(solicitud))
                        {
                            RotativaOptions = new Rotativa.Core.DriverOptions
                            {
                                CustomSwitches = "--header-html " + _headerUrl + " --header-spacing 0 " +
                                    "--footer-html " + _footerUrl + " --footer-spacing 0",
                                PageMargins = new Rotativa.Core.Options.Margins(0, 0, 0, 0)
                            }
                    };