Thank you Tahir for the quick response and the link to the Print Document Package documentation. Sadly, the scope of the Print Document Package is Windows desktop, so it isn’t relevant to printing from within a Windows service.
I understand that I can use the XpsPrint sample without Server 2012R2, but since my client wishes it to run unattended on Windows Server 2012 R2, that option is off the table. However, if there is a legacy printing patch available for Windows Server 2012R2, that would be of great interest. I read that there was a legacy printing patch for Windows Server 2008. Refer to KB971512.
I wish the Aspose XpsPrint sample did work as a service on Server 2012R2. I could send you my code, but it is nothing extraordinary, just a class that wraps the XpsPrintHelper. As I mentioned, it works running within a desktop app on Server 2012R2, but not from within a service. Since a hosting service needs to run in the context of a user account (to have access to installed printers) code alone will not fully represent my usage case.
Although I can’t submit my entire environment, I will share that the service is running in the context of my account and that it does in-fact find the installed network printer and when it prints, it throws error -2147467259 “The operation attempted is not supported”. Here is the stack trace:
================================ 2016-08-30_08:27:38_784
Error -2147467259 occurred in ProcessQueuedTasks
Source: DirectPrinter
Message: The operation attempted is not supported
Stack Trace: at XpsPrint.XpsPrintHelper.CheckJobStatus(IXpsPrintJob job) in C:\Source\DirectToPrinter\ExsDirect2Printer\ExsDirect2Printer\XpsPrintHelper.cs:line 159
at XpsPrint.XpsPrintHelper.Print(Stream stream, String printerName, String jobName, Boolean isWait) in C:\Source\DirectToPrinter\ExsDirect2Printer\ExsDirect2Printer\XpsPrintHelper.cs:line 86
at XpsPrint.XpsPrintHelper.Print(Document document, String printerName, String jobName, Boolean isWait) in C:\Source\DirectToPrinter\ExsDirect2Printer\ExsDirect2Printer\XpsPrintHelper.cs:line 47
at ExsDirect2Printer.DirectPrinter.ProcessDirectPrintTask(String dpPrinter, String dpDocument) in C:\Source\DirectToPrinter\ExsDirect2Printer\ExsDirect2Printer\DirectPrinter.cs:line 157
at ExsDirect2Printer.DirectPrinter.ProcessQueuedTasks() in C:\Source\DirectToPrinter\ExsDirect2Printer\ExsDirect2Printer\DirectPrinter.cs:line 87