iText从HTML表格中删除PDF格式的页面 [英] iText Cut between pages in PDF from HTML table

查看:465
本文介绍了iText从HTML表格中删除PDF格式的页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在google和docs中搜索了很多但是找不到解决这个问题的方法,也许你们可以帮我解决这个问题吗?

I did search a lot in google and docs but can't find a solution for this problem, maybe can you guys help me with this?

我有一个来自html导出的pdf和我的表数据在页面之间分开,看看这个图像:

I have a pdf from html export and my table data is split between the pages, look at this image:

这是一个html到pdf的转换导出,我不是在PDF中构建这个表,看看:

This is a html to pdf convert export, I am not building this table in the PDF, look:

String htmlString = getTableHtml(tableData);

// Create a buffer to hold the cleaned up HTML
ByteArrayOutputStream htmlOutputStream = new ByteArrayOutputStream();

// Clean up the HTML to be well formed
HtmlCleaner cleaner = new HtmlCleaner();
CleanerProperties props = cleaner.getProperties();
TagNode node = cleaner.clean(htmlString);
new PrettyXmlSerializer(props).writeToStream(node, htmlOutputStream);

// Create the PDF
ITextRenderer renderer = new ITextRenderer();
renderer.setDocumentFromString(new String(htmlOutputStream.toByteArray()));
renderer.layout();
ByteArrayOutputStream pdfOutputStream = new ByteArrayOutputStream();
renderer.createPDF(pdfOutputStream);

我该如何解决这个问题?

How can I fix this?

推荐答案

它帮助了我


<style>
@media print
{
  table { page-break-after:auto }
  tr    { page-break-inside:avoid; page-break-after:auto }
  td    { page-break-inside:avoid; page-break-after:auto }
  thead { display:table-header-group }
  tfoot { display:table-footer-group }
}
</style>


https://stackoverflow.com/a/7763286

这篇关于iText从HTML表格中删除PDF格式的页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆