如何在HTML渲染器中分页HTML内容 [英] How to Page Break HTML Content in HTML Renderer
问题描述
我有一个项目,其中使用HTML Renderer将HTML代码转换为PDF. HTML代码包含一个表.显示了PDF,但问题是表格的内容最后被截断了.那么,有没有解决问题的方法?
I have a project where HTML code is converted to a PDF using HTML Renderer. The HTML code contains a single table. The PDF is displayed but the issue is that the contents of the table are cut off at the end. So is there any solution to the problem?
PdfDocument pdf =新的PdfDocument();
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
HTMLRenderer should be able break the table to the next page.
See also:
https://github.com/ArthurHub/HTML-Renderer/pull/41
确保您使用的是最新版本.您可能必须添加这些CSS属性.
Make sure you are using the latest version. You may have to add those CSS properties.
也请参见以下答案:
https://stackoverflow.com/a/37833107/162529
Also see this answer:
https://stackoverflow.com/a/37833107/162529
这篇关于如何在HTML渲染器中分页HTML内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!