Convert JPG images to PDF, rotate them or set a page margin. Convert JPG to PDF online, easily and free. Strictly speaking, one would render a JSF View as PDF using an alternative renderer instead of the default HTML renderer. However, it's more likely that like most people you don't really want to 'export the JSF page to PDF', you want to generate a downloadable document in PDF form for viewing, printing and/or saving on the client's machine. Which is entirely different.
- JSF Tutorial
- JSF Useful Resources
- Selected Reading
We can create our own Custom convertor in JSF.
Defining a custom converter in JSF is a three-step process.
Step | Description |
---|---|
1 | Create a converter class by implementing javax.faces.convert.Converter interface. |
2 | Implement getAsObject() and getAsString() methods of above interface. |
3 | Use Annotation @FacesConvertor to assign a unique id to the custom convertor. |
Jsf To Pdf Converter Ppt
Step 1: Create a Converter Class : UrlConverter.java
Step 2: Implement Converter Interface Methods : UrlConverter.java
Jsf To Pdf Converter Ocr
Create a simple class to store data: UrlData. This class will store a URL string.
Use UrlData in getAsObject method.
Step 3: Annotate to Register the Convertor : UrlConverter.java
Use the Convertor in JSF Page
Example Application
Let us create a test JSF application to test the above tag.
Step | Description |
---|---|
1 | Create a project with a name helloworld under a package com.tutorialspoint.test as explained in the JSF - First Application chapter. |
2 | Create UrlData.java under package com.tutorialspoint.test as explained below. |
3 | Create UrlConvertor.java as a converter under package com.tutorialspoint.test as explained below. |
4 | Create UserData.java as a managed bean under package com.tutorialspoint.test as explained below. |
5 | Modify home.xhtml as explained below. Keep rest of the files unchanged. |
6 | Create result.xhtml in the webapps directory as explained below. |
7 | Compile and run the application to make sure the business logic is working as per the requirements. |
8 | Finally, build the application in the form of war file and deploy it in Apache Tomcat Webserver. |
9 | Launch your web application using appropriate URL as explained below in the last step. |
UrlData.java
UrlConvertor.java
UserData.java
home.xhtml
result.xhtml
Jsf To Pdf Converter I Love
Once you are ready with all the changes done, let us compile and run the application as we did in JSF - First Application chapter. If everything is fine with your application, this will produce the following result.
Enter any invalid value and press Submit button. See the following error message.
Enter any valid value and press Submit button. See the following result.
Complete list of supported conversions
|
|
|
|
|
|
|
|