Replacements for OpenPrinter/PrinterSetup in Console Programs

I need to write a sort of printing daemon that sits on a server and creates and prints documents to different printers. Unfortunately OpenPrinter and PrinterSetup are not available in console programs, so I wonder whether this can be done in Xojo without doing it all via the windows API?

In VB6 and PowerBasic, I used something called DDOC, from GreatWebDivide. I did some preliminary tests with RB a while back. It worked, using cstrings. I designed a VB6 application with pretty sophisticated printed documents using this utility. I think that Don Dickinson pretty much abandoned development on this utility, but it worked just fine up to Windows 8.1. I still have to test my app on Windows 10.

It was not expensive when I bought it. It may be worth a try.

This is only going to work on Windows (Win32).

Thanks for the hint, I will have a look at this. Did you ever try to use it in a RB console app when you tested with RB ( just asking because the free version comes with nag screens which probably do not harmonize with a console app. )?

The only functionality I actually need is sending complete pages as pictures to a printer queue ( which I could easily do if I could get hold of the printers graphics object).

No. I tried with a desktop program. I don’t see why it would not work.

Shell to the program you want to print.

See http://superuser.com/questions/477895/printing-from-windows-7-command-line

I just tried both of these which work just fine :

"%ProgramFiles%\\Windows NT\\Accessories\\wordpad.exe" /p list.txt %windir%\\system32\\mspaint.exe /p robot100.png

For the picture, the document was printed fit to paper.

I have been trying to replace the default printer dialog by my own to make it look better like the Modern UI style. At this moment I am trying to find as much as I can by shell, before going into the meanders of the API.

I also found that which is very interesting about managing printers from the command line :
http://woshub.com/manage-printers-and-drivers-from-the-command-line-in-windows-8/

I also found this :
http://superuser.com/questions/135393/list-printers-from-command-line-to-text-file

Here is how to set the default printer :
http://community.spiceworks.com/how_to/2564-how-to-set-the-default-printer-via-command-line-prompt

Also, https://technet.microsoft.com/en-us/library/cc782930(v=ws.10).aspx?f=255&MSPPError=-2147217396

Thanks to both of you for taking the time to answer.

@Louis:
I was afraid it might not work for the same reason PrinterSetup and OpenPrinter are not available for console. These probably contain fixed links to dialog/window related elements ( just my guess, no Xojo engineer answered so far ) and reading about nag screens and all the preview functions in DDOC made me assume it could be similar. I will send an email to Don though to ask him about this.

@Michel Bujardet
Thanks for the effort of selecting all the quotes and links. Actually I do have an older version of the program that prints by shelling either FoxitReader or XchangeViewer for printing PDF files it creates before (to one or more network printers. Unfortunately it happens every time and again that these Viewers seem to run into synchronization problems and quit working without giving back errors to the program but with creating popups - after all they are windows programs. Therefore I had hoped to print directly from within Xojo by setting the default printer via Windows API, rendering page by page as a picture and send it to the printer(s) . I tested this in desktop programs where it works quite nicely, but it is not available for console.

[quote=205934:@Silke Arnswald]@Michel Bujardet
Thanks for the effort of selecting all the quotes and links. Actually I do have an older version of the program that prints by shelling either FoxitReader or XchangeViewer for printing PDF files it creates before (to one or more network printers. Unfortunately it happens every time and again that these Viewers seem to run into synchronization problems and quit working without giving back errors to the program but with creating popups - after all they are windows programs. Therefore I had hoped to print directly from within Xojo by setting the default printer via Windows API, rendering page by page as a picture and send it to the printer(s) . I tested this in desktop programs where it works quite nicely, but it is not available for console.[/quote]

You still have an option worth trying. A windowless desktop app. I have successfully used that for a service app once. It could save you the aggravation of using the WinAPI.

Good idea.
Can someone from Xojo confirm that using OpenPrinter and PrinterSetup in a windowless desktop app would be reasonably safe? The thing would not even run as as service but get started via the windows scheduler in the morning and run until 20:00 processing an average of 40-80 documents per day with 1-3 printouts each.

I use DynaPDF to build the page within my console and web apps. You can send them to a user. But given a PDF I am not sure if this would be easier to sent directly to a printer. DynaPDF might be able to output to PostScript which could be sent to a PostScript printer via a Shell command.

Thanks for the input I will look into that.