javacoldfusionasposeopenbdbluedragon

Create PDF with Coldfusion (openBD CFML engine) java


Wrestling to create PDF in Coldfusion using the following block with no success:

<cfset FileInputStream = CreateObject("java", "java.io.FileInputStream") >
<cfset File = CreateObject("java", "java.io.File")>

<cfset lic = CreateObject("java", "com.aspose.pdf.License")>
<cfset lic.setLicense(FileInputStream.init(File.init("E:\Tomcat\webapps\openbd\Aspose.Pdf.lic")))>


<cfset Document = CreateObject("java", "com.aspose.pdf.Document").init() >
<cfset demo_pdf = Document.init() >

<cfset Section = CreateObject("java", "aspose.pdf.Section").init() >
<cfset Text = CreateObject("java", "aspose.pdf.Text").init() >

<cfset sec1 = section.demo_pdf.getSections().add() >
<cfset sec1.getParagraphs().add(Text.init("Τέσσερα"))>
<cfset demo_pdf.save("E:\Tomcat\webapps\openbd\HelloWorld.pdf")>

The error produced is: "java.lang.NoSuchFieldException" on line:"cfset sec1 = section.demo_pdf.getSections().add()". What am i supposed to do in order to generate PDFs using java aspose PDF lib under openBD CFML engine?


Solution

  • In reference to your last comment, try the following code:

    <cfset demo_pdf = CreateObject("java", "aspose.pdf.Pdf").init() >
    <cfset section = CreateObject("java", "aspose.pdf.Section").init() >
    <cfset sec1 = demo_pdf.getSections().add() >
    <cfset text = CreateObject("java", "aspose.pdf.Text").init("Κατά τη συζήτηση") >
    <cfset text.getTextInfo().setFontName("Arial Unicode MS")>
    <cfset sec1.getParagraphs().add(text)>
    <cfset demo_pdf.setUnicode()>
    <cfset demo_pdf.save("c:\HelloWorld.pdf")>