0

I have an image gallery running in ColdFusion. I would like to be able to print the images, without generating a PDF first. I believe this can be done using CFEXECUTE.

Basically there will be a session storing the images and when the proceed button is clicked, CFEXECUTE will kick in and use Windows Photo Viewer to open the image and the print all of them, is this possible? Can all images be opened and printed in the same queue or do they have to be opened one by one?

Update 1:

My issue is with the arguments that go in CFEXECUTE. I have opened cmd.exe and then in the arguments I need to open Windows Photo Viewer which is not an exe but a DLL. This is where the issue lies for me, and then would I put the path to all the images in the arguments as well?

Update 2:

This is the code I have tried:

<cfset args = []>
<cfloop index="thisitem" from="1" to="#arrayLen(session.orderbasket)#">
<cfset args[thisitem] = '#mainpath#\#session.orderbasket[thisitem].path#\#session.orderbasket[thisitem].image#'>
</cfloop>
<cfset printer = "DP-DS620">
<cfloop index="thisitem" from="1" to="#arrayLen(session.orderbasket)#">
<cfexecute name="C:\Windows\System32\cmd.exe" arguments="rundll32 C:\Program 
Files\Windows Photo Viewer\PhotoViewer.dll '#args#' '#printer#'" 
timeout="99"></cfexecute>
</cfloop>

I get this error:

Complex object types cannot be converted to simple values.

Any help regarding the correct syntax would be greatly appreciated.

James A Mohler
  • 11,060
  • 15
  • 46
  • 72
johnnyc0506
  • 133
  • 1
  • 3
  • 12
  • 1
    If you mean print something on a *user's computer*, no it is not possible. CFExecute can only run programs on the CF server. So even if you did use it to open Photo Viewer, the program would open on the CF server. The user would never even see it. – Leigh May 31 '17 at 12:30
  • It will print off the server that is running CF, so the user doesn't get to see anything except their photos that have been printed, I'm having issues with CFEXECUTE as what I want it to do is not really well documented – johnnyc0506 May 31 '17 at 12:36
  • @Leigh, in an intranet situation such as the one I work in, the user might have have physical access to the printer. I've done similar things with text files and notepad. – Dan Bracuk May 31 '17 at 13:10
  • 1
    @DanBracuk - True. It is certainly valid, it just sounded like the typical confusion about client versus server side capabilities initially. johnnyc0506 - Hard to tell which part you are struggling with without any code, but... it sounds like you are asking how to run Photo Viewer via command line (which is not a CF specific issue). I do not know if it is possible, but assuming it is ... you would need to get it working from the command line first, before doing anything with cfexecute. – Leigh May 31 '17 at 14:57
  • My issue is with the arguments that go in CFEXECUTE, i have opened cmd.exe and then in the arguments i need to open Windows Photo Viewer which is not an exe but a DLL, this is where the issue lies for me, and then would i put the path to all the images in the arguments as well? – johnnyc0506 May 31 '17 at 15:46
  • Yes, you cannot run a dll from cmd.exe. Have not tried it myself, but a brief search on "run photo viewer dll from command prompt" turned up [this thread](https://stackoverflow.com/questions/6190271/how-to-run-photoviewer-dll-in-command-line) which suggests using `rundll32.exe`. – Leigh May 31 '17 at 18:05
  • (Edit) (Edit) Regarding the error, `args` is an array (i.e. complex object). You cannot mix strings and arrays. Either convert the array to a string, or pass in an array containing *all* of the arguments (not just file names). Also, do not forget to capture the result/errors so you know if something went wrong. – Leigh Jun 01 '17 at 21:01
  • Unfortunately I am not sure if any of these tools allow printing multiple files. [This thread](https://stackoverflow.com/questions/11321919/command-line-photo-printing-in-windows-7) mentions using `mspaint` or `shimgvw.dll`. Both work for single images on Windows 7. However, neither seems to support multiple files. – Leigh Jun 03 '17 at 20:25

0 Answers0