Convert CSV File to PDF in Java Example

We are going to start a new set of tutorial series today, that will guide a developer to convert a CSV file to PDF table using a Java program. The tutorial will focus on producing the following programs:
  • CSV to PDF conversion – Java standalone program
  • Java servlet that converts CSV file to PDF
We will be using a number of JAR files to create PDF from CSV file. These will be introduced to you as we move along in the tutorial.
The main Java libraries involved in the conversion are provided below:
  • OpenCSV – This library will help us to read a CSV file line by line.
  • iText – iText will write the PDF file output.
Of course, you can use your own parser to read CSV file in Java. We would like to stick on with OpenCSV, as the library offers flexible methods to read any type of CSV file. And needless to say, iText is always our preferred writer.
The input CSV file we will be using for this tutorial, is a two column file with sample contents as shown below:
1,Finance
2,Marketing
3,IT

We will create a table in a PDF document with these contents through the sample code. Different parts on this tutorial are provided below, you can navigate to the right part based on your needs:

This series: Convert CSV to PDF using Java
Keywords: Convert CSV to PDF, Java Example Program, OpenCSV, iText, Java Servlet Example
All Parts:
1. Convert CSV to PDF– Standard Java Program Example
2. CSV to PDF Servlet Conversion – HTML Form Design
3. CSV to PDF Converter – Full Java Servlet Program

1 comment: