forked from TVScoundrel/ColdBox-iText-Plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
boltz/ColdBox-iText-Plugin
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Plugin: iText ColdBox: 3.5 beta (Will probably work in older versions too) Version: 1.0 Description: iText Project that provides iText PDF operations to ColdBox applications iText Version: 5.1.3 iText Project: http://www.itextpdf.com/ Who didn't run into the limitations of either <cfpdf> or <cfdocument>? While they are super cool to make quick and easy pdf documents, sometimes the requirements are a little more complicated... What if you want a different header/footer in size and content on the first page of your generated document then on consecutive pages in that doc? What if you want to generate PDF forms with event actions etc? You will be stuck using Coldfusion alone. Adobe gave us the power of JVM as the underlying engine that runs Coldfusion... So we can leverage that power and use awesome Java libraries in our CF applications. iText PDF is one of those awesome projects and behind the screen, Adobe Coldfusion even uses that for <cfpdf> and <cfdocument> but they far from implemented every piece of functionality it provides. On top of that, CF 9.0.1 is using an old version of iText! This project focusses on getting the benefits of the newest iText version at our fingertips while creating fantastic ColdBox applications. I hope this project will catch some interest so that it can grow and mature over time. ######################################################################################################################################################################### ####### Plugin Files ####### # iText-lib * Folder - iTextCFC.jar: My own addition * class iTextCFC: Used to look-up the full path of a iText class * class PdfPageEventHelperHeaderFooter: Extends PdfPageEventHelper for custom headers and footers * class HeaderFooter: abstract class providing basic functionality for the Header and the Footer class * class Header: Extends HeaderFooter, used to add custom headers to your pages * class Footer: Extends HeaderFooter, used to add custom footers to your pages - itextpdf-5.1.3.jar * The core iText library - itextpdf-5.1.3-javadoc.jar * Probably redundant here - itextpdf-5.1.3-sources.jar * Probably redundant here - itext-xtra-5.1.3.jar * The extra features (not used at this point) - itext-xtra-5.1.3-javadoc.jar * Probably redundant here - itext-xtra-5.1.3-sources.jar * Probably redundant here - notice.txt * Info about iText project # iText.cfc * The plugin ####### Putting it in ColdBox ####### Put the iText-lib folder and the iText.cfc file into the plugins folder of your application call: iText = getMyPlugin("iText"); In any of your handlers, layouts or views and you are good to go. Alternative using wirebox: property name="iText" inject="coldbox:myplugin:iText"; In any of your components! Example: ############################################################################ Handler: iText.cfc ############################################################################ component{ function index(event,rc,prc){ event.setLayout("empty"); event.setView("iText/test"); } } ############################################################################ ############################################################################ Layout: empty.cfm ############################################################################ <cfoutput>#renderView()#</cfoutput> ############################################################################ ############################################################################ View: iText/test.cfm ############################################################################ <cfscript> iText = getMyPlugin("iText"); /* * Call to iText to return a class of com.itextpdf.text.Document * Either using full or partial path * You still need to call init() to instanciate */ // iText.get(class = "Document", partial = true); writeDump(var=iText.get("Document")); // iText.get(class = "text.Document", partial = true); writeDump(var=iText.get("text.Document")); // iText.get(class = "itextpdf.text.Document", partial = true); writeDump(var=iText.get("itextpdf.text.Document")); // iText.get(class = "com.itextpdf.text.Document", partial = false); writeDump(var=iText.get("com.itextpdf.text.Document", false)); // or use wrapper writeDump(var=iText.getFullPath("com.itextpdf.text.Document")); /* * Use some of the wrapper methods of iText.cfc to do some of the hard work for you * These are methods that hopefully will be expanded rapidly */ /* * Will return an empty document with given page dimensions * because measurement is metric, the size will be calculated using milimeters */ document = iText.sizedDocument( pageWidth = 210, pageHeight = 297, leftMargin = 25, rightMargin = 25, topMargin = 15, bottomMargin = 15, measurement = "metric" ); /* * Will return an empty document with given page dimensions * because measurement is imperial, the size will be calculated using inches */ document = iText.sizedDocument( pageWidth = 8, pageHeight = 11, leftMargin = 1, rightMargin = 1, topMargin = 0.5, bottomMargin = 0.5, measurement = "imperial" ); /* * Will return an empty document with given standard page dimensions * because measurement is metric, the margins will be calculated using milimeter */ document = iText.standardSizeDocument( size="A4", leftMargin=20, rightMargin=20, topMargin=20, bottomMargin=20, landscape=false, measurement="metric" ); </cfscript> ############################################################################
About
iText Project that provides iText PDF operations to ColdBox applications
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published