核心 asp.net Rotativa PDF 不能有页眉和页脚



我有时获取页眉和页脚时遇到了一些麻烦 在 rotativa 中生成的 PDF 中 asp.net 核心 .

这是我的控制器代码:

   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 }  
                    };

如果我删除页脚,页眉会正确显示.如果我删除页眉,页脚会正确显示.

如您所见,页眉和页脚是动态生成的。

知道

发生了什么吗?

罗塔蒂瓦版本 : 1.0.6

WKHTMLTOPDF 版本 : 0.12.5 (带有修补的 qt)

谢谢。

经过很多麻烦,这对我有用:

 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 }  
        }; 

这一切都是关于间距奇怪的参数:)

最新更新