本文整理汇总了C++中CPDF_Dictionary::RemoveFor方法的典型用法代码示例。如果您正苦于以下问题:C++ CPDF_Dictionary::RemoveFor方法的具体用法?C++ CPDF_Dictionary::RemoveFor怎么用?C++ CPDF_Dictionary::RemoveFor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CPDF_Dictionary
的用法示例。
在下文中一共展示了CPDF_Dictionary::RemoveFor方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UpdateReference
FX_BOOL CPDF_PageOrganizer::UpdateReference(CPDF_Object* pObj,
CPDF_Document* pDoc,
ObjectNumberMap* pObjNumberMap) {
switch (pObj->GetType()) {
case CPDF_Object::REFERENCE: {
CPDF_Reference* pReference = pObj->AsReference();
uint32_t newobjnum = GetNewObjId(pDoc, pObjNumberMap, pReference);
if (newobjnum == 0)
return FALSE;
pReference->SetRef(pDoc, newobjnum);
break;
}
case CPDF_Object::DICTIONARY: {
CPDF_Dictionary* pDict = pObj->AsDictionary();
auto it = pDict->begin();
while (it != pDict->end()) {
const CFX_ByteString& key = it->first;
CPDF_Object* pNextObj = it->second;
++it;
if (key == "Parent" || key == "Prev" || key == "First")
continue;
if (!pNextObj)
return FALSE;
if (!UpdateReference(pNextObj, pDoc, pObjNumberMap))
pDict->RemoveFor(key);
}
break;
}
case CPDF_Object::ARRAY: {
CPDF_Array* pArray = pObj->AsArray();
for (size_t i = 0; i < pArray->GetCount(); ++i) {
CPDF_Object* pNextObj = pArray->GetObjectAt(i);
if (!pNextObj)
return FALSE;
if (!UpdateReference(pNextObj, pDoc, pObjNumberMap))
return FALSE;
}
break;
}
case CPDF_Object::STREAM: {
CPDF_Stream* pStream = pObj->AsStream();
CPDF_Dictionary* pDict = pStream->GetDict();
if (pDict) {
if (!UpdateReference(pDict, pDoc, pObjNumberMap))
return FALSE;
} else {
return FALSE;
}
break;
}
default:
break;
}
return TRUE;
}
示例2: GenerateContent
void CPDF_PageContentGenerator::GenerateContent() {
CFX_ByteTextBuf buf;
CPDF_Dictionary* pPageDict = m_pPage->m_pFormDict;
for (int i = 0; i < m_pageObjects.GetSize(); ++i) {
CPDF_PageObject* pPageObj = m_pageObjects[i];
if (!pPageObj || !pPageObj->IsImage()) {
continue;
}
ProcessImage(buf, pPageObj->AsImage());
}
CPDF_Object* pContent =
pPageDict ? pPageDict->GetDirectObjectFor("Contents") : nullptr;
if (pContent)
pPageDict->RemoveFor("Contents");
CPDF_Stream* pStream = new CPDF_Stream;
pStream->SetData(buf.GetBuffer(), buf.GetLength());
pPageDict->SetReferenceFor("Contents", m_pDocument,
m_pDocument->AddIndirectObject(pStream));
}
示例3: if
//.........这里部分代码省略.........
for (int i = 0; i < nStreams; i++) {
CPDF_Dictionary* pAnnotDic = ObjectArray.GetAt(i);
if (!pAnnotDic)
continue;
CFX_FloatRect rcAnnot = pAnnotDic->GetRectFor("Rect");
rcAnnot.Normalize();
CFX_ByteString sAnnotState = pAnnotDic->GetStringFor("AS");
CPDF_Dictionary* pAnnotAP = pAnnotDic->GetDictFor("AP");
if (!pAnnotAP)
continue;
CPDF_Stream* pAPStream = pAnnotAP->GetStreamFor("N");
if (!pAPStream) {
CPDF_Dictionary* pAPDic = pAnnotAP->GetDictFor("N");
if (!pAPDic)
continue;
if (!sAnnotState.IsEmpty()) {
pAPStream = pAPDic->GetStreamFor(sAnnotState);
} else {
auto it = pAPDic->begin();
if (it != pAPDic->end()) {
CPDF_Object* pFirstObj = it->second;
if (pFirstObj) {
if (pFirstObj->IsReference())
pFirstObj = pFirstObj->GetDirect();
if (!pFirstObj->IsStream())
continue;
pAPStream = pFirstObj->AsStream();
}
}
}
}
if (!pAPStream)
continue;
CPDF_Dictionary* pAPDic = pAPStream->GetDict();
CFX_Matrix matrix = pAPDic->GetMatrixFor("Matrix");
CFX_FloatRect rcStream;
if (pAPDic->KeyExist("Rect"))
rcStream = pAPDic->GetRectFor("Rect");
else if (pAPDic->KeyExist("BBox"))
rcStream = pAPDic->GetRectFor("BBox");
if (rcStream.IsEmpty())
continue;
CPDF_Object* pObj = pAPStream;
if (pObj) {
CPDF_Dictionary* pObjDic = pObj->GetDict();
if (pObjDic) {
pObjDic->SetNameFor("Type", "XObject");
pObjDic->SetNameFor("Subtype", "Form");
}
}
CPDF_Dictionary* pXObject = pNewXORes->GetDictFor("XObject");
if (!pXObject) {
pXObject = new CPDF_Dictionary(pDocument->GetByteStringPool());
pNewXORes->SetFor("XObject", pXObject);
}
CFX_ByteString sFormName;
sFormName.Format("F%d", i);
pXObject->SetReferenceFor(sFormName, pDocument,
pDocument->AddIndirectObject(pObj));
CPDF_StreamAcc acc;
acc.LoadAllData(pNewXObject);
const uint8_t* pData = acc.GetData();
CFX_ByteString sStream(pData, acc.GetSize());
if (matrix.IsIdentity()) {
matrix.a = 1.0f;
matrix.b = 0.0f;
matrix.c = 0.0f;
matrix.d = 1.0f;
matrix.e = 0.0f;
matrix.f = 0.0f;
}
CFX_ByteString sTemp;
CFX_Matrix m = GetMatrix(rcAnnot, rcStream, matrix);
sTemp.Format("q %f 0 0 %f %f %f cm /%s Do Q\n", m.a, m.d, m.e, m.f,
sFormName.c_str());
sStream += sTemp;
pNewXObject->SetData(sStream.raw_str(), sStream.GetLength());
}
pPageDict->RemoveFor("Annots");
ObjectArray.RemoveAll();
RectArray.RemoveAll();
return FLATTEN_SUCCESS;
}
示例4: ExportPage
FX_BOOL CPDF_PageOrganizer::ExportPage(CPDF_Document* pSrcPDFDoc,
std::vector<uint16_t>* pPageNums,
CPDF_Document* pDestPDFDoc,
int nIndex) {
int curpage = nIndex;
std::unique_ptr<ObjectNumberMap> pObjNumberMap(new ObjectNumberMap);
int nSize = pdfium::CollectionSize<int>(*pPageNums);
for (int i = 0; i < nSize; ++i) {
CPDF_Dictionary* pCurPageDict = pDestPDFDoc->CreateNewPage(curpage);
CPDF_Dictionary* pSrcPageDict = pSrcPDFDoc->GetPage(pPageNums->at(i) - 1);
if (!pSrcPageDict || !pCurPageDict)
return FALSE;
// Clone the page dictionary
for (const auto& it : *pSrcPageDict) {
const CFX_ByteString& cbSrcKeyStr = it.first;
CPDF_Object* pObj = it.second;
if (cbSrcKeyStr.Compare(("Type")) && cbSrcKeyStr.Compare(("Parent"))) {
if (pCurPageDict->KeyExist(cbSrcKeyStr))
pCurPageDict->RemoveFor(cbSrcKeyStr);
pCurPageDict->SetFor(cbSrcKeyStr, pObj->Clone());
}
}
// inheritable item
CPDF_Object* pInheritable = nullptr;
// 1 MediaBox //required
if (!pCurPageDict->KeyExist("MediaBox")) {
pInheritable = PageDictGetInheritableTag(pSrcPageDict, "MediaBox");
if (!pInheritable) {
// Search the "CropBox" from source page dictionary,
// if not exists,we take the letter size.
pInheritable = PageDictGetInheritableTag(pSrcPageDict, "CropBox");
if (pInheritable) {
pCurPageDict->SetFor("MediaBox", pInheritable->Clone());
} else {
// Make the default size to be letter size (8.5'x11')
CPDF_Array* pArray = new CPDF_Array;
pArray->AddNumber(0);
pArray->AddNumber(0);
pArray->AddNumber(612);
pArray->AddNumber(792);
pCurPageDict->SetFor("MediaBox", pArray);
}
} else {
pCurPageDict->SetFor("MediaBox", pInheritable->Clone());
}
}
// 2 Resources //required
if (!pCurPageDict->KeyExist("Resources")) {
pInheritable = PageDictGetInheritableTag(pSrcPageDict, "Resources");
if (!pInheritable)
return FALSE;
pCurPageDict->SetFor("Resources", pInheritable->Clone());
}
// 3 CropBox //Optional
if (!pCurPageDict->KeyExist("CropBox")) {
pInheritable = PageDictGetInheritableTag(pSrcPageDict, "CropBox");
if (pInheritable)
pCurPageDict->SetFor("CropBox", pInheritable->Clone());
}
// 4 Rotate //Optional
if (!pCurPageDict->KeyExist("Rotate")) {
pInheritable = PageDictGetInheritableTag(pSrcPageDict, "Rotate");
if (pInheritable)
pCurPageDict->SetFor("Rotate", pInheritable->Clone());
}
// Update the reference
uint32_t dwOldPageObj = pSrcPageDict->GetObjNum();
uint32_t dwNewPageObj = pCurPageDict->GetObjNum();
(*pObjNumberMap)[dwOldPageObj] = dwNewPageObj;
UpdateReference(pCurPageDict, pDestPDFDoc, pObjNumberMap.get());
++curpage;
}
return TRUE;
}