Exporting PDF using JSF 2.1
In the previous blog article we generated XSL:FO, this was really
a springboard for the real stuff. In this blog article we show how
you can now generate PDFs straight from a JSF page. How? Read on!
- Install the JSF FOP JAR file.
- Create a JSF page with the proper render kit id and content type
- Demo it!
Install the JSF FOP JAR file
If you are non-Maven user you will need to download the JAR file manually from
http://www.manorrock.com/repo/com/manorrock/jsf/com-manorrock-jsf-fop/.
And copy it into your WEB-INF/lib directory.
If you are a Maven user use the following dependency:
<dependency>
<groupId>com.manorrock.jsf</groupId>
<artifactId>com-manorrock-jsf-fop</artifactId>
<version>2.0.1</version>
</dependency>
Create the JSF page with the proper render kit id and content type
<f:view
renderKitId="FOP"
contentType="application/pdf"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html">
<h:body>
<h:outputText value="This is rendered using FOP"/>
</h:body>
</f:view>
Demo it!
And head on over to http://www.manorrock.com/demo/jsf/fop/ to see it in action!
- Login or register to post comments
- Printer-friendly version
- mriem's blog
- 1467 reads





