PDFOne (for Java)
Create, edit, view, print & enhance PDF documents and forms in Java SE/EE
J2SE J2EE Windows Linux Mac (OS X)

Create PDF Documents In A JSP Page

Learn to use PDFOne (for Java) in a Java Server Page web application running on a Apache Tomcat server.
By V. Subhash

I am new to JSP but decided to give this a try anyway. First, I had to install the Apache Tomcat Server.

Install Apache Tomcat Server

  1. Installed Oracle JDK.
  2. Created a system-wide environment variable named JAVA_HOME for the JDK installation folder.
  3. Downloaded Apache Tomcat Server for Windows.
  4. Extracted the main Tomcat folder from inside the ZIP archive to my C:\ drive. Installation over.
  5. Created system-wide environment variable CATALINA_HOME with the path to the Tomcat folder.
  6. Created a "Limited User" Windows account and ran bin\startup.bat file using this account. (I am still on XP and my regular account is a full-blown Admnistrator account.)
  7. Tested the default site at http://localhost:8080.

Next, I had to create a JSP script that used PDFOne to create a new PDF document and send it down to the browser.

Create PDFOne (for Java™) JSP Application

  1. Created a new folder named lib in the C:\apache-tomcat-7.0.14\webapps\ROOT\WEB-INF for the PDFOne JAR files.
  2. Copied the following files to the folder.
    1. bcprov-jdk14.jar
    2. PDFOne.jar
    3. pdfonejfont.dll
  3. Stopped and restarted the Tomcat server.
  4. Created a new JSP script at C:\apache-tomcat-7.0.14\webapps\ROOT\test.jsp with the following content.
    <%@page import="com.gnostice.pdfone.PDFOne" %>
    <%@page import="com.gnostice.pdfone.PdfDocument" %>
    <%@page import="com.gnostice.pdfone.fonts.PdfFont" %>
    <%@page import="java.awt.Color" %>
      // Activate your license
      try {
        // Create a new PDF document
        PdfDocument doc = new PdfDocument();
        // Access the default font and modify it
        PdfFont defaultFont = doc.getFont();
        // Prepare the browser
        // Set PDF version to 1.4 for backward compatibility
        // Render text on the first page
        doc.writeText("Hello, World!", 100, 100);
        // Save the document to the browser
        // Close the document
        // Close the browser output
      } catch (Exception e) {
        out.println("Sorry, an error occurred " + e.getMessage() );
  5. Accessed the JSP script in a browser.


Our .NET Developer Tools
Gnostice Document Studio .NET

Multi-format document-processing component suite for .NET developers.


A .NET PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, and bookmark PDF documents in .NET applications.

Our Delphi/C++Builder developer tools
Gnostice Document Studio Delphi

Multi-format document-processing component suite for Delphi/C++Builder developers, covering both VCL and FireMonkey platforms.

eDocEngine VCL

A Delphi/C++Builder component suite for creating documents in over 20 formats and also export reports from popular Delphi reporting tools.

PDFtoolkit VCL

A Delphi/C++Builder component suite to edit, enhance, view, print, merge, split, encrypt, annotate, and bookmark PDF documents.

Our Java developer tools
Gnostice Document Studio Java

Multi-format document-processing component suite for Java developers.

PDFOne (for Java)

A Java PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, bookmark PDF documents in Java applications.

Our Platform-Agnostic Cloud and On-Premises APIs

Cloud-hosted and On-Premises REST-based document-processing and document-viewing APIs

Privacy | Legal | Feedback | Newsletter | Blog | Resellers © 2002-2024 Gnostice Information Technologies Private Limited. All rights reserved.