3

I am currently creating a WCF service to Print a HTML file that has been saved in a specific location. This HTML file then needs to be printed to a specific printer on our network, the issue I am currently facing is in regards to printing the HTML.

As this is a WCF service some of the basic methods that can be used in WinForm applications cannot be used (for example WebBrowser). This causes issues as I am not entirely sure what other methods and options I have. The service is also asynchronous which means that multiple files can be sent through the application for printing at any point, which means that the solution also needs to be able to handle multi threading.

I have currently used the PDF method of printing within this WCF application, but have had issues with this so have been asked to convert the WCF to print passed in HTML instead. the issues are associated with the use of Adobe, and before we decide to move over to FoxItReader I have been asked to validate HTML as an option.

Thank you for your time.

1 Answers1

0

You still can use WebBrowser from a WCF service, although you'd need to organize a dedicated STA thread for it. Here is a basic sample of console app doing just that, and the architecture of console application is in a way similar to the one of WCF service. You'd need to add some consumer/producer queue logic to it.

Specifying a custom printer is also possible, although not so trivial:
Add support to print & preview HTML in a dialog-based MFC app.

Besides the WebBrowser-based solution, there are some other options, still HTML-based:
Paginating HTML document for printing with WebKit-based browsers.

Community
  • 1
  • 1
noseratio
  • 59,932
  • 34
  • 208
  • 486
  • 1
    Thank you for your help, I am very surprised at the lack of information regarding this topic online or any printing topic based information from a WCF service. – SymbioticKaos Nov 29 '13 at 14:39