iText PDFReader class and java.lang.NoClassDefFoundError

I have posted this in the 4/5 Forum (http://www-10.lotus.com/ldd/46dom.nsf/DateAllThreadedweb/0a4fd8bae26e5fd3852576330057b09b?OpenDocument), however, I am not sure if many people are monitoring the forum, so I thought I would post it to this forum also, even though I am working with the 5.0.7 client.

If this is the incorrect way to do this, I do apologize, but my client wants this in place by tomorrow and I am really hoping for a solution today.

I am in the process of creating an agent that will convert documents to PDF files, using the iText classes.

First of all, to get the Java code to compile, the latest version of iText I can use is 1.01 (this was through trial and error until I got the code to compile successfully) – I am using these classes in the agent:

import com.lowagie.text.pdf.AcroFields;

import com.lowagie.text.pdf.PdfReader;

import com.lowagie.text.pdf.PdfStamper;

The reason for using 1.0.1 is that the AcroFields class was continually giving me a error that the wrong version was being used:

error: Invalid class file format: C:\Lotus\Notes5\Data\domino\java\iText-2.1.7.jar(com/lowagie/text/pdf/AcroFields.class), wrong version 48, expected 45

JavaAgent.java:6: Class import com.lowagie.text.pdf.AcroFields not found on import

Anyway, I am trying to set the PdfReader object and I get this error every time I run the agent:

java.lang.NoClassDefFoundError

Here is the line of code:

private static final java.lang.String pdfLocation = “C:\activity\iSOPPDF.pdf”;

PdfReader reader = new PdfReader(pdfLocation);

I have tried these 2 routes:

  1. In my notes.in, I have the setting:

JavaUserClasses=C:\Lotus\Notes5\Data\domino\java\iText-1.01.jar

  1. I used the “Edit Project” feature and added the iText-1.01.jar to the Java agent files

The agent compiles successfully using either of those 2 routes above.

I am not that familiar with iText and here is the answer I received when posting to their message board:

“There is no business relationship between iText Software Corp. and the company that owns Lotus Notes. Please contact IBM for support integrating iText in their product.”

Do I need to use a later version of iText? Does iText not “play nice” with R5?

NOTE: I compiled and ran in the 7.0.3 client and it worked fine.

Any help would be great – I appreciate it!

Thanks!

Dan

Full Agent Code:

import lotus.domino.*;

import java.util.*;

import java.lang.*;

import java.text.*;

import java.io.*;

import com.lowagie.text.pdf.AcroFields;

import com.lowagie.text.pdf.PdfReader;

import com.lowagie.text.pdf.PdfStamper;

public class JavaAgent extends AgentBase {

// Notes Objects...

Session s = null;

Database db = null;

AgentContext agentContext = null;

Agent agent = null;	

Document doc = null;

View view = null;



// Java Objects...

Date certJavaDate = null;

SimpleDateFormat sdFormat = new SimpleDateFormat("MMMM dd, yyyy");

Runtime run = null;

Enumeration e = null;

PrintWriter pw = null;

NumberFormat nf = NumberFormat.getNumberInstance();



// Strings, Vectors, Integers...

String docNumber;

String title;

String currentStatus;

String docIssueDate;

String reportDate;

String fileOutputPath;

Vector getDocIssueDate;	

Vector embedObjects;



// Constants...

private static final java.lang.String pdfFileExtension = ".pdf";	

private static final java.lang.String pdfLocation = "C:\\activity\\iSOPPDF.pdf";

private static final java.lang.String pdfFolder = "C:\\activity\\";



public void NotesMain() {

    try {

System.out.println(“ProcessDocsToPDF: Step 1…”);

		s = getSession();

		agentContext = s.getAgentContext();

		db = agentContext.getCurrentDatabase();

System.out.println(“ProcessDocsToPDF: Step 2…”);

		// Open the pdf form we are going to use...

		PdfReader reader = new PdfReader(pdfLocation);

		// Get the view and cycle through the documents...

System.out.println(“ProcessDocsToPDF: Step 3…”);

		view = db.getView("");

		doc = view.getFirstDocument();

  		while (doc != null) {

			// Get the values we need from the document...

			docNumber = doc.getItemValueString("DDOCRevActNumber");

			title = doc.getItemValueString("VLSOP_SopTitleAR");

			currentStatus = doc.getItemValueString("VLSOP_SOPStatus_AR");

			getDocIssueDate = doc.getItemValue("VLSOP_SopEffectiveDateAR");

			docIssueDate = getDocIssueDate.toString();

			reportDate = doc.getItemValueString("TodayAR");



			// Fill out the form...

			fileOutputPath = pdfFolder + docNumber + pdfFileExtension;

			System.out.println("fileOutputPath: " + fileOutputPath);

			PdfStamper stamp1 = new PdfStamper(reader, new FileOutputStream(fileOutputPath));

			AcroFields form1 = stamp1.getAcroFields();

			form1.setField("DDOCRevActNumber", docNumber);

			form1.setField("VLSOP_SopTitleAR", title);

			form1.setField("VLSOP_SOPStatus_AR", currentStatus);

			form1.setField("VLSOP_SopEffectiveDateAR", docIssueDate);

			form1.setField("TodayAR", reportDate);

			stamp1.setFormFlattening(true);

			stamp1.close();

   			doc = view.getNextDocument(doc); 

		}		

	}

	catch (NotesException ne) {

		System.out.println(ne.getMessage());

	}

	catch (Exception de) {

		de.printStackTrace();

	}

}   

}

Subject: Export utility for Lotus Notes / Domino

If you’d like to consider a 3rd party tool we have an Export Utility for Lotus Notes which supports exporting documents to PDF format as well as Excel, CSV, Word, Access, HTML, Fixed Width, XML and more.

You can export documents, and views. Exports can also be scheduled.

For more information and to download a copy:

Single user license costs less than an hour of development time.

Regards,

Alex