0
PDFLib Coldfusion example
Explorer
,
/t5/coldfusion-discussions/pdflib-coldfusion-example/td-p/497074
Oct 23, 2007
Oct 23, 2007
Copy link to clipboard
Copied
Developers,
I realize that iText has been widely discussed here and Coldfusion MX 8 now includes the <cfpdf> tag to merge and alter pdfs, but my company still uses CFMX 7 and PDFLib and am hoping for some assistance in altering pdflib code to work with coldfusion.
Below is the example pdf merge file provided by PDFLib. It is written in java, much like the iText example was, and then coded for Coldfusion by PaulH here. Thanks in advance for any and all help.
Code:
I realize that iText has been widely discussed here and Coldfusion MX 8 now includes the <cfpdf> tag to merge and alter pdfs, but my company still uses CFMX 7 and PDFLib and am hoping for some assistance in altering pdflib code to work with coldfusion.
Below is the example pdf merge file provided by PDFLib. It is written in java, much like the iText example was, and then coded for Coldfusion by PaulH here. Thanks in advance for any and all help.
Code:
TOPICS
Advanced techniques
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Engaged
,
/t5/coldfusion-discussions/pdflib-coldfusion-example/m-p/497075#M45114
Oct 23, 2007
Oct 23, 2007
Copy link to clipboard
Copied
Not sure if this helps at all, but we merge and fill PDFs
with CFMX 7 using pdftk, read more about it here:
http://www.accesspdf.com/pdftk/
It's basically a stand-alone executable that you can call with <cfexecute>.
http://www.accesspdf.com/pdftk/
It's basically a stand-alone executable that you can call with <cfexecute>.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Lumpia
AUTHOR
Explorer
,
/t5/coldfusion-discussions/pdflib-coldfusion-example/m-p/497076#M45115
Oct 23, 2007
Oct 23, 2007
Copy link to clipboard
Copied
Thanks for the post Grizzly. Unfortunately, my company
acquired PDFLib and wants us to use this. Originally, I tested
iText and we were about to go forth with it, but they wanted the
company as a whole to use one product for similiar tasks, instead
of many products doing the same thing. Anyone else have ideas on
how to recode the attached java code for Coldfusion?
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Guide
,
LATEST
/t5/coldfusion-discussions/pdflib-coldfusion-example/m-p/497077#M45116
Oct 23, 2007
Oct 23, 2007
Copy link to clipboard
Copied
Lumpia,
You're probably going to have do it through a little trial and error. But it looks like there are only a few patterns you have to translate to CF, and they're repeated throughout the code.
For example the string array:
String pdffiles[] = ...
Probably translates to a CF array (ignoring 0/1 based index issues)
<cfset pdffiles = listToArray("PDFlib-real-world.pdf,PDFlib-datasheet.pdf,....")>
The call to
p = new pdflib();
Should translate to a createObject() call
<cfset p = createObject("java", "com.pdflib.pdflib").init() />
Once you've created the object, the methods from CF are almost exactly the same. Though you might need to use javacast() in a few places.
java:
p.set_info("Creator", "PDFlib Cookbook");
p.set_info("Title", title + " $Revision: 1.8 $");
cf:
<cfset p.set_info("Creator", "PDFlib Cookbook") >
<cfset p.set_info("Title", title + " $Revision: 1.8 $")>
The rest looks pretty standard. Try/catch becomes <cftry><cfcatch>. If becomes <cfif>. The for loop becomes <cfloop>. etc.
Keep in mind you can also use <cfscript> syntax. Though I didn't use it here, its probably closer to the java code in terms of syntax.
HTH
You're probably going to have do it through a little trial and error. But it looks like there are only a few patterns you have to translate to CF, and they're repeated throughout the code.
For example the string array:
String pdffiles[] = ...
Probably translates to a CF array (ignoring 0/1 based index issues)
<cfset pdffiles = listToArray("PDFlib-real-world.pdf,PDFlib-datasheet.pdf,....")>
The call to
p = new pdflib();
Should translate to a createObject() call
<cfset p = createObject("java", "com.pdflib.pdflib").init() />
Once you've created the object, the methods from CF are almost exactly the same. Though you might need to use javacast() in a few places.
java:
p.set_info("Creator", "PDFlib Cookbook");
p.set_info("Title", title + " $Revision: 1.8 $");
cf:
<cfset p.set_info("Creator", "PDFlib Cookbook") >
<cfset p.set_info("Title", title + " $Revision: 1.8 $")>
The rest looks pretty standard. Try/catch becomes <cftry><cfcatch>. If becomes <cfif>. The for loop becomes <cfloop>. etc.
Keep in mind you can also use <cfscript> syntax. Though I didn't use it here, its probably closer to the java code in terms of syntax.
HTH
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

