none
Winspool.drv not defaulting to printer settings RRS feed

  • Question

  • Using the Windows spool API (winspool.drv) to write bytes to a printer. As the user who is printing, I setup printer default settings like duplex and watermark. This doesn't flow to the printer. Printer always prints single page without watermark. I do not want to setup printer settings and am expecting the default printer setting to flow. Any ideas?

    [DllImport("winspool.Drv", EntryPoint = "WritePrinter", SetLastError = true, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
     public static extern bool WritePrinter(IntPtr hPrinter, IntPtr pBytes, Int32 dwCount, out Int32 dwWritten);

    Wednesday, September 23, 2015 2:36 PM

Answers

  • Thanks for your response. I have already seen the link, I don't it answers the question. 

    However, re-reading WritePrinter documentation. It looks like it expects these settings to be set at the document level and override the printer settings always

    "When a high-level document (such as an Adobe PDF or Microsoft Word file) or other printer data (such PCL, PS, or HPGL) is sent directly to a printer, the print settings defined in the document take precedent over Windows print settings. "

    • Marked as answer by G33kKahuna Tuesday, October 6, 2015 11:14 PM
    Tuesday, September 29, 2015 5:12 PM

All replies

  • Hi G33kKahuna,

    In my opinion, you could not only use “WritePrinter” method, you also need to use “EndPagePrinter” etc.

    You could read this article for details: How to send raw data to a printer by using Visual C# .NET

    Best Regards,

    Xavier Eoro


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, September 28, 2015 5:57 AM
    Moderator
  • Thanks for your response. I have already seen the link, I don't it answers the question. 

    However, re-reading WritePrinter documentation. It looks like it expects these settings to be set at the document level and override the printer settings always

    "When a high-level document (such as an Adobe PDF or Microsoft Word file) or other printer data (such PCL, PS, or HPGL) is sent directly to a printer, the print settings defined in the document take precedent over Windows print settings. "

    • Marked as answer by G33kKahuna Tuesday, October 6, 2015 11:14 PM
    Tuesday, September 29, 2015 5:12 PM