3 Replies Latest reply on Dec 8, 2006 7:59 PM by Newsgroup_User

    CFML to PDF

    dudeatwar
      Where is it not outputing the direct content without the tags? I can create the pdf for the browser and create the pdf, however, the pdf shows all the html code and not the desired output. (Shows <img src="logo.gif"><p><strong>Hello.....) When I want the pdf to show the image and not the backend. Here is the code:

      <cfset PDFname = "#getfile.filenum#_contact.pdf">
      <cfset mydirectory = "C:\CFusionMX7\wwwroot\AMS\#PDFname#">
      <cfheader name="Content-Type" value="pdf">
      <cfscript>
      // create a 'Document' object
      document = CreateObject("java", "com.lowagie.text.Document");
      document.init();
      // get an outputstream for the PDF Writer
      fileIO = CreateObject("java", "java.io.FileOutputStream");
      // call the constructor, pass the location where you want
      // the pdf to be created
      fileIO.init("#mydirectory#");
      // get a PDF Writer var
      writer = CreateObject("java", "com.lowagie.text.pdf.PdfWriter");
      // call the static 'getInstance' factory method
      writer.getInstance(document, fileIO);
      // open the document
      document.open();
      // create a new paragraph
      paragraph = CreateObject("java", "com.lowagie.text.Paragraph");
      paragraph.init("#myletter#");
      // create a new chunk
      //chunk = CreateObject("java", "com.lowagie.text.pdf.PdfContentUnder");
      //chunk.init("#myletter#");
      // create a new paragraph
      // add the paragraph
      document.add(paragraph);
      // close the document (PDF Writer is listening and will automatically
      // create the PDF for us
      document.close();
      </cfscript>

      Please reply with any advice, Thanks.