【问题标题】:Printing dynamic content with page breaks in asp.net在 asp.net 中打印带有分页符的动态内容
【发布时间】:2011-08-19 13:06:00
【问题描述】:

在我的 asp.net 项目中,我需要打印一个包含一些动态内容的页面。我按照这篇文章 http://www.dotnetcurry.com/ShowArticle.aspx?ID=92 来实现这一点,只要我需要打印的内容适合一页,它就可以正常工作。

但是如果内容很长,当我点击打印按钮时,我会看到一个包含所有需要打印的内容的打印预览,打印时它只会打印适合一页的内容。所以我想当我打电话时'window.print()' 它只打印任何可以放入页面的内容,并且不检查是否还有内容要打印在另一个页面上。我不知道如何设置分页符以获取整个内容打印,因为它是动态内容。

有人可以帮我解决这个问题吗?

谢谢

编辑:

这是一些呈现的示例 HTML。

<table class="Main">
<tr>
<td class=”left bold”>
Some text
</td>
<td>
<span id="Label">Label</span>
</td>
</tr>
<tr>
......
......
</tr>
......
......
......
<tr>
<td>
<table class= “productslist”>
<tbody>
<tr>....</tr>
<tr>....</tr>
<tr class=”productTextAlign”>  ......</tr>
<tr class=”additionalOptions”> ..... </tr>
<tr class=”additionalOptions”>.....</tr>

<tr class=”additionalOptions”>.....</tr>

<tr class=”additionalOptions”>.....</tr>

<tr class=”additionalOptions”>.....</tr>
<tr>...</tr>

<tr class=”productTextAlign”></tr>

<tr class=”additionalOptions”>.....</tr>

<tr class=”additionalOptions”>.....</tr>

<tr class=”additionalOptions”>.....</tr>

<tr class=”additionalOptions”>.....</tr>
</tbody>
</table>

</td>
<tr>
</table>

类为“Main”的表是一个 html 表,其中还有另一个类为“productslist”的表,它实际上是一个中继器。我正在尝试使用

将“分页符之前”应用于此转发器
table.productslist
{
page-break-before:auto;
}

在 FF6.0 中不起作用,在 IE8 中似乎可以正常工作。

【问题讨论】:

  • FF6 还是新的,可能有很多错误。
  • 你认为它会在较低版本的 FF 中工作吗?
  • 你没试过吗???
  • 我还没有。会试一试。谢谢
  • 只是为了确认'page-break-before'设置为'auto'时,对于冗长的内容,它会引入分页符。对吗?

标签: asp.net printing


【解决方案1】:

【讨论】:

  • 谢谢。我尝试使用'Page-break-before:always',这似乎工作正常。但我想要一个分页符,只有当内容很长时。所以我把它改成了'auto'不起作用。“自动”不应该根据内容长度起作用吗?请帮忙。
  • 向我们展示您尝试打印的页面的标记 - 它是静态内容,GridView?等等……
  • 好的,我在原始问题中添加了一些示例 HTML。请参阅。
猜你喜欢
  • 2016-09-02
  • 1970-01-01
  • 1970-01-01
  • 2019-03-06
  • 2022-10-24
  • 2020-08-06
  • 2012-07-06
  • 1970-01-01
  • 2011-07-07
相关资源
最近更新 更多