HTML to PDF - page break with PdfSharp and HtmlRenderer

后端 未结 4 674
清酒与你
清酒与你 2020-12-28 17:16

I try to convert HTML to PDF using PdfSharp and HtmlRenderer. This is part of code:

private byte[] CreateHtmlContent()
{
    string htmlContent = File.ReadAl         


        
4条回答
  •  情深已故
    2020-12-28 18:05

    I had a similar challenge and resolved it as I found this pull request on github: https://github.com/ArthurHub/HTML-Renderer/pull/41

    You can set the custom-css-property

    td { page-break-inside: avoid; }
    

    on all elements or selectors you want (td, p, .my-class, etc.) to control the page breaking.

    You can use the value "auto" if you want the library to control your page breaking on certain elements

    td { page-break-inside: auto; }
    

    There is also a example for page breaking in running text.

提交回复
热议问题