如何在c#web应用程序中设置PDF页眉、页脚的高度(使用NReco.PdfGenerator)



我正在开发一个c#web应用程序,并使用NReco.PdfGenerator生成pdf。PDF正在生成良好的页眉和页脚。

我正在使用";PageHeaderHtml";以及";PageFooterHtml";以生成页眉页脚。

现在,我需要为页眉和页脚设置特定的高度,以便邮件包含在这两者之间。我如何实现

您需要使用prperty NReco.PdfGenerator.PageMargins设置上下边距,如:

NReco.PdfGenerator.PageMargins margin = new NReco.PdfGenerator.PageMargins();
margin.Top = 20;
margin.Left = 0;
margin.Right = 0;
margin.Bottom = 20;
var htmlToPdf = new NReco.PdfGenerator.HtmlToPdfConverter();
htmlToPdf.LowQuality = true;
htmlToPdf.PageWidth = 210;
htmlToPdf.PageHeight = 297;
htmlToPdf.Margins = margin;
htmlToPdf.PageHeaderHtml = htmlHeader;
htmlToPdf.PageFooterHtml = htmlFooter;

最新更新