0

I am told that there is a fax modem that operates as a printer, and that I can use that as a standard printer in Windows to accomplish printing to fax destinations. Is that true? If so, what would be the best fax modem to use?

I see that there is a fax device in Windows 7 called Microsoft Shared Fax Driver. Is it possible to print to that, purely in code, without user interaction or popups, to achieve printing to fax?

This is for an application that I work on that can generate reports directly to printer. But we are talking with a client that wants to the reports to go directly to fax. Our application is a reporting library, so there's no user interaction, although there can be configuration to set the fax number, for example. We use J2D+JPS on the Java side, and System.Drawing.Printing on the .NET side. I know that the client could implement this with third party libraries, but I want to address the possibility of simply using our existing direct-to-printer feature.

Tomas
  • 125
  • 1
  • 10

1 Answers1

1

You can use the built-in Fax Service Extended COM API to send a fax programmatically, and without any user interaction.

The API allows you to check if there are any fax devices installed on the machine (via the FaxService.FaxDevices collection) and attach files to a FaxDocument via the Body property.

A caveat: the Body property is actually a string containing the path to the file that should be sent as a fax. From the documentation: the body has to be associated with an application that is installed on that computer, and the application has to support the PrintTo verb. This means that you can't fax the report directly from an in-memory object; you'd have to generate the report to some temporary printable file (an image, a PDF, or XPS) in some location, and set its' path to the Body property of the FaxDocument.

Zev Spitz
  • 13,950
  • 6
  • 64
  • 136
  • Thanks, Zev, that's helpful information for writing fax sending applications. Do you have anything to say about printing to a fax modem? Or a virtual printer device that faxes? – Tomas Dec 10 '12 at 23:39
  • I would assume that the details specific to a particular printer (in the case of the fax printer - the destination phone number, subject, cover page) are not available from `System.Drawing.Printer`. The UI that comes up is after the document has been handed over to be printed by the fax printer, at which point the .NET printing API is done. – Zev Spitz Dec 10 '12 at 23:47
  • For your needs, is there a difference between **sending a fax** without involving the user, and attempting to **print to the installed fax printer** without involving the user? – Zev Spitz Dec 10 '12 at 23:49
  • There is only a difference when considering the specific case of using the direct-to-printer feature of my application, in which case, I must use a printer device. – Tomas Dec 11 '12 at 00:04
  • I don't think you can set options on the fax from the .NET side, for the reasons I outlined in my first comment. What about checking within the direct-to-printer feature, if the destination printer is actually a fax device, and if it is then use the procedure I outlined in my answer? – Zev Spitz Dec 11 '12 at 00:32