ColdFusion's new <CFPRINT> tag lets you print files from the ColdFusion server. And the new GetPrinterInfo() function reports information about available printers. But how can you get a list of installed printers? There is a list in ColdFusion Administrator, but what if you need this information within your own code? We probably should have added a GetPrinters() function, and maybe we will in the future. But for now, you can use this simple UDF which returns an array of printers recognized by the ColdFusion server:
<!--- Get installed printers --->
<cffunction name="GetPrinters" returntype="array" output="no">
<!--- Define local vars --->
<cfset var piObj="">
<!--- Get PrinterInfo object --->
<cfobject type="java"
action="create"
name="piObj"
class="coldfusion.print.PrinterInfo">
<!--- Return printer list --->
<cfreturn piObj.getPrinters()>
</cffunction>
This would be very helpful to me in particular if ColdFusion recognized printers installed on the client machine, not attached to the server. Can this function do that? If not, are there any plans to build one that can?
That's not possible. ColdFusion, and any server side software, can't reach across to get client settings. It would be a major security hole if this were possible. The only way you could do it is by having something run on the client that reported this back to you, an ActiveX control or Java applet or something like that.
--- Ben
I have tried at my PC and I can not list the network printers which are registered with TCP/IP port. Is that something expected?
TIA!
HTH
Damon
If there were a way to access - w/ the users permission, of course - to the *client* printer, than THAT would be a big deal. Currently we have a major pain in the behind trying to force landscape printing to a local client printer (we've managed to...hack it, I guess, and it works, but its ugly....)
If you're taking orders in the front office area (store), you can have the packing slip and receipt automatically print out to back room printers. Order "fillers" use them to fill the order and put them into the boxes along with product. This eliminates certain queuing steps in the order fulfillment process.
Another application for this tag would be in industries were documentation is king. Namely, insurance companies, mortgage and lending, banking etc...
Thanks for the tag! It's a good thing.
a) ALL network resources [servers, firewalls, printers, laptops, workstations, routers, etc] are tagged and bagged: IP-driven, internally and centrally controlled, what connects to what and who gets to see what
b) printers for "live" documents are very very tightly controlled, because there is million dollar liability in having closing documents printed on public printers ... even worse in having 6 and 7-figure checks printed to public printers
c) therefore, Network Engineering establishes a limited number of known network printers which are the only ones allowed to print live mortgage documents and only a select few production application servers are allowed to connect to them; workstations and branch servers are NOT allowed to even see let alone connect to these printers
d) the net result is that printing can only be controlled by application code on the application servers, never by the client-side application code
This is a prime example of why a business would want to be able to write application code capable of enumerating server-side printer options. Excellent solution from CF! and the hack to get the PrinterInfo array is no worse than the one to get the available DSNs from the DataFactory. Thanks!
--- Ben
Please tell me that there will soon be a way to pass some of these other settings to the printer via CFPRINT.
--- Ben
1. Will it print to a network printer that's installed on CFserver? Meaning shared from a printer server
2. I am printing dynamic data i.e., parts produced by Lot, using cfreport to print 2" X .5" labels and I want lot quantities to output copies. Is this possible?
3. Do you have an example of what my code structure should look to include <cfreport> and <cfprint> tags in one page?
Any update?