gpt4 book ai didi

c# - 如何在 HTML 渲染器中分页 HTML 内容

转载 作者:行者123 更新时间:2023-12-01 11:20:26 26 4
gpt4 key购买 nike

我有一个项目,其中使用 HTML 渲染器将 HTML 代码转换为 PDF。 HTML 代码包含一个表。显示 PDF,但问题是表格的内容在末尾被截断。那么问题有没有解决的办法呢? enter image description here

PdfDocument pdf=new PdfDocument();

            var config = new PdfGenerateConfig()
{
MarginBottom = 20,
MarginLeft = 20,
MarginRight = 20,
MarginTop = 20,
};
//config.PageOrientation = PageOrientation.Landscape;
config.ManualPageSize = new PdfSharp.Drawing.XSize(1080, 828);

pdf = PdfGenerator.GeneratePdf(html, config);

byte[] fileContents = null;
using (MemoryStream stream = new MemoryStream())
{
pdf.Save(stream, true);
fileContents = stream.ToArray();
return new FileStreamResult(new MemoryStream(fileContents.ToArray()), "application/pdf");
}

最佳答案

HTMLRenderer 应该能够将表格拆分到下一页。
另见:
https://github.com/ArthurHub/HTML-Renderer/pull/41

确保您使用的是最新版本。您可能必须添加这些 CSS 属性。

另请参阅此答案:
https://stackoverflow.com/a/37833107/162529

关于c# - 如何在 HTML 渲染器中分页 HTML 内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44413259/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com