Printing barcode labels from CF

172 views
Skip to first unread message

hofar...@houseoffusion.com

unread,
Mar 25, 2014, 10:23:16 AM3/25/14
to ColdFusion Technical Talk

I'm building a membership system where I will need to print barcode labels
(Code128) from a CF app. I've got the barcode creation down (using a
JQuery plugin), but haven't started the label creation piece. I was
thinking of using CSS + cfdocument, but am concerned that PDF's crappy
support of CSS will cause me trouble. Has anyone else done something like
this? What do I need to look out for?

Thanks

Pete


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:358077

hofar...@houseoffusion.com

unread,
Mar 25, 2014, 11:27:33 AM3/25/14
to ColdFusion Technical Talk

A number of years ago I accomplished a similar need through the utilization of a client side print ocx which allowed the user to select a printer to be used for label printing. Once they selected the printer, I was able to manipulate the required settings and query paper size information that I would pass back to my label designer and return the HTML that I would then send to the printer. It worked beautifully and the clients loved it.

I do not remember the name of the control, but it was a commercial ocx. Our clients did a lot of label printing so installing the ocx was not an issue for them. I do not know how if you are intending for the client to print barcodes or not, but if this will be an administrative function it might be something to consider.

David Phelan
Web Developer
IT Security & Web Technologies

Emerging Health
Montefiore Information Technology
3 Odell Plaza, Yonkers, NY 10701
914-457-6465 Office
dph...@emerginghealthit.com
www.emerginghealthit.com
www.montefiore.org

________________________________________
From: Pete Ruckelshaus <prucke...@gmail.com>
Sent: Tuesday, March 25, 2014 10:23 AM
To: cf-talk
Subject: Printing barcode labels from CF
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:358078

hofar...@houseoffusion.com

unread,
Mar 25, 2014, 12:25:37 PM3/25/14
to ColdFusion Technical Talk

Yay! I'm useful for something. I have much experience with barcodes printing. Part of the system I work on includes creating barcodes for E-Tickets to be used for admission to amusement parks.

A couple resources for you to use: http://cfbarbecue.riaforge.org/. It's a CF wrapper to a Java library that can create images of barcodes. Once you install it into your CF server (copy some files to a directory, restart CF), you can call the component to create a CFIMAGE and it will spit out a PNG or JPG or what ever other format it supported.

If you're planning on creating a PDF, a couple things you'll have to remember: CFIMAGE and CFDOCUMENT uses an HTTP call to generate those files (or something like that). You'll have to either A) edit your host files to accept your domain B) reference the image using "file:\\\". http://www.ravenglass.com/blog/index.cfm/2010/6/9/Including-Images-in-a-PDF-created-in-CFDOCUMENT & http://stackoverflow.com/questions/10637542/coldfusion-cfdocument-creates-a-red-x

It isn't as complicated as it sounds, just a couple gotcha's you have to be prepared for. Hope that helps.
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:358079

hofar...@houseoffusion.com

unread,
Mar 25, 2014, 3:35:44 PM3/25/14
to ColdFusion Technical Talk

Sorry if I misunderstand the issue. I've used cfbarbecue http://cfbarbecue.riaforge.org/ in a number of apps with no problems.
It simply uses <cfimage> to print the barcode to the screen. I opened that document in a small window and sent it to label printer using JS window.print().
Then using any label printer I have been able to print the barcode perfectly.
HTH

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:358080

hofar...@houseoffusion.com

unread,
Mar 25, 2014, 7:48:35 PM3/25/14
to ColdFusion Technical Talk

Thanks. I think I'm going to try using CSS and print as an HTML file
first, and if I run into issues, I'll go with cfdocument.
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:358082

hofar...@houseoffusion.com

unread,
May 24, 2014, 10:04:11 AM5/24/14
to ColdFusion Technical Talk

Followup, here's what I used to print to an HP m251w. Works great printing
to Avery 5520 3x10 labels. Set margin to 0 when printing from within
Chrome:

<cfsetting showdebugoutput="No" enablecfoutputonly="Yes"><!--- --->
<cfimport taglib="/extensions/custom_tags/" prefix="ct">
<ct:security allow="board,admin"><!--- --->

<cfparam name="url.memberFamilyID" default="0">
<cfquery name="getRecord" datasource="#request.datasource#">
[redacted]
</cfquery>

<cfoutput>
<html>
<head>
<meta name="google" value="notranslate">
<meta http-equiv="content-language" content="en">
<script type="text/javascript" src="
http://barcode-coder.com/js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="
http://barcode-coder.com/js/jquery-ui-1.7.custom.min.js"></script>
<script type="text/javascript" src="
http://barcode-coder.com/js/jquery-barcode-last.min.js"></script>
<script language="JavaScript">
function bc() {
<cfloop
query="getRecord">$('##bcTarget#getRecord.memberID#').barcode('#getRecord.memberID#',
'code128', {barHeight:50, barWidth:1, showHRI:true, fontSize: 11});
</cfloop>
}
</script>
<style>
@media print
{
div.row
{page-break-after: auto;}
div.spacer
{height: 90px;}
}
body
{text-align: center;
font-family: arial;
font-size: 11px;
margin-left: 0px;
margin-right: 0px;
margin-top: 45px;
margin-bottom: 48px;}
div.spacer
{height: 90px;
clear: both;
border: 0px solid blue;}
div.row
{margin: 0px;
padding: 0px;
page-break-after: auto;}
div.label
{width: 232px;
height: 83px;
margin-left: 13px;
border: 1px solid white;
float: left;
padding-top: 5px;}
</style>
</head>
<body onLoad="bc();">
<div class="row">
<cfloop query="getRecord">
<div class="label" align="center"><div class="bc"
id="bcTarget#getRecord.memberID#"></div>
#getrecord.memberfirstname# #getrecord.memberLastName#
#getrecord.memberNameSuffix# (DOB: #dateFormat(getRecord.memberDOB,
"MM/DD/YYYY")#)</div><cfif getrecord.currentrow MOD 3 EQ 0></div>
<cfif getrecord.currentrow MOD 30 EQ 0>
<div class="spacer">&nbsp;</div>
</cfif>
<div class="row"></cfif>
</cfloop>
</div>
</body>
</html>
</cfoutput>
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:358680
Reply all
Reply to author
Forward
0 new messages