PrintQueue::GetPrintCapabilitiesAsXml() does not initialize until the property DefaultPrintTicket() is invoked

StackOverflow https://stackoverflow.com/questions/12205036

  •  29-06-2021
  •  | 
  •  

質問

This sounds like an initialization problem on certain printers. Here's the use-case:

 // Get the default printer.
 PrintQueue printer = LocalPrintServer.GetDefaultPrintQueue();

 // Get the printer properties as XML from the system and populate the instance of PrinterProperties.
 Stream printerDocmentStream = printer.GetPrintCapabilitiesAsXml();

From the XML document retrieved, the XML element PageMediaSize does not hold comprehensive list of supported page sizes for certain class of printers.

However, when XML document is retrieved after a call to the DefaultPrintTicket, the XML element PageMediaSize returns all the supported page sizes. The code is as follows:

 // This call initializes the printer properties.  <--------------------
 PrintTicket dummyPrintTicket = printer.DefaultPrintTicket; <-----------

 // Get the default printer.
 PrintQueue printer = LocalPrintServer.GetDefaultPrintQueue();

 // Get the printer properties as XML from the system and populate the instance of PrinterProperties.
 Stream printerDocmentStream = printer.GetPrintCapabilitiesAsXml();

I am guessing that a call to DefaultPrintTicket initializes the instance of PrintQueue, there is an initialized method but it is protected.

Is this bug ? Is anyone seeing a similar behavior ?

P.S: The printer I am using is: HP Designjet T7100ps HPGL2

役に立ちましたか?

解決

This is confirmed Bug. If GetPrintCapablitiesAsXml() is the first method to be called by an instance of PrintQueue, the returned XML is does not enumerate all the properties of the printer correctly.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top