Hi Darren,
We are using the iText.jar set of java classes with several of our internal
apps to generate on the fly PDF's and it has worked very well thusfar. We
actually use a wrapper .jar package which contains the iText classes and
several extra ones which make the object far easier to instantiate using CF.
Email me off list for the .jar file and I'll send it over. You just need to
stick it under your CFMX install somewhere and reference that path in the
Vava/JVM classpath in CFadmin.
Its opensource, very small, and written entirely in java so you can't go
wrong integrating with CFMX. Only thing that I have found is that for some
bizarre reason images embedded in the PDF will not show up if the PDF is
created on a linux filesystem...works perfectly on windows. So on Linux you
just have to create PDF's without images for now...we are currently looking
for a workaround to this though.
Quick example of its use would be:
<cfobject action="CREATE"
type="JAVA"
class=Html2pdf
name="obj"
context="INPROC">
<cfset obj.setFontType("HELVETICA", "Cp1252", true) >
<cfset obj.setlayout("#arguments.pdfOrientation#")>
<cfset obj.setTable_Header(false)>
<cfset obj.setHeader("#arguments.pdfHeader#")>
<cfset obj.setMargin(20,20,50,50)>
<cfset obj.setFooter("#arguments.pdfFooter#")>
<cfset obj.setAuthor("#arguments.pdfAuthor#")>
<cfset obj.setPageSize("#arguments.pdfPageSize#")>
<cfset obj.setFontSize("#arguments.pdfFontSize#")>
<cfset obj.createpdf("#arguments.pdfBody#", "#arguments.pdfOutput#")>
Regards,
Phil
"Darren Tracey" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
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/