WritePrinter() with RAW data fails to print with TS Easy Print


Symptoms


Calls to the WritePrinter() API to write RAW data directly to a printer will fail with Terminal Services Easy Print, a feature available in Vista and later OS versions. 

Cause


This is because the TS Easy Print feature creates an XPS document which is sent to the client, and the client must add data to this document.  But XPS does not support RAW data, so the call will fail.  This behavior is a by design limitation in the Terminal Services Easy Print feature. Terminal Services Easy Print cannot be used to write RAW data to a printer.

Resolution


Disabling Terminal Services Easy Print with the following group policy option will avoid this limitation:

Computer Configuration\Administrative Templates\Windows Components\Remote Desktop Services\Remote Desktop Session Host\Printer Redirection\Use Terminal Services Easy Print printer driver first