Chromium Code Reviews| Index: printing/print_settings_initializer_win.cc |
| diff --git a/printing/print_settings_initializer_win.cc b/printing/print_settings_initializer_win.cc |
| index 6d3ee33aaee69fe6d9cf0a54c96bf137b773790c..95d2fced08b5ff262a5d92de0105878ffee9e397 100644 |
| --- a/printing/print_settings_initializer_win.cc |
| +++ b/printing/print_settings_initializer_win.cc |
| @@ -21,6 +21,17 @@ bool IsTechnology(HDC hdc, const char* technology) { |
| if (::GetDeviceCaps(hdc, TECHNOLOGY) != DT_RASPRINTER) |
| return false; |
| + // If postscript, try to query Postscript Identify and then set to |
| + // postscript mode before calling any more ExtEscape functions. Otherwise, |
| + // PSLEVEL query will not work. |
| + if (strcmp(technology, "PostScript") == 0 && |
|
Lei Zhang
2017/02/25 02:49:50
Doing this within IsTechnology() seems weird, but
|
| + HasEscapeSupprt(hdc, POSTSCRIPT_IDENTIFY)) { |
| + DWORD mode = PSIDENT_PSCENTRIC; |
| + const char* ptr = reinterpret_cast<const char*>(&mode); |
| + ExtEscape(hdc, POSTSCRIPT_IDENTIFY, sizeof(DWORD), ptr, 0, nullptr); |
| + return true; |
| + } |
| + |
| if (!HasEscapeSupprt(hdc, GETTECHNOLOGY)) |
| return false; |
| @@ -37,7 +48,7 @@ bool IsPrinterPostScript(HDC hdc, int* level) { |
| return false; |
| } |
| - // Query the PS Level if possible. Many PS printers do not implement this. |
|
Lei Zhang
2017/02/25 02:49:50
Are there printers that only support this in PS mo
|
| + // Query the PS Level if possible. |
| if (HasEscapeSupprt(hdc, GET_PS_FEATURESETTING)) { |
| constexpr int param = FEATURESETTING_PSLEVEL; |
| const char* param_char_ptr = reinterpret_cast<const char*>(¶m); |
| @@ -116,10 +127,8 @@ void PrintSettingsInitializerWin::InitPrintSettings( |
| print_settings->SetPrinterPrintableArea(physical_size_device_units, |
| printable_area_device_units, |
| false); |
| - if (IsPrinterXPS(hdc)) { |
| - print_settings->set_printer_type(PrintSettings::PrinterType::TYPE_XPS); |
| - return; |
| - } |
| + // Check for postscript first so that we can change the mode with the |
| + // first command. |
| int level; |
| if (IsPrinterPostScript(hdc, &level)) { |
| if (level == 2) { |
| @@ -132,6 +141,10 @@ void PrintSettingsInitializerWin::InitPrintSettings( |
| PrintSettings::PrinterType::TYPE_POSTSCRIPT_LEVEL3); |
| return; |
| } |
| + if (IsPrinterXPS(hdc)) { |
| + print_settings->set_printer_type(PrintSettings::PrinterType::TYPE_XPS); |
| + return; |
| + } |
| print_settings->set_printer_type(PrintSettings::PrinterType::TYPE_NONE); |
| } |