.net - 基于 HTML 的报告被分页撕成碎片

标签 .net html css printing c#-2.0

我创建了一个基于 HTML 的报告,它可以在 C# 中可变长度和段数(这就是为什么不使用 Crystal Reports 的原因),但我不能使用美妙的 http://www.printfriendly.com/因为报告是基于 Intranet 的(嘘声,嘶嘶声)。

我已经创建了一个 media=print CSS 文件,该文件用于使格式设置尽可能高效,但我遇到了问题。报告中有一个很长的表格,大约有 50 行表格,每行大约 height: 200px。不幸的是,由于自动分页,一些表格行被切片,部分表格行在一页上,其余部分在下一页上。无论如何(希望通过 CSS)将分页选项设置为不分隔表格元素(或类似元素)?

谢谢, 亚历克斯

最佳答案

page-break-inside: avoid 属性应该控制它,但看起来大多数浏览器在 tr 上不支持它或 td 元素。在我的测试中,Opera 是唯一支持此属性的软件,如以下测试中所用:

<!DOCTYPE html>
<title>Page Break Test</title>
<style>tr, td { page-break-inside: avoid }</style>
<table border=1>
  <tr height=200><td>This is a test. This should be tall.<td>Another column.
  <tr height=200><td>This is a test. This should be tall.<td>Another column.
  <tr height=200><td>This is a test. This should be tall.<td>Another column.
  <tr height=200><td>This is a test. This should be tall.<td>Another column.
  <tr height=200><td>This is a test. This should be tall.<td>Another column.
  <tr height=200><td>This is a test. This should be tall.<td>Another column.
  <tr height=200><td>This is a test. This should be tall.<td>Another column.
  <tr height=200><td>This is a test. This should be tall.<td>Another column.
  <tr height=200><td>This is a test. This should be tall.<td>Another column.
  <tr height=200><td>This is a test. This should be tall.<td>Another column.
  <tr height=200><td>This is a test. This should be tall.<td>Another column.
  <tr height=200><td>This is a test. This should be tall.<td>Another column.
  <tr height=200><td>This is a test. This should be tall.<td>Another column.
  <tr height=200><td>This is a test. This should be tall.<td>Another column.
  <tr height=200><td>This is a test. This should be tall.<td>Another column.
  <tr height=200><td>This is a test. This should be tall.<td>Another column.
</table>

如果您会使用 Opera,这可能就足够了。另一种选择是查看 Prince用于打印报告,因为它往往比浏览器更好地支持打印样式表功能(尽管我没有特别测试过此功能)。

关于.net - 基于 HTML 的报告被分页撕成碎片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1981152/

相关文章:

c# - 我在哪里可以了解 MEF?

html - Twitter Bootstrap - 列之间的边距和等高

javascript - wow.js 和 fullpage.js 动画触发同时滚动到/离开视口(viewport)

javascript - Jquery 自动滑动列表

c# - HTML 标签 :label with onclick asp. 网络方法。

html - 使用 JavaScript 的 Codeigniter

c# - 无法加载文件或程序集“System.Security.Cryptography.Algorithms,版本 = 4.1.0.0

.net 应用架构

c# - StringComparison.InvariantCultureIgnoreCase 有快捷方式吗?

javascript - 将浏览器重定向到表单输入。简单的JS