From d5d8f606d98d9df959bf2fc308979471bddda8c1 Mon Sep 17 00:00:00 2001 From: rbpotter Date: Wed, 29 Mar 2017 16:10:45 -0700 Subject: Quick fix for blank preview BUG=chromium:701057 Change-Id: I601b9763b2fddec953f769ec012cd7920806265a Reviewed-on: https://pdfium-review.googlesource.com/3330 Commit-Queue: Lei Zhang Reviewed-by: Lei Zhang --- fpdfsdk/fpdfppo.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'fpdfsdk') diff --git a/fpdfsdk/fpdfppo.cpp b/fpdfsdk/fpdfppo.cpp index 4e06856455..e2ef406b05 100644 --- a/fpdfsdk/fpdfppo.cpp +++ b/fpdfsdk/fpdfppo.cpp @@ -210,16 +210,18 @@ bool CPDF_PageOrganizer::ExportPage(const std::vector& pageNums, } // inheritable item + // Even though some entries are required by the PDF spec, there exist + // PDFs that omit them. Set some defaults in this case. // 1 MediaBox - required if (!CopyInheritable(pCurPageDict, pSrcPageDict, "MediaBox")) { - // Search for "CropBox" in the source page dictionary, - // if it does not exists, use the default letter size. + // Search for "CropBox" in the source page dictionary. + // If it does not exist, use the default letter size. CPDF_Object* pInheritable = PageDictGetInheritableTag(pSrcPageDict, "CropBox"); if (pInheritable) { pCurPageDict->SetFor("MediaBox", pInheritable->Clone()); } else { - // Make the default size to be letter size (8.5'x11') + // Make the default size letter size (8.5"x11") CPDF_Array* pArray = pCurPageDict->SetNewFor("MediaBox"); pArray->AddNew(0); pArray->AddNew(0); @@ -229,8 +231,10 @@ bool CPDF_PageOrganizer::ExportPage(const std::vector& pageNums, } // 2 Resources - required - if (!CopyInheritable(pCurPageDict, pSrcPageDict, "Resources")) - return false; + if (!CopyInheritable(pCurPageDict, pSrcPageDict, "Resources")) { + // Use a default empty resources if it does not exist. + pCurPageDict->SetNewFor("Resources"); + } // 3 CropBox - optional CopyInheritable(pCurPageDict, pSrcPageDict, "CropBox"); -- cgit v1.2.3