Step-by-step tutorial on how to install and run iText with Eclipse to create PDFs

Posted by on Mar 4, 2008 in Documentation, Technology | 18 comments

This tutorial will show you how to install and run all the software necessary for you to create PDF files in Java. We will be using the Eclipse editor to write the Java code. Of course there are many other Java editors, but we consider Eclipse to be particularly convenient. This tutorial focuses on the Windows platform. You will work through the following five steps:

  1. Installing Java on your computer
  2. Install iText on your Computer
  3. Install and configure Eclipse on your Computer
  4. Write and run a “HelloWorld” program

The order of these steps is very important. Please go through them one by on. In addition to this tutorial you may also want to consider reading these books that are of particular use:

iTextiText in Action
by Bruno Lowagie
view at

1. Install Java on your Computer

Download and install Java SE (Standard Edition) JRE (Java Runtime Environment). You do NOT need to install the JDK (Java Developer Kit). We will install Eclipse later, which does already include all the tools you need to write and compile your programs. After the installation you also do NOT need to set any Path or Classpath variables for Java itself. Java will be installed in “C:\Program Files\Java”

Download Java

If you already have Java installed you need to verify that you have at least version 5, preferable of the JRE, but the JDK will work as well. We will install Eclipse, which does require at least this version.

2. Install iText on your Computer

Download iText jar file. Create a directory called “ProgramFiles” on your hard disk. The already existing directory “Program Files” does contain a space character between “Program” and “Files” that sometimes causes problems in the usage of Java technology. You will later also install Eclipse into the “ProgramFiles” directory. Place the iText jar file in your “ProgramFiles” directory.

place iText

3. Install and configure Eclipse on your Computer

Download Eclipse IDE for Java Developers. Eclipse itself is written in Java and does not contain an installer (setup.exe). It comes in a simple ZIP file that you should unzip into the previously created “ProgramFiles” directory. You may want to create a shortcut to “eclipse.exe” on your desktop for your own convenience.

unzip eclipse

When you start Eclipse you will be asked to choose a workspace. The workspace will contain all the files that you create. Again, you should create a directory in a location so that the path does not contain any space characters ” “. In our example we use the directory “d:\programming\workspace”. You will then be greeted with the welcome screen.

path for eclipse start page

We will now create a Hello World program. First, you need to create a new Java project. Click on “File => New => Java Project”. Give the project a new name, but avoid space characters. We called ours “iTextTest”

new java project new java project

Next, you need to turn this project into an iText project. Right-click onto the project and select “Properties”. Select “Java Build Path” on the left and click on the “Libraries” tab. Afterwards, click on “Add External JARs…” and locate the directory “ProgramFiles”. Select the iText.jar file and press “Open”. The iText library will now be listed. Click “OK” to leave the properties.

4. Write and run a “Hello world” program

First, we need to create the main class of your program. Click on “New => Class”. Name it “HelloWorld” and check the box “public static void(String[] args)”. You will receive an almost empty class. Eclipse is a very smart Java editor that tries to compile your program while you write. Similar to M$ Word, it will underline errors with a red line. Sometimes this automatic compilation does not work and you want to force Eclipse to compile. You can achieve this by simply saving the file.

new class new class new class

You now need to copy iText’s example HelloWorld java file which is available here. Replace all the text in the class with the example file. Make sure that you comment out the line containing pachage:

// package com.lowagie.examples.general;

Now you can safe and run the program. The program will create a pdf file in your project directory inside of your workspace directory.



  1. this tutorial was excellent and helped me get started with itext and java – just what i needed.

    thank you!


  2. “Afterwards, click on “Add External JARs…” and locate the “lib” directory in your “ProgramFiles\iText” directory.”

    This should be:

    “Afterwards, click on “Add External JARs…” and locate the JAR-file in your “ProgramFiles\iText” directory.”

    But I guess this minor flaw wouldn’t give any problems.
    The rest of the Tutorial is well written and easy to follow.


  3. Hey Ruben,

    I changed the text. Thank you for this feedback!


  4. Cool! Easy to understand!
    Thanks a lot!

  5. Its very helpful to me,

    To know atleast to know how pdf is generating through itext

    its fine…

  6. Excellent guide, had no problems and got iText and Eclipse up and working perfectly.

    Really appreciate the time you took to put this together.


  7. very useful and straight forward tutorial..thank you.

  8. Hey great job! This tutorial was very helpful!

  9. Hey,very good job thank u.
    But, where can i find your other tutoriels please??

  10. thank u …..
    it’s good….

  11. thanks alot ..itz reallp excellent….thanks once again

  12. Hi,

    I was trying to follow your steps but it seems like the is no longer available at your site. Is it possible you could post the code to see if I did all steps correctly?

    Thank you

  13. Hi,

    I was trying to follow your steps but it seems like the is no longer available at your site. Is it possible you could post the code to see if I did all steps correctly?

    Thank you
    Sorry I re-posted but I provided the wrong email

  14. The is located at lowagie’s website. I seems like they moved it. Maybe you can look for it on their website and let us know where it went…

  15. Great tutorial this really helped me to join my PDF’s together. Keep up the good work.

  16. The HelloWorld source code may be found at the following link:

    BTW, an easier way to proceed is to create a mven project and add dependency on itext artifact.

    Add the example class that’s it :)

  17. really helpful thank u!!!

  18. Great info. This gets me out of a bind. I’ve been using different open source PDF libraries in PHP for years but have found in Java that iText seems to the the only open source option. If anyone knows of other options, please let me know.



  1. Step-by-step installation of iText on Windows | Christoph Bartneck, Ph.D. - [...] you installing iText on Windows. iText allows you to create PDF files from Java. A new and better tutorial…
  2. Design By Numbers Course | Christoph Bartneck, Ph.D. - [...] Step-by-step tutorial on how to install and run iText with Eclipse to create PDFs [...]

Leave a Reply

Your email address will not be published. Required fields are marked *