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 printrule. 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@mediarule: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,noneor 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