Remove CJS_RuntimeFactory
[pdfium.git] / fpdfsdk / src / fpdfeditpage.cpp
index d9cbbe4..0219c9c 100644 (file)
-// Copyright 2014 PDFium Authors. All rights reserved.\r
-// Use of this source code is governed by a BSD-style license that can be\r
-// found in the LICENSE file.\r
\r
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com\r
-\r
-// #include "x:/pdf/fpdfapi5/include/fpdfapi.h"\r
-#include "../include/fsdk_define.h"\r
-#include "../include/fpdfedit.h"\r
-\r
-\r
-#if _FX_OS_ == _FX_ANDROID_\r
-#include "time.h"\r
-#else\r
-#include <ctime>\r
-#endif\r
-\r
-DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_CreateNewDocument()\r
-{\r
-       CPDF_Document* pDoc = FX_NEW CPDF_Document;\r
-       if (!pDoc)\r
-               return NULL;\r
-       pDoc->CreateNewDoc();\r
-       time_t currentTime;\r
-\r
-       CFX_ByteString DateStr;\r
-\r
-       if(FSDK_IsSandBoxPolicyEnabled(FPDF_POLICY_MACHINETIME_ACCESS))\r
-       {\r
-               if ( -1 != time( &currentTime ) )\r
-               {\r
-                       tm * pTM = localtime( &currentTime );\r
-                       if ( pTM )\r
-                       {\r
-                               DateStr.Format( "D:%04d%02d%02d%02d%02d%02d", pTM->tm_year+1900, pTM->tm_mon+1,\r
-                                       pTM->tm_mday, pTM->tm_hour, pTM->tm_min, pTM->tm_sec );\r
-                       }\r
-               }\r
-       }\r
-       \r
-       CPDF_Dictionary* pInfoDict = NULL;\r
-       pInfoDict = pDoc->GetInfo();\r
-       if (pInfoDict)\r
-       {\r
-               if(FSDK_IsSandBoxPolicyEnabled(FPDF_POLICY_MACHINETIME_ACCESS))\r
-                       pInfoDict->SetAt("CreationDate", new CPDF_String(DateStr));\r
-#ifdef FOXIT_CHROME_BUILD\r
-               pInfoDict->SetAt("Creator",FX_NEW CPDF_String(L"Google"));\r
-#else\r
-               pInfoDict->SetAt("Creator",FX_NEW CPDF_String(L"Foxit PDF SDK DLL 2.0 - Foxit Software"));\r
-#endif\r
-       }\r
-\r
-       return pDoc;\r
-}\r
-\r
-DLLEXPORT void STDCALL FPDFPage_Delete(FPDF_DOCUMENT document, int page_index)\r
-{\r
-       CPDF_Document* pDoc = (CPDF_Document*)document;\r
-       if (pDoc == NULL) \r
-               return;\r
-       if (page_index < 0 || page_index >= pDoc->GetPageCount()) \r
-               return;\r
-\r
-       pDoc->DeletePage(page_index);\r
-}\r
-\r
-DLLEXPORT FPDF_PAGE STDCALL FPDFPage_New(FPDF_DOCUMENT document, int page_index, double width, double height)\r
-{\r
-       if (!document)\r
-               return NULL;\r
-\r
-//     CPDF_Parser* pParser = (CPDF_Parser*)document;\r
-       CPDF_Document* pDoc = (CPDF_Document*)document;\r
-       if(page_index < 0)\r
-               page_index = 0;\r
-       if(pDoc->GetPageCount()<page_index)\r
-               page_index = pDoc->GetPageCount();\r
-//     if (page_index < 0 || page_index >= pDoc->GetPageCount()) \r
-//             return NULL;\r
-\r
-       CPDF_Dictionary* pPageDict = pDoc->CreateNewPage(page_index);\r
-       if(!pPageDict)\r
-               return NULL;\r
-       CPDF_Array* pMediaBoxArray = FX_NEW CPDF_Array;\r
-       pMediaBoxArray->Add(FX_NEW CPDF_Number(0));\r
-       pMediaBoxArray->Add(FX_NEW CPDF_Number(0));\r
-       pMediaBoxArray->Add(FX_NEW CPDF_Number(FX_FLOAT(width)));\r
-       pMediaBoxArray->Add(FX_NEW CPDF_Number(FX_FLOAT(height)));\r
-\r
-       pPageDict->SetAt("MediaBox", pMediaBoxArray);\r
-       pPageDict->SetAt("Rotate", FX_NEW CPDF_Number(0));\r
-       pPageDict->SetAt("Resources", FX_NEW CPDF_Dictionary);\r
-\r
-       CPDF_Page* pPage = FX_NEW CPDF_Page;\r
-       pPage->Load(pDoc,pPageDict);\r
-       pPage->ParseContent();\r
-\r
-       return pPage;\r
-}\r
-\r
-DLLEXPORT int STDCALL FPDFPage_GetRotation(FPDF_PAGE page)\r
-{\r
-       CPDF_Page* pPage = (CPDF_Page*)page;\r
-       if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type")\r
-               || pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare("Page"))\r
-       {\r
-               return -1;\r
-       }\r
-       CPDF_Dictionary* pDict = pPage->m_pFormDict;\r
-\r
-       int rotate = 0;\r
-       if(pDict != NULL)\r
-       {\r
-               if(pDict->KeyExist("Rotate"))\r
-                       rotate = pDict->GetElement("Rotate")->GetDirect()->GetInteger() / 90;\r
-               else\r
-               {\r
-                       if(pDict->KeyExist("Parent"))\r
-                       {\r
-                               CPDF_Dictionary* pPages = (CPDF_Dictionary*)pDict->GetElement("Parent")->GetDirect();\r
-                               while(pPages)\r
-                               {\r
-                                       if(pPages->KeyExist("Rotate"))\r
-                                       {\r
-                                               rotate = pPages->GetElement("Rotate")->GetDirect()->GetInteger() / 90;\r
-                                               break;\r
-                                       }\r
-                                       else if(pPages->KeyExist("Parent"))\r
-                                               pPages = (CPDF_Dictionary*)pPages->GetElement("Parent")->GetDirect();\r
-                                       else break;\r
-                               }\r
-                       }\r
-               }\r
-       }\r
-       else\r
-       {\r
-               return -1;\r
-       }\r
-       \r
-       return rotate;\r
-}\r
-\r
-DLLEXPORT void STDCALL FPDFPage_InsertObject(FPDF_PAGE page, FPDF_PAGEOBJECT page_obj)\r
-{\r
-       CPDF_Page* pPage = (CPDF_Page*)page;\r
-       if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type")\r
-               || pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare("Page"))\r
-       {\r
-               return;\r
-       }\r
-       CPDF_PageObject* pPageObj = (CPDF_PageObject*)page_obj;\r
-       if(pPageObj == NULL)\r
-               return;\r
-       FX_POSITION LastPersition = pPage->GetLastObjectPosition();\r
-\r
-       pPage->InsertObject(LastPersition, pPageObj);\r
-       switch(pPageObj->m_Type)\r
-       {\r
-       case FPDF_PAGEOBJ_PATH:\r
-               {\r
-                       CPDF_PathObject* pPathObj = (CPDF_PathObject*)pPageObj;\r
-                       pPathObj->CalcBoundingBox();\r
-                       break;\r
-               }\r
-       case FPDF_PAGEOBJ_TEXT:\r
-               {\r
-                       //      CPDF_PathObject* pPathObj = (CPDF_PathObject*)pPageObj;\r
-                       //      pPathObj->CalcBoundingBox();\r
-                       break;\r
-               }\r
-       case FPDF_PAGEOBJ_IMAGE:\r
-               {\r
-                       CPDF_ImageObject* pImageObj = (CPDF_ImageObject*)pPageObj;\r
-                       pImageObj->CalcBoundingBox();\r
-                       break;\r
-               }\r
-       case FPDF_PAGEOBJ_SHADING:\r
-               {\r
-                       CPDF_ShadingObject* pShadingObj = (CPDF_ShadingObject*)pPageObj;\r
-                       pShadingObj->CalcBoundingBox();\r
-                       break;\r
-               }\r
-       case FPDF_PAGEOBJ_FORM:\r
-               {\r
-                       CPDF_FormObject* pFormObj = (CPDF_FormObject*)pPageObj;\r
-                       pFormObj->CalcBoundingBox();\r
-                       break;\r
-               }\r
-       default:\r
-               break;\r
-       }\r
-\r
-       //      pPage->ParseContent();\r
-       //pPage->GenerateContent();\r
-\r
-}\r
-\r
-DLLEXPORT int STDCALL FPDFPage_CountObject(FPDF_PAGE page)\r
-{\r
-       CPDF_Page* pPage = (CPDF_Page*)page;\r
-       if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type")\r
-               || pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare("Page"))\r
-       {\r
-               return -1;\r
-       }\r
-       return pPage->CountObjects();\r
-//     return 0;\r
-}\r
-\r
-DLLEXPORT FPDF_PAGEOBJECT STDCALL FPDFPage_GetObject(FPDF_PAGE page, int index)\r
-{\r
-       CPDF_Page* pPage = (CPDF_Page*)page;\r
-       if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type")\r
-               || pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare("Page"))\r
-       {\r
-               return NULL;\r
-       }\r
-       return pPage->GetObjectByIndex(index);\r
-//     return NULL;\r
-}\r
-\r
-DLLEXPORT FPDF_BOOL STDCALL FPDFPage_HasTransparency(FPDF_PAGE page)\r
-{\r
-       if(!page) return FALSE;\r
-       CPDF_Page* pPage = (CPDF_Page*)page;\r
-\r
-       return pPage->BackgroundAlphaNeeded();\r
-}\r
-\r
-DLLEXPORT FPDF_BOOL STDCALL FPDFPageObj_HasTransparency(FPDF_PAGEOBJECT pageObject)\r
-{\r
-       if(!pageObject) return FALSE;\r
-       CPDF_PageObject* pPageObj = (CPDF_PageObject*)pageObject;\r
-\r
-       const CPDF_GeneralStateData* pGeneralState = pPageObj->m_GeneralState;\r
-       int blend_type = pGeneralState ? pGeneralState->m_BlendType : FXDIB_BLEND_NORMAL;\r
-       if (blend_type != FXDIB_BLEND_NORMAL) return TRUE;\r
-\r
-       CPDF_Dictionary* pSMaskDict = pGeneralState ? (CPDF_Dictionary*)pGeneralState->m_pSoftMask : NULL;\r
-       if(pSMaskDict) return TRUE;\r
-\r
-       if(pGeneralState && pGeneralState->m_FillAlpha != 1.0f)\r
-               return TRUE;\r
-\r
-       if(pPageObj->m_Type == PDFPAGE_PATH)\r
-       {\r
-               if(pGeneralState && pGeneralState->m_StrokeAlpha != 1.0f)\r
-                       return TRUE;\r
-       }\r
-\r
-       if(pPageObj->m_Type == PDFPAGE_FORM)\r
-       {\r
-               CPDF_FormObject* pFormObj = (CPDF_FormObject*)pPageObj;\r
-               if(pFormObj->m_pForm && (pFormObj->m_pForm->m_Transparency & PDFTRANS_ISOLATED))\r
-                       return TRUE;\r
-               if(pFormObj->m_pForm && (!(pFormObj->m_pForm->m_Transparency & PDFTRANS_ISOLATED) && (pFormObj->m_pForm->m_Transparency & PDFTRANS_GROUP)))\r
-                       return TRUE;\r
-       }\r
-       return FALSE;\r
-}\r
-\r
-DLLEXPORT FPDF_BOOL STDCALL FPDFPage_GenerateContent(FPDF_PAGE page)\r
-{\r
-       CPDF_Page* pPage = (CPDF_Page*)page;\r
-       if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type")\r
-               || pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare("Page"))\r
-       {\r
-               return FALSE;\r
-       }\r
-       CPDF_PageContentGenerate CG(pPage);\r
-       CG.GenerateContent();\r
-\r
-       return TRUE;\r
-}\r
-\r
-DLLEXPORT void STDCALL FPDFPageObj_Transform(FPDF_PAGEOBJECT page_object,\r
-                        double a, double b, double c, double d, double e, double f)  \r
-{\r
-       CPDF_PageObject* pPageObj = (CPDF_PageObject*)page_object;\r
-       if(pPageObj == NULL)\r
-               return;\r
-//PDF_ImageObject* pImageObj = FX_NEW CPDF_ImageObject;\r
-       CFX_AffineMatrix matrix((FX_FLOAT)a,(FX_FLOAT)b,(FX_FLOAT)c,(FX_FLOAT)d,(FX_FLOAT)e,(FX_FLOAT)f);\r
-       pPageObj->Transform(matrix);\r
-}\r
-DLLEXPORT void STDCALL FPDFPage_TransformAnnots(FPDF_PAGE page,\r
-                                                                                          double a, double b, double c, double d, double e, double f)\r
-{\r
-       if(page == NULL)\r
-               return;\r
-       CPDF_Page* pPage = (CPDF_Page*)page;\r
-       CPDF_AnnotList AnnotList(pPage);\r
-       for (int i=0; i<AnnotList.Count();i++)\r
-       {\r
-               CPDF_Annot* pAnnot = AnnotList.GetAt(i);\r
-               // transformAnnots Rectangle\r
-               CPDF_Rect rect;\r
-               pAnnot->GetRect(rect);\r
-               CFX_AffineMatrix matrix((FX_FLOAT)a,(FX_FLOAT)b,(FX_FLOAT)c,(FX_FLOAT)d,(FX_FLOAT)e,(FX_FLOAT)f);\r
-               rect.Transform(&matrix);\r
-               CPDF_Array *pRectArray = NULL;\r
-               pRectArray = pAnnot->m_pAnnotDict->GetArray("Rect");\r
-               if (!pRectArray) pRectArray=CPDF_Array::Create();\r
-               pRectArray->SetAt(0,FX_NEW CPDF_Number(rect.left));\r
-               pRectArray->SetAt(1,FX_NEW CPDF_Number(rect.bottom));\r
-               pRectArray->SetAt(2,FX_NEW CPDF_Number(rect.right));\r
-               pRectArray->SetAt(3,FX_NEW CPDF_Number(rect.top));\r
-               pAnnot->m_pAnnotDict->SetAt("Rect",pRectArray);\r
-\r
-               //Transform AP's rectangle\r
-               //To Do\r
-\r
-       }\r
-\r
-}\r
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "../../public/fpdf_edit.h"
+#include "../include/fsdk_define.h"
+
+#if _FX_OS_ == _FX_ANDROID_
+#include "time.h"
+#else
+#include <ctime>
+#endif
+
+DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_CreateNewDocument() {
+  CPDF_Document* pDoc = new CPDF_Document;
+  pDoc->CreateNewDoc();
+  time_t currentTime;
+
+  CFX_ByteString DateStr;
+
+  if (FSDK_IsSandBoxPolicyEnabled(FPDF_POLICY_MACHINETIME_ACCESS)) {
+    if (-1 != time(&currentTime)) {
+      tm* pTM = localtime(&currentTime);
+      if (pTM) {
+        DateStr.Format("D:%04d%02d%02d%02d%02d%02d", pTM->tm_year + 1900,
+                       pTM->tm_mon + 1, pTM->tm_mday, pTM->tm_hour, pTM->tm_min,
+                       pTM->tm_sec);
+      }
+    }
+  }
+
+  CPDF_Dictionary* pInfoDict = NULL;
+  pInfoDict = pDoc->GetInfo();
+  if (pInfoDict) {
+    if (FSDK_IsSandBoxPolicyEnabled(FPDF_POLICY_MACHINETIME_ACCESS))
+      pInfoDict->SetAt("CreationDate", new CPDF_String(DateStr));
+    pInfoDict->SetAt("Creator", new CPDF_String(L"PDFium"));
+  }
+
+  return pDoc;
+}
+
+DLLEXPORT void STDCALL FPDFPage_Delete(FPDF_DOCUMENT document, int page_index) {
+  CPDF_Document* pDoc = (CPDF_Document*)document;
+  if (pDoc == NULL)
+    return;
+  if (page_index < 0 || page_index >= pDoc->GetPageCount())
+    return;
+
+  pDoc->DeletePage(page_index);
+}
+
+DLLEXPORT FPDF_PAGE STDCALL FPDFPage_New(FPDF_DOCUMENT document,
+                                         int page_index,
+                                         double width,
+                                         double height) {
+  if (!document)
+    return NULL;
+
+  //   CPDF_Parser* pParser = (CPDF_Parser*)document;
+  CPDF_Document* pDoc = (CPDF_Document*)document;
+  if (page_index < 0)
+    page_index = 0;
+  if (pDoc->GetPageCount() < page_index)
+    page_index = pDoc->GetPageCount();
+  //   if (page_index < 0 || page_index >= pDoc->GetPageCount())
+  //           return NULL;
+
+  CPDF_Dictionary* pPageDict = pDoc->CreateNewPage(page_index);
+  if (!pPageDict)
+    return NULL;
+  CPDF_Array* pMediaBoxArray = new CPDF_Array;
+  pMediaBoxArray->Add(new CPDF_Number(0));
+  pMediaBoxArray->Add(new CPDF_Number(0));
+  pMediaBoxArray->Add(new CPDF_Number(FX_FLOAT(width)));
+  pMediaBoxArray->Add(new CPDF_Number(FX_FLOAT(height)));
+
+  pPageDict->SetAt("MediaBox", pMediaBoxArray);
+  pPageDict->SetAt("Rotate", new CPDF_Number(0));
+  pPageDict->SetAt("Resources", new CPDF_Dictionary);
+
+  CPDF_Page* pPage = new CPDF_Page;
+  pPage->Load(pDoc, pPageDict);
+  pPage->ParseContent();
+
+  return pPage;
+}
+
+DLLEXPORT int STDCALL FPDFPage_GetRotation(FPDF_PAGE page) {
+  CPDF_Page* pPage = (CPDF_Page*)page;
+  if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") ||
+      !pPage->m_pFormDict->GetElement("Type")->GetDirect() ||
+      pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare(
+          "Page")) {
+    return -1;
+  }
+  CPDF_Dictionary* pDict = pPage->m_pFormDict;
+
+  int rotate = 0;
+  if (pDict != NULL) {
+    if (pDict->KeyExist("Rotate"))
+      rotate = pDict->GetElement("Rotate")->GetDirect()
+                   ? pDict->GetElement("Rotate")->GetDirect()->GetInteger() / 90
+                   : 0;
+    else {
+      if (pDict->KeyExist("Parent")) {
+        CPDF_Dictionary* pPages =
+            (CPDF_Dictionary*)pDict->GetElement("Parent")->GetDirect();
+        while (pPages) {
+          if (pPages->KeyExist("Rotate")) {
+            rotate =
+                pPages->GetElement("Rotate")->GetDirect()
+                    ? pPages->GetElement("Rotate")->GetDirect()->GetInteger() /
+                          90
+                    : 0;
+            break;
+          } else if (pPages->KeyExist("Parent"))
+            pPages =
+                (CPDF_Dictionary*)pPages->GetElement("Parent")->GetDirect();
+          else
+            break;
+        }
+      }
+    }
+  } else {
+    return -1;
+  }
+
+  return rotate;
+}
+
+DLLEXPORT void STDCALL FPDFPage_InsertObject(FPDF_PAGE page,
+                                             FPDF_PAGEOBJECT page_obj) {
+  CPDF_Page* pPage = (CPDF_Page*)page;
+  if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") ||
+      !pPage->m_pFormDict->GetElement("Type")->GetDirect() ||
+      pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare(
+          "Page")) {
+    return;
+  }
+  CPDF_PageObject* pPageObj = (CPDF_PageObject*)page_obj;
+  if (pPageObj == NULL)
+    return;
+  FX_POSITION LastPersition = pPage->GetLastObjectPosition();
+
+  pPage->InsertObject(LastPersition, pPageObj);
+  switch (pPageObj->m_Type) {
+    case FPDF_PAGEOBJ_PATH: {
+      CPDF_PathObject* pPathObj = (CPDF_PathObject*)pPageObj;
+      pPathObj->CalcBoundingBox();
+      break;
+    }
+    case FPDF_PAGEOBJ_TEXT: {
+      //       CPDF_PathObject* pPathObj = (CPDF_PathObject*)pPageObj;
+      //       pPathObj->CalcBoundingBox();
+      break;
+    }
+    case FPDF_PAGEOBJ_IMAGE: {
+      CPDF_ImageObject* pImageObj = (CPDF_ImageObject*)pPageObj;
+      pImageObj->CalcBoundingBox();
+      break;
+    }
+    case FPDF_PAGEOBJ_SHADING: {
+      CPDF_ShadingObject* pShadingObj = (CPDF_ShadingObject*)pPageObj;
+      pShadingObj->CalcBoundingBox();
+      break;
+    }
+    case FPDF_PAGEOBJ_FORM: {
+      CPDF_FormObject* pFormObj = (CPDF_FormObject*)pPageObj;
+      pFormObj->CalcBoundingBox();
+      break;
+    }
+    default:
+      break;
+  }
+
+  //   pPage->ParseContent();
+  // pPage->GenerateContent();
+}
+
+DLLEXPORT int STDCALL FPDFPage_CountObject(FPDF_PAGE page) {
+  CPDF_Page* pPage = (CPDF_Page*)page;
+  if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") ||
+      !pPage->m_pFormDict->GetElement("Type")->GetDirect() ||
+      pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare(
+          "Page")) {
+    return -1;
+  }
+  return pPage->CountObjects();
+  //   return 0;
+}
+
+DLLEXPORT FPDF_PAGEOBJECT STDCALL FPDFPage_GetObject(FPDF_PAGE page,
+                                                     int index) {
+  CPDF_Page* pPage = (CPDF_Page*)page;
+  if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") ||
+      pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare(
+          "Page")) {
+    return NULL;
+  }
+  return pPage->GetObjectByIndex(index);
+  //   return NULL;
+}
+
+DLLEXPORT FPDF_BOOL STDCALL FPDFPage_HasTransparency(FPDF_PAGE page) {
+  if (!page)
+    return FALSE;
+  CPDF_Page* pPage = (CPDF_Page*)page;
+
+  return pPage->BackgroundAlphaNeeded();
+}
+
+DLLEXPORT FPDF_BOOL STDCALL
+FPDFPageObj_HasTransparency(FPDF_PAGEOBJECT pageObject) {
+  if (!pageObject)
+    return FALSE;
+  CPDF_PageObject* pPageObj = (CPDF_PageObject*)pageObject;
+
+  const CPDF_GeneralStateData* pGeneralState = pPageObj->m_GeneralState;
+  int blend_type =
+      pGeneralState ? pGeneralState->m_BlendType : FXDIB_BLEND_NORMAL;
+  if (blend_type != FXDIB_BLEND_NORMAL)
+    return TRUE;
+
+  CPDF_Dictionary* pSMaskDict =
+      pGeneralState ? (CPDF_Dictionary*)pGeneralState->m_pSoftMask : NULL;
+  if (pSMaskDict)
+    return TRUE;
+
+  if (pGeneralState && pGeneralState->m_FillAlpha != 1.0f)
+    return TRUE;
+
+  if (pPageObj->m_Type == PDFPAGE_PATH) {
+    if (pGeneralState && pGeneralState->m_StrokeAlpha != 1.0f)
+      return TRUE;
+  }
+
+  if (pPageObj->m_Type == PDFPAGE_FORM) {
+    CPDF_FormObject* pFormObj = (CPDF_FormObject*)pPageObj;
+    if (pFormObj->m_pForm &&
+        (pFormObj->m_pForm->m_Transparency & PDFTRANS_ISOLATED))
+      return TRUE;
+    if (pFormObj->m_pForm &&
+        (!(pFormObj->m_pForm->m_Transparency & PDFTRANS_ISOLATED) &&
+         (pFormObj->m_pForm->m_Transparency & PDFTRANS_GROUP)))
+      return TRUE;
+  }
+  return FALSE;
+}
+
+DLLEXPORT FPDF_BOOL STDCALL FPDFPage_GenerateContent(FPDF_PAGE page) {
+  CPDF_Page* pPage = (CPDF_Page*)page;
+  if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") ||
+      !pPage->m_pFormDict->GetElement("Type")->GetDirect() ||
+      pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare(
+          "Page")) {
+    return FALSE;
+  }
+  CPDF_PageContentGenerate CG(pPage);
+  CG.GenerateContent();
+
+  return TRUE;
+}
+
+DLLEXPORT void STDCALL FPDFPageObj_Transform(FPDF_PAGEOBJECT page_object,
+                                             double a,
+                                             double b,
+                                             double c,
+                                             double d,
+                                             double e,
+                                             double f) {
+  CPDF_PageObject* pPageObj = (CPDF_PageObject*)page_object;
+  if (pPageObj == NULL)
+    return;
+  CFX_AffineMatrix matrix((FX_FLOAT)a, (FX_FLOAT)b, (FX_FLOAT)c, (FX_FLOAT)d,
+                          (FX_FLOAT)e, (FX_FLOAT)f);
+  pPageObj->Transform(matrix);
+}
+DLLEXPORT void STDCALL FPDFPage_TransformAnnots(FPDF_PAGE page,
+                                                double a,
+                                                double b,
+                                                double c,
+                                                double d,
+                                                double e,
+                                                double f) {
+  if (page == NULL)
+    return;
+  CPDF_Page* pPage = (CPDF_Page*)page;
+  CPDF_AnnotList AnnotList(pPage);
+  for (int i = 0; i < AnnotList.Count(); i++) {
+    CPDF_Annot* pAnnot = AnnotList.GetAt(i);
+    // transformAnnots Rectangle
+    CPDF_Rect rect;
+    pAnnot->GetRect(rect);
+    CFX_AffineMatrix matrix((FX_FLOAT)a, (FX_FLOAT)b, (FX_FLOAT)c, (FX_FLOAT)d,
+                            (FX_FLOAT)e, (FX_FLOAT)f);
+    rect.Transform(&matrix);
+    CPDF_Array* pRectArray = NULL;
+    pRectArray = pAnnot->GetAnnotDict()->GetArray("Rect");
+    if (!pRectArray)
+      pRectArray = CPDF_Array::Create();
+    pRectArray->SetAt(0, new CPDF_Number(rect.left));
+    pRectArray->SetAt(1, new CPDF_Number(rect.bottom));
+    pRectArray->SetAt(2, new CPDF_Number(rect.right));
+    pRectArray->SetAt(3, new CPDF_Number(rect.top));
+    pAnnot->GetAnnotDict()->SetAt("Rect", pRectArray);
+
+    // Transform AP's rectangle
+    // To Do
+  }
+}
+
+DLLEXPORT void STDCALL FPDFPage_SetRotation(FPDF_PAGE page, int rotate) {
+  CPDF_Page* pPage = (CPDF_Page*)page;
+  if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") ||
+      !pPage->m_pFormDict->GetElement("Type")->GetDirect() ||
+      pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare(
+          "Page")) {
+    return;
+  }
+  CPDF_Dictionary* pDict = pPage->m_pFormDict;
+  rotate %= 4;
+
+  pDict->SetAt("Rotate", new CPDF_Number(rotate * 90));
+}