Printing from a Windows Service [duplicate]

北城以北 提交于 2019-12-01 10:45:58

The point is not how to print from a windows service or from an application, if you don't want any user interaction to be required you have to specify all print parameters without any need to show a print dialog ( which you can't because a windows service has no access to the UI ).

see here: http://msdn.microsoft.com/en-us/library/system.drawing.printing.printdocument.aspx

Try to create a Multithreaded Services. Once you create the service with Admin previledges, it won't get interfere by users. (Actually I didn't understantpurpose of "without the need of any user-interaction")

Joe

There is another discussion on this using crystal reports: Print without Printer selection dialog

And here's another one for printing html Print html document from Windows Service without print dialog

Hopefully, they'll get you started in the right direction.

// Class that handles printing
class MyPrintDocument : PrintDocument
    {
       //...
    }

when you want to print:

        // Create an instance of your printer class
        MyPrintDocument printer = new MyPrintDocument();

        // Set StandardPrintController so status dialog won't appear
        printer.PrintController = new StandardPrintController();

To 'silently' print from a Windows Service you should utilise Win32 GDI API.

If you are developing a Microsoft .NET application, you can use Platform Invocation Services (PInvoke) to call the Win32 GDI APIs to print. Heres a nice PInvoke tutorial. Take a look here for Win32 GDI methods etc.

Here is more information and an example regarding printing from a windows service from Microsoft's DSUI team... take a look

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!