Skip to Content
Author's profile photo Former Member

Create a PDF file using JAVA

Introduction

This weblog presents Java code to create a PDF file to be displayed in EP6 portal using AbstractPortalComponent.
I currently use this solution to convert all my reporting htmlb table display to PDFs.
I am going to use iText’s open source api to create a PDF file.
These apis can also be used to read PDF file. For more information about api check out the site. www.lowagie.com/iText/.
There is plenty of documentation and example code at this site.

Required Jars:

You can download the following iText jar from http://www.lowagie.com/iText/download.html.
servlet.jar, itext-1.2.jar

Steps to create PAR component

Step 1:

Create an AbstractPortalComponent using Eclipse or Netweaver Studio. Add the above jar (itext-1.2.jar) to PORTAL-INF->lib folder.

Step 2:

Add the following lines to doContent method.

Step 3:

Deploy it in portal and run it. You should get the following output.
image

Assigned Tags

      6 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member
      Prakash,

      Thanks for this example about using PDF within Java code... It should be very usefull for me.

      Author's profile photo Former Member
      Former Member
      Hats off,
      You have done a good job. I was looking for the same. By this can we edit pdfs?

      Thanx and Regards
      George

      Author's profile photo Former Member
      Former Member
      Blog Post Author
      Thank you George. Comments like this make we want to write more weblogs and share my solutions.
      Author's profile photo Former Member
      Former Member
      I am new to eclipse, as mentioned in the blog, i could get itext-1.3.jar (this is only available).
      And stored in c:\tomcat\webapps\irj\WEB-INF\lib\ext.

      And refered in the project.

      But i am getting a error:

      Linkage error while loading implementation class

      java.lang.NoClassDefFoundError: com/lowagie/text/Phrase

      I think, i missing some very basic step.
      can you guide me thru. it?

      Thank You.

      Author's profile photo Former Member
      Former Member
      Hi Can any one help me how to add images to pdf which i have kept in /images folder.I'm facing problem with the path.
      Author's profile photo Former Member
      Former Member
      Hello!

      How can I pass to the pdf document
      the content of my view ?

      Regards
      sas