• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

CFML to PDF

New Here ,
Dec 08, 2006 Dec 08, 2006

Copy link to clipboard

Copied

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.
TOPICS
Advanced techniques

Views

251

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 08, 2006 Dec 08, 2006

Copy link to clipboard

Copied

Why don't you use the cfdocument tag?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 08, 2006 Dec 08, 2006

Copy link to clipboard

Copied

I am trying to save the pdf file. I can output just fine. I didn't see anywhere that I could use cfdocument to save the pdf?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 08, 2006 Dec 08, 2006

Copy link to clipboard

Copied

LATEST
dudeatwar wrote:
> I am trying to save the pdf file. I can output just fine. I didn't see
> anywhere that I could use cfdocument to save the pdf?

parsing/working with HTML in iText is a pain. use cfdocument. if by "save the
pdf" you mean to a file, use the filename = "filename" option.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation