1

I am working on a c# web application and using NReco.PdfGenerator to generate a pdf. PDF is generating fine with Header and Footer.

I am using "PageHeaderHtml" and "PageFooterHtml" to generate header footer.

Now I need to set specific height for Header and Footer, so that the mail contain comes in between that. How can I achieve that

Soumen Halder
  • 117
  • 1
  • 13
  • I'm thinking that it can be controlled via the html/css of the page header/footer html that you put inside. I have only used a similar library that is like yours that is based on wkhtmltopdf. – Markuzy Jul 24 '20 at 14:16
  • Did you find the answer – Jeeva J Mar 23 '21 at 05:21

1 Answers1

0

you need to set the top an bottom margin with the prperty NReco.PdfGenerator.PageMargins like:

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;