using IronPdf;
var renderer = new ChromePdfRenderer();
// Set Margins (in millimeters)
renderer.RenderingOptions.MarginTop = 40;
renderer.RenderingOptions.MarginLeft = 20;
renderer.RenderingOptions.MarginRight = 20;
renderer.RenderingOptions.MarginBottom = 40;
renderer.RenderHtmlFileAsPdf("my-content.html").SaveAs("my-content.pdf");
Imports IronPdf
Private renderer = New ChromePdfRenderer()
' Set Margins (in millimeters)
renderer.RenderingOptions.MarginTop = 40
renderer.RenderingOptions.MarginLeft = 20
renderer.RenderingOptions.MarginRight = 20
renderer.RenderingOptions.MarginBottom = 40
renderer.RenderHtmlFileAsPdf("my-content.html").SaveAs("my-content.pdf")
Install-Package IronPdf
设置自定义边距
IronPDF 允许你使用 RenderingOptions 将页边距编辑为任意值。ChromePdfRenderer` 的 HTML 到 PDF 输出选项指定了纸张大小、DPI、页眉和页脚等选项,以及其他 Chromium 特定的浏览器设置选项。我们还可以使用该功能设置自定义页边距。