-
1
- #1
NorthStarDA
IS-IT--Management
i am using iText to create PDF files from my site, and i am trying to set it up as a custom tag similar to cfdocument in MX7. You can see in the code below that i pass the contents between the opening and closing custom tag call to the PDF Writer, but the html formatting is not written into the pdf, but rather the html code itself. Anyone know how i can get the html to be parsed by iText and the proper PDF formatting applied?
this is the code in the custom tag that generates the 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(Attributes.FilePath);
// 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("Hi I'm some PDF text!");
// add the paragraph
document.add(paragraph);
// create a new paragraph
paragraph = CreateObject("java", "com.lowagie.text.Paragraph");
paragraph.init(thisTag.GeneratedContent);
// add the paragraph
document.add(paragraph);
// close the document -PDF Writer is listening and will automatically
// create the PDF for us
document.close();
</cfscript>
this is how i would call it:
<cf_report>
<cfoutput>
<strong>Date is: #DateFormat(Now(),"MM/DD/YYYY")#</strong>
Here is another line of text
</cfoutput>
</cf_report>
the date shows up fine, but so does the html code...
=========================================
I have not failed. I've just found 10,000 ways that won't work.
Thomas A. Edison
this is the code in the custom tag that generates the 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(Attributes.FilePath);
// 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("Hi I'm some PDF text!");
// add the paragraph
document.add(paragraph);
// create a new paragraph
paragraph = CreateObject("java", "com.lowagie.text.Paragraph");
paragraph.init(thisTag.GeneratedContent);
// add the paragraph
document.add(paragraph);
// close the document -PDF Writer is listening and will automatically
// create the PDF for us
document.close();
</cfscript>
this is how i would call it:
<cf_report>
<cfoutput>
<strong>Date is: #DateFormat(Now(),"MM/DD/YYYY")#</strong>
Here is another line of text
</cfoutput>
</cf_report>
the date shows up fine, but so does the html code...
=========================================
I have not failed. I've just found 10,000 ways that won't work.
Thomas A. Edison