Print Images using CFEXECUTE - printing

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.

Related

Objective C and SVG

I am receiving a SVG back from our server that I need to display. What the server is returning is:
preview = "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"256\" height=\"256\" preserveAspectRatio=\"xMedYMed meet\" viewBox=\"-10756457.3242036 -5943062.39021874 1277.60796701722 1244.16676712781\">\n <path d=\"M -10756407.324203580617905 -5942993.280961670912802 L -10756388.214946510270238 -5941880.166737286373973 -10755229.716236563399434 -5941868.223451617173851 -10755244.048179365694523 -5942728.140019812621176 -10755394.533578801900148 -5942730.528676947578788 -10755396.922235935926437 -5943012.390218744985759 -10755578.460178112611175 -5943005.224247347563505 -10755671.617806335911155 -5942995.669618809595704 -10755764.775434559211135 -5943005.224247347563505 -10755845.98977711237967 -5942990.892304535955191 -10755958.256662406027317 -5943000.446933076716959 -10756166.069833055138588 -5943002.835590209811926 -10756216.231632867828012 -5942998.058275939896703 -10756261.616118412464857 -5942990.892304535955191 -10756347.607775231823325 -5943002.835590209811926 Z\" stroke-width=\"1\" fill=\"black\" stroke=\"black\">\n </path>\n</svg>";
I am looking at the library the SVGKit. I'm not exactly sure what I can do with this information. Can SVGKit load this type of data or does it need to be a local SVG file?
We want to use this SVG cause its a lot smaller then a .png and the server is returning lots of them.
Any ideas on what I can do?
According to the documentation you can load an SVG file from data which is what you have.

Using printer name Adobe PDF

I have looked everywhere for this solution. The code below allows me to print to the printer, Adobe PDF, but what I want to do is automate the file name save as screen with a generic name and in a specific folder. For example, the file would be saved to C:\temp\tmpResize.pdf and I am having problems there.
var params = this.getPrintParams();
params.interactive=params.constants.interactionLevel.silent;
params.pageHandling=params.constants.handling.none;
params.fileName = "/c/temp/tmpResize.pdf";
params.printerName="Adobe PDF"
this.print(params);
Thanks for your help.

nicEdit Uploading Locally - Issues with nicUpload

If anyone has managed to get locally uploading images I'd be mightily appreciative of some help.
I've downloaded the latest version of nicEdit along with the nicUpload plug in (from nicedit.com - Version 0.9 r24 released June 7th, 2012).
I've also downloaded nicUpload.php from http://svn.nicedit.com//trunk/nicUpload/php/nicUpload.php
NicUpload.php - I've set NICUPLOAD_PATH and NICUPLOAD_URI both to 'images' which is the subfolder of where nicupload.php and nicEdit.js are located.
NicEdit.js - I've added the following to line 271:-
uploadURI : 'nicUpload.php?id=123',
I've given it an ID otherwise it was failing with an invalid ID code. But the ?id=123 isn't meant to be there. I've also set the iconsPath accordingly.
Line 1370 I've switched this:-
nicURI : 'http://api.imgur.com/2/upload.json',
for this:-
nicURI : 'http://www.mydomain.com/nicedit/nicUpload.php',
But I'm still getting "Failed to upload image". I've searched and searched and searched for answers to this and I'm getting close to having spent two days tinkering with it.
With a few debugging displays I can see that it's failing on line 46 of nicUpload.php where it says:-
$file = $_FILES['nicImage'];
$image = $file['tmp_name'];
$max_upload_size = ini_max_upload_size();
if(!$file) {...
That last IF is true and that's where it exits with the error.
Appreciate anyone being able to help.
The nicUpload.php script file laying around sucks and I don't even understand how it could work.
NicEditor uses imgur as the default image upload service. The source code follows the API format described here: http://api.imgur.com/resources_anon#upload
My suggestion would be to implement the API request and response defined there.
I did not use the niceedit upload function to do what you want. I managed to add a button to the link and img dropdown menu. The button opens a file manager window where you also can upload. I managed to put then de url of the image or document into the nicedit drop down img or url window. That is how I solved the problem.

Can't load images from Content folder on iis in asp mvc project

In visual studio virtual server this works. But when I put site on IIS it doesn't display images from content folder.
var imgPath = '/Content/Images/Icons/' + icon + '.png';
var imageContent = '#Server.MapPath(Url.Content("-1"))';
image = imageContent.replace('-1', imgPath);
I get errors in browser foreach image
http://localhost/Content/Images/Icons/carwash.png Failed to load resource: the server responded with a status of 404 (Not Found)
First thing is first, are you sure that all of your 'icons' are part of the solution and are actually being deployed to your web server? I have had a few instances where I would add a file to the solution directory and VS does not automatically include in it the solution, thus it never actually gets deployed...
If that is ok and the images are actually there, my next question would be, have you tried just using the #Url.Content helper in your view to determine if that is working as it should?
<img src="#Url.Content("~/Content/Images/Icons/SomeIcon.png")"/>
EDIT
Since you are trying to accomplish this in Javascript and the above tag works in HTML, you should be able to condense that code up there to the following code:
var image = '#Url.Content("~/Content/Images/Icons/")' + icon + '.png';
Go ahead and let MVC get the path to the Icon folder and append your file and extension to that. This should eliminate the need for string replacement and still be able to process the icon paths in JS.
var image will now be the complete relative path to the icon file you have passed to this function. You can use this string to update and img src tag or create an image or whatever.

Save current webpage in Watin

I'm trying to save the full content of the current static web page, using the code from Show IE "Save As" dialog using Watin
So here it is:
IE ie = new IE("http://localhost");
// more code
//I expect out.html is the output file
FileDownloadHandler fileDownloadHandler = new FileDownloadHandler("out.html");
//I expect this line to popup the save as dialog box, but nothing happens
ie.AddDialogHandler(fileDownloadHandler);
//the program is blocked at this line, as it can't click anywhere
ie.Link("startDownloadLinkId").Click();
fileDownloadHandler.WaitUntilFileDownloadDialogIsHandled(15);
fileDownloadHandler.WaitUntilDownloadCompleted(200);
I also tried the code below, but it doesn't save all the page:
System.IO.StreamWriter file = new System.IO.StreamWriter("output.html");
file.Write(ie.Html);
Again, I need to save the webpage from Watin, and the result to be the same as saving it manually.
Thanks!
Here is how I do it:
File.WriteAllText("myfile.html",
(myIE.InternetExplorer as SHDocVw.InternetExplorer).Document.documentElement.outerHtml);
Assumes myIE is a WatiN IE element, of course.
If you're ever having difficulty finding how to do something with WatiN, I often find it helpful to google how to do it with an "Internet Explorer COM object". WatiN wraps the object, but it is exposed and able to be accessed!
Cheers!
Try to parse the html with html agility pack and save it, there are additional abilities that you can use...
using HtmlAgilityPack;
var htmldoc = new HtmlDocument();
htmldoc.LoadHtml(ie.Html);
htmldoc.Save(stream);
Link to agility pack

Resources