Buddhika Ariyaratne
Buddhika Ariyaratne

Reputation: 2423

Convert a div in a Jsf page to PDF

I develop a JSF application and need to convert a div or some other container like h:panalGroup or p:panel to PDF. How can I print a container of the page to a PDF document.

Important: I can not print the whole page. I can not use primefaces data exported as it renders only a databtable

Upvotes: 1

Views: 1767

Answers (1)

Zaw Than oo
Zaw Than oo

Reputation: 9935

For my experience, there are two process.

  1. Printing the content.
  2. Install PDF Printer (Eg : doPDFv7)

Example Code

<p:commandButton value="Print">
    <p:printer target="printPanel" />
</p:commandButton>
<h:panelGroup id="printPanel">
    here you print content
</h:panelGroup>

Make sure the printer Setting in Browser(Firefox) as below. enter image description here

When you click Print buttom, Print dialog will be appere. Choose PDF printer and print it.

enter image description here

Your content will be print as PDF File.

Upvotes: 2

Related Questions