Convert Jsf File To Pdf



Complete list of supported conversions

Jsf To Pdf Converter Online

  • PDF to PDF
  • PDF to PCL
  • PDF to Exe
  • PDF to XPS
  • EPS to PDF
  • EPS to HTML
  • EPS to TXT
  • EPS to Text
  • EPS to CSV
  • EPS to BMP
  • EPS to PCL
  • EPS to Exe
  • EPS to XPS
  • EPS to PS
  • PS to TXT
  • PS to Exe
  • PS to XPS
  • PS to PS
  • PRN to Doc
  • PRN to WMF
  • PRN to PCL
  • PRN to Exe
  • PRN to XPS
  • PRN to PS
  • PCL to PDF
  • PCL to Text
  • PCL to CSV
  • PCL to BMP
  • PCL to GIF
  • PCL to PCL
  • PCL to PPT
  • PCL to Exe
  • PCL to XPS
  • PCL to PS
  • PXL to HTML
  • PXL to XHTML
  • PXL to Doc
  • PXL to RTF
  • PXL to XLS
  • PXL to JPEG
  • PXL to TIFF
  • PXL to TXT
  • PXL to Text
  • PXL to CSV
  • PXL to BMP
  • PXL to GIF
  • PXL to PNG
  • PXL to EMF
  • PXL to WMF
  • PXL to PCL
  • PXL to PPT
  • PXL to Exe
  • PXL to XPS
  • PXL to PS
  • XPS to PDF
  • XPS to BMP
  • XPS to Exe
  • XPS to XPS
  • XPS to PS
  • OXPS to PDF
  • OXPS to BMP
  • OXPS to GIF
  • OXPS to PNG
  • OXPS to EMF
  • OXPS to WMF
  • OXPS to PCL
  • OXPS to PPT
  • OXPS to Exe
  • OXPS to XPS
  • OXPS to PS

In this article, we show you how to create a custom converter in JSF 2.0.

In Microsoft Windows 10, Microsoft has introduced a new feature call Print To PDF. It is an inbuilt pre-installed printer in Windows 10 that you can be used. This free online PDF converter converts images (JPG, TIFF, etc.), ebook files (ePub, MOBI, FB2, CBR, CBZ), documents (DOC, DOCX, PPT, XLS, ODT etc.) and other files of over 20 formats to PDF in just a single mouse click.

Steps
1. Create a converter class by implementing javax.faces.convert.Converter interface.
2. Override both getAsObject() and getAsString() methods.
3. Assign an unique converter ID with @FacesConverter annotation.
4. Link your custom converter class to JSF component via f:converter tag.

HowConvert Jsf File To Pdf

Custom converter example

A detail guide to create a JSF 2 custom converter name “URLConverter”, which is used to convert a String into an URL format (add HTTP protocol in front only :)) and store it into an Object.

1. Folder Structure

Folder structure of this example.

2. Converter class

Create a custom converter class by implementing javax.faces.convert.Converter interface.

Override following two methods :
1. getAsObject(), converts the given string value into an Object.
2. getAsString(), converts the given object into a String.

Assign an converter ID with @FacesConverter annotation.

See full custom converter source code :

URLConverter.java

In this custom converter class, it’s given a converter id as “com.mkyong.URLConverter“, and converts any given String (by adding a “http” in front) into “URLBookmark” object.

Convert Jsf File To Pdf

In addition, if URL validation is failed, return a FacesMessage object with declared error message.

Pdf

URLBookmark.java

3. Managed Bean

A normal managed bean named “user”, nothing special here.

4. JSF Page

Convert json to pdf

Link above custom converter to JSF component via “converterId” attribute in “f:converter” tag.

default.xhtml

result.xhtml

5. Demo

Enter a valid URL, without “http”.

File

Add a “http” in front of the valid URL and display it.

If an invalid URL is provided, return the declared error message.

Download Source Code

Download It – JSF-2-Custom-Converter-Example.zip (11KB)

Reference

Related Articles

mkyong

Founder of Mkyong.com, love Java and open source stuff. Follow him on Twitter. If you like my tutorials, consider make a donation to these charities.