如何使用 NReco.PdfGenerator 设置边距?
How do I set margins with NReco.PdfGenerator?
我使用 NReco.PDFGenerator 成功更改了许多设置,但我不明白如何设置页边距。我找到了 .Margins
选项,但它希望类型为 PageMargins
。以下是我尝试过的一些事情。如何设置上、左、下、右页边距?
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
设置边距:
pdfConverter.Margins = new PageMargins {Top = 1, Bottom = 1, Left = 1, Right = 1}
或
var margins = new PageMargins();
margins.Top = 1;
margins.Bottom = 1;
margins.Left= 1;
margins.Right= 1;
pdfConverter.Margins = margins;
(假设:using NReco.PdfGenerator;
)
他们做同样的事情,即将所有边距设置为1mm。
您可以在这里阅读更多内容:http://www.nrecosite.com/doc/NReco.PdfGenerator/
我使用 NReco.PDFGenerator 成功更改了许多设置,但我不明白如何设置页边距。我找到了 .Margins
选项,但它希望类型为 PageMargins
。以下是我尝试过的一些事情。如何设置上、左、下、右页边距?
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
设置边距:
pdfConverter.Margins = new PageMargins {Top = 1, Bottom = 1, Left = 1, Right = 1}
或
var margins = new PageMargins();
margins.Top = 1;
margins.Bottom = 1;
margins.Left= 1;
margins.Right= 1;
pdfConverter.Margins = margins;
(假设:using NReco.PdfGenerator;
)
他们做同样的事情,即将所有边距设置为1mm。 您可以在这里阅读更多内容:http://www.nrecosite.com/doc/NReco.PdfGenerator/