Invoke default printer dialogue from command line.

Miscellaneous Forums/General Discussion/Invoke default printer dialogue from command line.

Is this ^^^^^ possible under Windows? Hunted high and low, I have, but the only examples of getting the dialogue up involve sending something to print. Seems like the sort of thing that *should* be straightforward.

IIRC typing something like:
type myfile.ext >LPT1:

or

type myfile.ext >PRN:


used to do it, the thing is with USB printers I dont think they are taken into account. There also used to be a Print.exe command under MS-DOS.

You can also print to a serial port ie. COM1 as well for special printers (eg, those nasty oldskool receipt printers)

To connect to, or disconnect from, a shared printer:

"net use LPT2: \\myprintserver\myprinter"

then:
"type myfile >lpt2"
or:
"print /d:LPT2: myfile"

It this doesnt work try mapping lpt1

there are many others too, like viewing and cancelling jobs from the queue etc but i cant remember what they are :/ something like "print jobnumber /delete" or something.

Thanks for the suggestions. I can print from command line just fine, it's the actual printer dialogue I wast to magic up (where you can select the desired printer and/or set preferences for it) without sending a print job to it. As you can send print jobs with or without calling this dialogue I'm surprised it can't be called on its own.

I'm not sure its possible. What if you'd opened the dialog and then clicked "OK". It'd normally print, but what if it didn't know what it was meant to be printing?

What are you trying to do, anyway? Maybe there's another solution.

Not sure whether it will help but did you do your searches using 'dialog' as well as 'dialogue'?

Take a look in the decls (userlibs) section of the codearchives. Im not sure if any printer services have been wrapped yet.

I saw a thing for printing an image in one of them once, mabe that will help.

Oh I'm looking at the various different ways of getting something printed out from Max -- it really needs a cross-platform printer module along the lines of Kantai's B3D/+ lib!

All I want to do is arbitrarily place sections of text on the page, write them in a system font (Courier) and print them somehow, but every solution out there seems to have problems: The main thing is wanting complete control over each page's appearance so a print job of several pages will actually be my code formatting a series of pages and sending them out as individual print jobs. But -- uh oh! -- suppose the deafault priner is set to colour mode? That's really a really horrible thing for an application that only prints black text not to allow you to switch out of! Having a way for the user to summon the default printer's prefs dialogue (where 'Okay' just confirms the settings) really is quite vital.

I've been looking at just dumping straight to pdf, from which the user can then print with Adobe Reader if they want. In computing terms that's quite elegant -- my app' doesn't have to replicate functionality the user already has installed. However, if I'm honest, I really don't understand what the PDFLib license allows/forbids or whether it even applies to me as someone using a dll someone else made with PDFLib! (I tend to avoid GNU-like GPL/LGPL-like licenses on the grounds that nobody seems to be able to give a straight answer about what they mean).

Also, PDFLib ain't cross-platform. Cairo is, but I've already run into problems with that as it expects an equivalent of Linux's font cataloguing -- I would have to write a Cairo-lite mod to use it, I think.

There's always MaxGUI's GadgetPrint() but I don't own MaxGUI and the demo already expired when I was testing Max itself. Plus I get the impression that GadgetPrint() really isn't very reliable.

So Max looks like a fantastic language for manipulating the data I want to print, but actually getting it to the printer reliably is something else!

Bet you're sorry you asked now. :)

Sledge,

If you want to access the print dialog and setup from the command prompt type:

 Rundll32 Printui.dll,PrintUIEntry /? 

Hope it helps.

Darkheart

-=Darkheart=-, that's a massive step in the right direction -- thanks! Now I'm going to scoot off and find out how to direct it to the default printer.

it really needs a cross-platform printer module

Yeah, cross-platform printing is cool, especially when it has integrated print-preview etc.

but every solution out there seems to have problems

I haven't come across anything terribly troublesome with my own solution, but it's not been extensively tested as yet. (Printing, last time I tried it, was working happily on both Win32 and MacOS.)

MaxGUI's GadgetPrint() has problems indeed.. and as its name suggests prints gadgets - which is fine if you want to print a textarea or whatever, but not for much else.

Otherwise, BlitzMax has a lot going for it in the application arena (not that anyone would use it for that, since it's a *Games* programming language... but anyway).

Persevere, I say. You'll come up with something :-)

I haven't come across anything terribly troublesome with my own solution

You mean wxMax? I'll give it a look! (EDIT: You appear to be employing some darke majiks called 'Subversion'. I am afeared!)

Well I've got it all compiled and I see there's PDF functionality in wxMax also -- this looks perfect Brucey. :)

The PDF stuff is WIP... Check out the sample docs from HERE to see what it'll be able to do.
The API is *very* easy too :-)