forked from TVScoundrel/ColdBox-iText-Plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME
168 lines (136 loc) · 5.42 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
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>
############################################################################