How to Set Height of a PDF header, footer in c# web application(Using NReco.PdfGenerator)

893 views Asked by At

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

1

There are 1 answers

0
ragePolpette On

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;