/ Published in: Other
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<cfscript> // create document document = CreateObject("java", "com.lowagie.text.Document"); document.init(); // writer fileIO = CreateObject("java", "java.io.FileOutputStream"); fileIO.init(pdf_path); writer = CreateObject("java", "com.lowagie.text.pdf.PdfWriter"); writer.getInstance(document, fileIO); document.open(); // newsinfo header image Image = CreateObject("java", "com.lowagie.text.Image"); jpg = Image.getInstance(header_image); jpg.setAbsolutePosition(28, 713); jpg.setDpi(300,300); document.add(jpg); // top margin; dumb i know but i was in a hurry paragraph = CreateObject("java", "com.lowagie.text.Paragraph"); paragraph.init(" "); for (i=0; i lt 9; i=i+1) { document.add(paragraph); } // the fonts FontFactory = createobject("java", "com.lowagie.text.FontFactory"); Font = createObject("java", "com.lowagie.text.Font"); TimesLargeBI = Font.init(Font.TIMES_ROMAN, 14.0, Font.BOLDITALIC); TimesNormal = Font.init(Font.TIMES_ROMAN, 12.0); // all the text paragraph = CreateObject("java", "com.lowagie.text.Paragraph"); paragraph.init("Hello World!", TimesLargeBI); paragraph.setIndentationLeft(indentation_left); paragraph.setIndentationRight(indentation_right); document.add(paragraph); paragraph.init("#dateFormat(now(), 'long')#", TimesNormal); paragraph.setIndentationLeft(indentation_left); paragraph.setIndentationRight(indentation_right); document.add(paragraph); document.close(); </cfscript>