Posted By

jnunemaker on 09/07/06


Tagged

pdf line web ColdFusion itext bookmarklet citeulike duplicates news textfiles breaks


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

gwmccort


Creating a PDF using iText and ColdFusion


 / Published in: Other
 

  1.  
  2. <cfscript>
  3. // create document
  4. document = CreateObject("java", "com.lowagie.text.Document");
  5. document.init();
  6.  
  7. // writer
  8. fileIO = CreateObject("java", "java.io.FileOutputStream");
  9. fileIO.init(pdf_path);
  10. writer = CreateObject("java", "com.lowagie.text.pdf.PdfWriter");
  11. writer.getInstance(document, fileIO);
  12. document.open();
  13.  
  14. // newsinfo header image
  15. Image = CreateObject("java", "com.lowagie.text.Image");
  16. jpg = Image.getInstance(header_image);
  17. jpg.setAbsolutePosition(28, 713);
  18. jpg.setDpi(300,300);
  19. document.add(jpg);
  20.  
  21. // top margin; dumb i know but i was in a hurry
  22. paragraph = CreateObject("java", "com.lowagie.text.Paragraph");
  23. paragraph.init(" ");
  24. for (i=0; i lt 9; i=i+1) {
  25. document.add(paragraph);
  26. }
  27.  
  28. // the fonts
  29. FontFactory = createobject("java", "com.lowagie.text.FontFactory");
  30. Font = createObject("java", "com.lowagie.text.Font");
  31. TimesLargeBI = Font.init(Font.TIMES_ROMAN, 14.0, Font.BOLDITALIC);
  32. TimesNormal = Font.init(Font.TIMES_ROMAN, 12.0);
  33.  
  34. // all the text
  35. paragraph = CreateObject("java", "com.lowagie.text.Paragraph");
  36.  
  37. paragraph.init("Hello World!", TimesLargeBI);
  38. paragraph.setIndentationLeft(indentation_left);
  39. paragraph.setIndentationRight(indentation_right);
  40. document.add(paragraph);
  41.  
  42. paragraph.init("#dateFormat(now(), 'long')#", TimesNormal);
  43. paragraph.setIndentationLeft(indentation_left);
  44. paragraph.setIndentationRight(indentation_right);
  45. document.add(paragraph);
  46.  
  47. document.close();
  48. </cfscript>
  49.  

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: aspcorpo on June 25, 2010

what about creating the code with a pdf fuction on a cftag?

You need to login to post a comment.