Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I select a layout when using Windows Picture and Fax Viewer (shimgvw.dll) to print jpgs from the command line?

I am automating the printing of jpg files using a windows batch file and the command line interface for the Windows Picture and Fax Viewer. The command I'm using in my .bat is:

rundll32.exe C:\Windows\System32\shimgvw.dll,ImageView_PrintTo /pt "%fullpath_to_jpg%" "%printer_name%"

My photo printer does 4x6 prints. If the jpg file is exactly 4x6 aspect ratio, everything works fine and I get a full-bleed 4x6 print. If not, I get a white border that I do NOT want. In Windows Explorer, I can right click on the non-4x6 jpg and select print to invoke the Photo Printing Wizard, select "Full page photo print" and it crops to give me the full-bleed 4x6 print that I want.

How can I specify "Full Page Photo Print" layout selection from the command line to tell shimgvw.dll to "crop and rotate to fit" not "center and rotate to fit"? Is there a registry setting to select this as the default layout instead of the "Full page fax print? Should I be using photowiz.dll instead of shimgvw.dll?

I can't find a reference for command line parms or registry settings for these dlls.

like image 890
user206481 Avatar asked Feb 12 '10 16:02

user206481


1 Answers

Bad news: there is no way to do this, even with VBS. I extracted all the strings and did significant searches on the web for all means of controlling this .dll and only two basic ones exist:

rundll32 shimgvw.dll,ImageView_Fullscreen c:\temp\grub.jpg

will print grub.jpg to the screen

rundll32 shimgvw.dll,ImageView_PrintToW /pt c:\temp\grub.jpg "Microsoft XPS Document Writer"

will print grub.jpg to the MS Office XPS printer, though this and PDF printers will require you to select a filename so automating this way is not possible

The only way to possibly automate printing using built-in methods to XP would use SendKeys, but that's a horrible solution, given that any accidental keystrokes entered by the user would render the output different than what you want. Of course you could always start the process hidden in VBS but this is not an ideal solution.

like image 72
Lizz Avatar answered Sep 30 '22 06:09

Lizz