I'm using primeface print just like below
<ui:define name="content" id="content">
<h:form id="common_chart_form" prependId="flase">
<p:growl id="growl" showDetail="true" autoUpdate="true"
sticky="false" />
<p:outputLabel id="labelvalue" value="aaaaaaaaaa"/>
<p:chart id="chart" type="bar"
model="#{commonChartController.barModel}" style="height:300px" />
<p:commandButton value="Print" type="button" icon="ui-icon-print">
<p:printer target="chart" />
</p:commandButton>
<p:commandButton value="Back" action="admin_sales_reports" />
</h:form>
</ui:define>
i need to print the chart but unfortunately it cannot print. then to test the print target i tried to print the "labelvalue" it printed what is the wrong thing that im doing in this code
this is the screen shot of the page
You can use script to export chart as image to a panel which has same height with chart and z-index property value less than chart. Exp:
Only put this (onclick="print();").
Thats it.
You can do it in a more elegant way, without the need of the outputPanel declared in the page:
Javascript function:
Define widgetVar for chart:
Call the print function:
Here is how you do it - found a thread from Brazil that showed it:
1 - Create a dialog like this:
2 - Create your charts with a widgetVar like this:
3 - Create a javascript function like this:
4 - Create a menubar, command button, or any other way of invoking the print() function. Here is my way:
According to this post, it's not possible to print a chart. A solution is given in the last post.