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 <thestig@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/AUTHORS b/AUTHORS
index ee6fc93..6b7b167 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -33,6 +33,7 @@
 Miklos Vajna <vmiklos@vmiklos.hu>
 Nico Weber <thakis@chromium.org>
 Peter Kasting <pkasting@chromium.org>
+Ralf Sippl <ralf.sippl@gmail.com>
 Raymes Khoury <raymes@chromium.org>
 Reid Kleckner <rnk@chromium.org>
 Ryan Wiley <wileyrr@gmail.com>
diff --git a/core/fpdfdoc/cpvt_generateap.cpp b/core/fpdfdoc/cpvt_generateap.cpp
index a61a245..eb3e22d 100644
--- a/core/fpdfdoc/cpvt_generateap.cpp
+++ b/core/fpdfdoc/cpvt_generateap.cpp
@@ -470,14 +470,14 @@
     const ByteString& sBlendMode) {
   auto pGSDict =
       pdfium::MakeUnique<CPDF_Dictionary>(pAnnotDict.GetByteStringPool());
-  pGSDict->SetNewFor<CPDF_String>("Type", "ExtGState", false);
+  pGSDict->SetNewFor<CPDF_Name>("Type", "ExtGState");
 
   float fOpacity =
       pAnnotDict.KeyExist("CA") ? pAnnotDict.GetNumberFor("CA") : 1;
   pGSDict->SetNewFor<CPDF_Number>("CA", fOpacity);
   pGSDict->SetNewFor<CPDF_Number>("ca", fOpacity);
   pGSDict->SetNewFor<CPDF_Boolean>("AIS", false);
-  pGSDict->SetNewFor<CPDF_String>("BM", sBlendMode, false);
+  pGSDict->SetNewFor<CPDF_Name>("BM", sBlendMode);
 
   auto pExtGStateDict =
       pdfium::MakeUnique<CPDF_Dictionary>(pAnnotDict.GetByteStringPool());
@@ -514,7 +514,8 @@
 
   CPDF_Dictionary* pStreamDict = pNormalStream->GetDict();
   pStreamDict->SetNewFor<CPDF_Number>("FormType", 1);
-  pStreamDict->SetNewFor<CPDF_String>("Subtype", "Form", false);
+  pStreamDict->SetNewFor<CPDF_Name>("Type", "XObject");
+  pStreamDict->SetNewFor<CPDF_Name>("Subtype", "Form");
   pStreamDict->SetMatrixFor("Matrix", CFX_Matrix());
 
   CFX_FloatRect rect = bIsTextMarkupAnnotation