I want to (programmatically) print documents of various types, by asking Windows to do it (using the default associated application). How can I do this (in .NET or C++/Win32 API)?
For example, if I have MS Office and Acrobat Reader installed on the machine, PDF files should be printed by Acrobat Reader, and DOC files should be printed by MS Word. But if I don't have MS Office installed, DOC files should be printed using Wordpad, or OpenOffice.org Writer if the latter is installed, or whatever application is currently the default association for that type of files.
To start, right-click your Windows Start menu button and click the “Event Viewer” option. The Event Viewer will allow you to view a list of previously printed files, but you'll need to set Windows to begin logging your long-term printer history first.
Alternatively, click (Down arrow) of the Start Printing button in the Edit and Print Clips screen and select Print Settings.... The Print Settings dialog box appears. The Print dialog box is used as an example in the following descriptions. Each setting item is the same for Print Settings dialog box.
Click File > Print. Under Settings, choose the color printing option, and any other options you want, and click the Print button.
Try using the ShellExecute function.
For example, in C:
ShellExecute(my_window_handle, "print", path_to_file, NULL, NULL, SW_SHOW);
Call ShellExecute
. Use "print" for the lpOperation
parameter.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With