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(); }
void CPDF_StreamContentParser::AddForm(CPDF_Stream* pStream) { if (!m_Options.m_bSeparateForm) { CPDF_Dictionary* pResources = pStream->GetDict()->GetDict("Resources"); CFX_Matrix form_matrix = pStream->GetDict()->GetMatrix("Matrix"); form_matrix.Concat(m_pCurStates->m_CTM); CPDF_Array* pBBox = pStream->GetDict()->GetArray("BBox"); CFX_FloatRect form_bbox; CPDF_Path ClipPath; if (pBBox) { form_bbox = pStream->GetDict()->GetRect("BBox"); ClipPath.New(); ClipPath.AppendRect(form_bbox.left, form_bbox.bottom, form_bbox.right, form_bbox.top); ClipPath.Transform(&form_matrix); form_bbox.Transform(&form_matrix); } CPDF_StreamContentParser parser(m_pDocument, m_pPageResources, m_pResources, &m_mtContentToUser, m_pObjectList, pResources, &form_bbox, &m_Options, m_pCurStates.get(), m_Level + 1); parser.m_pCurStates->m_CTM = form_matrix; if (ClipPath.NotNull()) { parser.m_pCurStates->m_ClipPath.AppendPath(ClipPath, FXFILL_WINDING, TRUE); } CPDF_StreamAcc stream; stream.LoadAllData(pStream, FALSE); if (stream.GetSize() == 0) { return; } parser.Parse(stream.GetData(), stream.GetSize(), 0); return; } CPDF_FormObject* pFormObj = new CPDF_FormObject; pFormObj->m_pForm = new CPDF_Form(m_pDocument, m_pPageResources, pStream, m_pResources); pFormObj->m_FormMatrix = m_pCurStates->m_CTM; pFormObj->m_FormMatrix.Concat(m_mtContentToUser); CPDF_AllStates status; status.m_GeneralState = m_pCurStates->m_GeneralState; status.m_GraphState = m_pCurStates->m_GraphState; status.m_ColorState = m_pCurStates->m_ColorState; status.m_TextState = m_pCurStates->m_TextState; pFormObj->m_pForm->ParseContent(&status, NULL, NULL, &m_Options, m_Level + 1); if (!m_pObjectList->m_bBackgroundAlphaNeeded && pFormObj->m_pForm->m_bBackgroundAlphaNeeded) { m_pObjectList->m_bBackgroundAlphaNeeded = TRUE; } pFormObj->CalcBoundingBox(); SetGraphicStates(pFormObj, TRUE, TRUE, TRUE); m_pObjectList->m_ObjectList.AddTail(pFormObj); }
DLLEXPORT void STDCALL FPDFPage_InsertObject(FPDF_PAGE page, FPDF_PAGEOBJECT page_obj) { CPDF_PageObject* pPageObj = reinterpret_cast<CPDF_PageObject*>(page_obj); if (!pPageObj) return; std::unique_ptr<CPDF_PageObject> pPageObjHolder(pPageObj); CPDF_Page* pPage = CPDFPageFromFPDFPage(page); if (!IsPageObject(pPage)) return; pPage->GetPageObjectList()->push_back(std::move(pPageObjHolder)); switch (pPageObj->GetType()) { case CPDF_PageObject::TEXT: { break; } case CPDF_PageObject::PATH: { CPDF_PathObject* pPathObj = pPageObj->AsPath(); pPathObj->CalcBoundingBox(); break; } case CPDF_PageObject::IMAGE: { CPDF_ImageObject* pImageObj = pPageObj->AsImage(); pImageObj->CalcBoundingBox(); break; } case CPDF_PageObject::SHADING: { CPDF_ShadingObject* pShadingObj = pPageObj->AsShading(); pShadingObj->CalcBoundingBox(); break; } case CPDF_PageObject::FORM: { CPDF_FormObject* pFormObj = pPageObj->AsForm(); pFormObj->CalcBoundingBox(); break; } default: { ASSERT(false); break; } } }