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.
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.
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?
Lookup the classname of the <p:dataTable>
and override it in your @media
rule:
@media print {
.primeFaces-dataTable-className {
border: 0;
margin: 0;
padding: 0;
background: none;
color: black;
}
}
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.
Also, is it possible to change the paper orientation of the print? I would like to print it as landscape instead of portrait. Use CSS.
As per CSS 2.1, you can specify it as follows:
@media print {
@page {
size: landscape;
}
}
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With