使用 DinkToPDF 分页

Page Break with DinkToPDF

我正在使用 DinkToPDF NuGet,我想在第一页之后添加一个新的分页符。这可能吗?我知道它必须在 HTML 内完成,但是提供带有 100% height 的元素并没有达到预期的效果。

虽然不完美,但使用这些设置:

var globalSettings = new GlobalSettings
{
    ColorMode = ColorMode.Color,
    Orientation = Orientation.Portrait,
    PaperSize = PaperKind.A4,
    Margins = new MarginSettings { Top = 10 },
    DocumentTitle = "PDF Report"
};

var objectSettings = new ObjectSettings
{
    PagesCount = true,
    HtmlContent = html.ToString(),
    //Page = "https://code-maze.com/", USE THIS PROPERTY TO GENERATE PDF CONTENT FROM AN HTML PAGE
    WebSettings = { DefaultEncoding = "utf-8" }, //, UserStyleSheet = Path.Combine(Directory.GetCurrentDirectory(), "assets", "styles.css") },
    HeaderSettings = { FontName = "Arial", FontSize = 9, Right = "Page [page] of [toPage]", Line = true },
    FooterSettings = { FontName = "Arial", FontSize = 9, Line = true, Center = "Report Footer" }
};

我可以使用一个 HTML 文件,其中包含一系列 DIV 设置如下,使它们每个适合 1 个页面大小:

<div style="height: 1308px; overflow:hidden;">

我正在使用 https://github.com/rdvojmoc/DinkToPdf NuGet; 我们可以使用 CSS 样式

控制分页
table {
 page-break-inside: auto
}

tr {
 /*page-break-inside: avoid;*/
 page-break-after: always;
 display: table-row-group;
}

thead {
 display: table-header-group;
}

tfoot {
  display: table-footer-group;
  display: table-row-group;
 }