I succeeded at changing many settings with NReco.PDFGenerator, but I do not understand how to set the margins. I found a .Margins
option, yet it wants the type to be PageMargins
. Below are some things I tried. How do I set the top, left, bottom, and right margins?
HtmlToPdfConverter pdfConverter = new HtmlToPdfConverter();
pdfConverter.Size = PageSize.Letter;
pdfConverter.Orientation = PageOrientation.Landscape;
pdfConverter.Zoom = 1F;
pdfConverter.CustomWkHtmlArgs = "--encoding UTF-8";
// What I tried...
pdfConverter.Margins = (PageMargins)1; // can't caste
pdfConverter.Margins = PageMargins.????; // no appropriate methods
pdfConverter.Margins = 1; // wrong type
pdfConverter.Margins = "1"; // wrong type
To set the margins:
pdfConverter.Margins = new PageMargins {Top = 1, Bottom = 1, Left = 1, Right = 1}
or
var margins = new PageMargins();
margins.Top = 1;
margins.Bottom = 1;
margins.Left= 1;
margins.Right= 1;
pdfConverter.Margins = margins;
(Assuming: using NReco.PdfGenerator;
)
They do the same thing, ie will set all the margins to 1mm. You can read more here: http://www.nrecosite.com/doc/NReco.PdfGenerator/