0
votes

I have a system service that handles print requests, and given a printer name from the user, attaches a DC to that printer. It starts a document, ends it, and detatches.

m_PrinterDC.CreateDC (L"WINSPOOL", _printerName.c_str(), NULL, NULL)
m_DC.Attach(m_hprinter)
m_DC.StartDoc(...)
...
mDc.TextOut(...)
...
m_DC.EndDoc()
m_DC.Detatch()

This works fine for normal printers, but when using the "Print to OneNote" functionality (driver name 'Send To OneNote 2010') it doesn't seem to work. I would like to avoid custom logic just for this feature; ideally all printers would work regardless. Any thoughts what might be going wrong? I've tried updating the printer security settings to include Print rights for group everyone; not sure what else to try.

1
"it doesn't seem to work" - please be more precise. Which call fails? You did check return values, did you? - MSalters
No dialog appears 'sending document to printer', etc. None of the calls fail, all return expected values (not every call is checked, but all the setup-teardown is). Each of those functions is actually called like: if(m_DC.EndDoc() < 0) LOG(L"Failed to end document printing");, but no error appears. - Rollie

1 Answers

0
votes

Unfortunately, I have to guess some points, because you seem to avoid detailed description of error condition.

First, if you check all return values are success, just it may be a problem about onenote itself. Check the condition of onenote by printing using other programmes.

Second, did you check if _printerName is exact? If some of users are using other language OS, the driver name, 'Send To OneNote 2010' will be different or depending on version. Of course, if you check all return values of function calls, it recorded in your log file. However, I'm worrying about you used exact printer name by using 'EnumPrinters'.

http://msdn.microsoft.com/en-us/library/windows/desktop/dd162931(v=vs.85).aspx

I hope this helps you a little.