I'm trying to use the iText (http://www.lowagie.com/iText/) set of java libraries to 
produce PDF files from my CFMX app.
I can't work out how to get it all starting though.

I don't believe the problem lies within the iText classes, but more in the fact that 
I've never had to do anything with java classes or .jar files in CF ever before.

There's 2 jar files (iText.jar and iTextXML.jar), which I've been able to work out 
should be put in this directory:
 C:\CFusionMX\wwwroot\WEB-INF\lib 
although I'm also aware that this is not the best place for it, but that it should at 
least work from there.
I'm also reasonably sure that I should use a CFOBJECT tag to start using the java, but 
I can't for the life of me work out what class name to use to make it work.

I've got tutorial code, but its all in straight java, not CF.
Here's the java code:
-------------------------------------------------------------------
import java.io.FileOutputStream;
import java.io.IOException;

import com.lowagie.text.*;
import com.lowagie.text.pdf.PdfWriter;

public class Chap0101 {
    
    public static void main(String[] args) {
        
        System.out.println("Chapter 1 example 1: Hello World");
        
        // step 1: creation of a document-object
        Document document = new Document();
        
        try {
            
            // step 2:
            // we create a writer that listens to the document
            // and directs a PDF-stream to a file
            
            PdfWriter.getInstance(document, new FileOutputStream("Chap0101.pdf"));
            
            // step 3: we open the document
            document.open();
            
            // step 4: we add a paragraph to the document
            document.add(new Paragraph("Hello World"));
            
        }
        catch(DocumentException de) {
            System.err.println(de.getMessage());
        }
        catch(IOException ioe) {
            System.err.println(ioe.getMessage());
        }
        
        // step 5: we close the document
        document.close();
    }
}
-------------------------------------------------------------------
I'm fairly right from about step 3 onwards, but I just can't get over the initial 
hurdle of instantiating the object.
Whatever I try gets the following error:
Object Instantiation Exception. 
Class not found: com.lowagie.text.pdf.PdfWriter
The error above was produced by this code:
 <cfobject class="com.lowagie.text.pdf.PdfWriter" name="iTDoc" type="java" 
action="create">

I've tried countless variations on what's in the 'class' parameter, but never had any 
differing results.

Can anyone help me work out what my CFOBJECT tag should look like?

On the same issue, can anyone point me at a good book/site/example of using a set of 
java classes in a CFMX page?
The books I've got haven't been much chop. Neither have the CF documentation, nor 
anything I've been able to find with Google. Trial and error also has been a 
frustrating and fruitless option.

Thanks

Darren Tracey

---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]

MX Downunder AsiaPac DevCon - http://mxdu.com/

Reply via email to