作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个项目,其中使用 HTML 渲染器将 HTML 代码转换为 PDF。 HTML 代码包含一个表。显示 PDF,但问题是表格的内容在末尾被截断。那么问题有没有解决的办法呢?
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 属性。
关于c# - 如何在 HTML 渲染器中分页 HTML 内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44413259/
我是一名优秀的程序员,十分优秀!