如何将 PrimeFaces p:dataTable 转换为标准 h:dataTable(无皮肤)然后打印
我想打印
,所以我使用
,但我想跳过打印皮肤并使其看起来像
。我该怎么做?
另外,是否可以更改打印的纸张方向?我想将其打印为横向而不是纵向。
<h:outputLink id="lnk" value="#">
<p:printer target="tbl" />
<p:graphicImage value="http://www.primefaces.org/showcase/images/print.png" />
</h:outputLink>
我在
标记中没有找到任何合适的属性。
更新:抱歉,没关系
也可以在
上使用,所以您可以也只回答第二个问题而已。
I want to print a <p:dataTable>
, so I use <p:printer>
, but I want to skip printing the skin and make it look like a <h:dataTable>
. How can I do this?
Also, is it possible to change the paper orientation of the print? I would like to print it as landscape instead of portrait.
<h:outputLink id="lnk" value="#">
<p:printer target="tbl" />
<p:graphicImage value="http://www.primefaces.org/showcase/images/print.png" />
</h:outputLink>
I didn't find any suitable attribute in the <p:printer>
tag.
Update: sorry, nevermind the <p:printer>
can be used on a <h:dataTable>
as well, so you can also just answer the second question only.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这两个问题都可以通过 CSS
@media print
规则来回答。它允许您指定特定于打印输出的 CSS 样式。您可以按照通常的方式将这些规则嵌入到普通的 CSS 样式表文件或元素中。
查找
的类名并在您的@media
规则中覆盖它:可能还有更多,我不知道这一切,您应该能够使用 Firebug 或 Chrome 开发人员工具检查使用了哪些类名以及设置了哪些属性,以便您知道应该将哪些重置为
0,<代码>无或一些其他默认。
根据 CSS 2.1,您可以按如下方式指定它:
但是,这具有浏览器特定的障碍,FF 和 MSIE <=7 中不支持它。有关解决方法,请检查此问题已接受的答案:从 HTML 进行横向打印
Both qustions are answered with CSS
@media print
rule. It allows you to specify CSS styles which are specific to printed output. You can embed those rules in a normal CSS stylesheet file or<style>
element the usual way.Lookup the classname of the
<p:dataTable>
and override it in your@media
rule:There are likely more, I don't know it all from top of head, you should be able to check using Firebug or Chrome developer tools what classname is been used and which properties are all been set so that you know which you should reset to
0
,none
or some other default.As per CSS 2.1, you can specify it as follows:
This has however browser specific impediments, it's not supported in FF and in MSIE <=7. For workarounds, check the accepted answer of this question: Landscape printing from HTML