From 2c3cfa734d034a0f0c78e658e98ed1113eba29a8 Mon Sep 17 00:00:00 2001 From: Ralf Sippl Date: Wed, 14 Mar 2018 15:18:55 +0000 Subject: Fix blend mode in generated AP When adding an annotation, an appearance stream (AP) is generated. According to the PDF spec, the Subtype, Type and BM entries it contains should be names rather than strings. Type should be set to XObject. BUG=pdfium:1038 Change-Id: I0131eec33c257ab3a3a48c7e0dfeac5ca8dfbe2b Reviewed-on: https://pdfium-review.googlesource.com/28550 Commit-Queue: Lei Zhang Reviewed-by: Lei Zhang --- AUTHORS | 1 + core/fpdfdoc/cpvt_generateap.cpp | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/AUTHORS b/AUTHORS index ee6fc932c1..6b7b167576 100644 --- a/AUTHORS +++ b/AUTHORS @@ -33,6 +33,7 @@ Michael Doppler Miklos Vajna Nico Weber Peter Kasting +Ralf Sippl Raymes Khoury Reid Kleckner Ryan Wiley diff --git a/core/fpdfdoc/cpvt_generateap.cpp b/core/fpdfdoc/cpvt_generateap.cpp index a61a2451af..eb3e22d870 100644 --- a/core/fpdfdoc/cpvt_generateap.cpp +++ b/core/fpdfdoc/cpvt_generateap.cpp @@ -470,14 +470,14 @@ std::unique_ptr GenerateExtGStateDict( const ByteString& sBlendMode) { auto pGSDict = pdfium::MakeUnique(pAnnotDict.GetByteStringPool()); - pGSDict->SetNewFor("Type", "ExtGState", false); + pGSDict->SetNewFor("Type", "ExtGState"); float fOpacity = pAnnotDict.KeyExist("CA") ? pAnnotDict.GetNumberFor("CA") : 1; pGSDict->SetNewFor("CA", fOpacity); pGSDict->SetNewFor("ca", fOpacity); pGSDict->SetNewFor("AIS", false); - pGSDict->SetNewFor("BM", sBlendMode, false); + pGSDict->SetNewFor("BM", sBlendMode); auto pExtGStateDict = pdfium::MakeUnique(pAnnotDict.GetByteStringPool()); @@ -514,7 +514,8 @@ void GenerateAndSetAPDict(CPDF_Document* pDoc, CPDF_Dictionary* pStreamDict = pNormalStream->GetDict(); pStreamDict->SetNewFor("FormType", 1); - pStreamDict->SetNewFor("Subtype", "Form", false); + pStreamDict->SetNewFor("Type", "XObject"); + pStreamDict->SetNewFor("Subtype", "Form"); pStreamDict->SetMatrixFor("Matrix", CFX_Matrix()); CFX_FloatRect rect = bIsTextMarkupAnnotation -- cgit v1.2.3