Index: chrome/browser/printing/pdf_to_emf_converter.cc |
diff --git a/chrome/browser/printing/pdf_to_emf_converter.cc b/chrome/browser/printing/pdf_to_emf_converter.cc |
index f5066dc429f9543446f777ba40154f476c7c4ada..3aeefb11be168a2bf377356d5fefb0c223d54844 100644 |
--- a/chrome/browser/printing/pdf_to_emf_converter.cc |
+++ b/chrome/browser/printing/pdf_to_emf_converter.cc |
@@ -364,6 +364,14 @@ bool PostScriptMetaFile::SafePlayback(HDC hdc) const { |
{ |
// Ensure enumerator destruction before calling Close() below. |
Emf::Enumerator emf_enum(emf, nullptr, nullptr); |
+ |
+ // Check if postscript passthrough is supported. Use normal passthrough if |
+ // it is not. |
+ DWORD escape = POSTSCRIPT_PASSTHROUGH; |
+ const char* ptr = reinterpret_cast<const char*>(&escape); |
+ bool postscript_passthrough = |
Lei Zhang
2017/02/25 03:03:35
int passthrough = ExtEscape(hdc, QUERYESCSUPPORT,
|
+ ExtEscape(hdc, QUERYESCSUPPORT, sizeof(escape), ptr, 0, nullptr) > 0; |
+ |
for (const Emf::Record& record : emf_enum) { |
auto* emf_record = record.record(); |
if (emf_record->iType != EMR_GDICOMMENT) |
@@ -373,8 +381,13 @@ bool PostScriptMetaFile::SafePlayback(HDC hdc) const { |
reinterpret_cast<const EMRGDICOMMENT*>(emf_record); |
const char* data = reinterpret_cast<const char*>(comment->Data); |
const uint16_t* ptr = reinterpret_cast<const uint16_t*>(data); |
- int ret = |
- ExtEscape(hdc, POSTSCRIPT_PASSTHROUGH, 2 + *ptr, data, 0, nullptr); |
+ int ret = 0; |
+ if (postscript_passthrough) { |
+ ret = |
+ ExtEscape(hdc, POSTSCRIPT_PASSTHROUGH, 2 + *ptr, data, 0, nullptr); |
+ } else { |
+ ret = ExtEscape(hdc, PASSTHROUGH, 2 + *ptr, data, 0, nullptr); |
+ } |
DCHECK_EQ(*ptr, ret); |
} |
} |