1

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

4

2 回答 2

1

虽然它并不完美,但使用以下设置:

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像这样的 s 以使它们每个都适合 1 个页面大小:

<div style="height: 1308px; overflow:hidden;">
于 2019-03-22T05:31:40.593 回答
0

我正在使用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;
 }
于 2022-01-13T08:35:33.027 回答