diff options
author | rbpotter <rbpotter@chromium.org> | 2017-03-29 16:10:45 -0700 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-03-29 23:50:58 +0000 |
commit | d5d8f606d98d9df959bf2fc308979471bddda8c1 (patch) | |
tree | 85ac1c2a93a50b03fbf31a0b20276481178acbee /fpdfsdk | |
parent | cbb02c07924757794f611235ea16bee6717918c4 (diff) | |
download | pdfium-d5d8f606d98d9df959bf2fc308979471bddda8c1.tar.xz |
Quick fix for blank preview
BUG=chromium:701057
Change-Id: I601b9763b2fddec953f769ec012cd7920806265a
Reviewed-on: https://pdfium-review.googlesource.com/3330
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'fpdfsdk')
-rw-r--r-- | fpdfsdk/fpdfppo.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
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<uint16_t>& 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<CPDF_Array>("MediaBox"); pArray->AddNew<CPDF_Number>(0); pArray->AddNew<CPDF_Number>(0); @@ -229,8 +231,10 @@ bool CPDF_PageOrganizer::ExportPage(const std::vector<uint16_t>& 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<CPDF_Dictionary>("Resources"); + } // 3 CropBox - optional CopyInheritable(pCurPageDict, pSrcPageDict, "CropBox"); |