本文整理汇总了C++中CPDF_Document::GetByteStringPool方法的典型用法代码示例。如果您正苦于以下问题:C++ CPDF_Document::GetByteStringPool方法的具体用法?C++ CPDF_Document::GetByteStringPool怎么用?C++ CPDF_Document::GetByteStringPool使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CPDF_Document
的用法示例。
在下文中一共展示了CPDF_Document::GetByteStringPool方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CPDFPageFromFPDFPage
DLLEXPORT void STDCALL FPDFPage_InsertClipPath(FPDF_PAGE page,
FPDF_CLIPPATH clipPath) {
CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
if (!pPage)
return;
CPDF_Dictionary* pPageDic = pPage->m_pFormDict;
CPDF_Object* pContentObj =
pPageDic ? pPageDic->GetObjectFor("Contents") : nullptr;
if (!pContentObj)
pContentObj = pPageDic ? pPageDic->GetArrayFor("Contents") : nullptr;
if (!pContentObj)
return;
CFX_ByteTextBuf strClip;
CPDF_ClipPath* pClipPath = (CPDF_ClipPath*)clipPath;
uint32_t i;
for (i = 0; i < pClipPath->GetPathCount(); i++) {
CPDF_Path path = pClipPath->GetPath(i);
int iClipType = pClipPath->GetClipType(i);
if (path.GetPoints().empty()) {
// Empty clipping (totally clipped out)
strClip << "0 0 m W n ";
} else {
OutputPath(strClip, path);
if (iClipType == FXFILL_WINDING)
strClip << "W n\n";
else
strClip << "W* n\n";
}
}
CPDF_Document* pDoc = pPage->m_pDocument;
if (!pDoc)
return;
CPDF_Stream* pStream = pDoc->NewIndirect<CPDF_Stream>(
nullptr, 0,
pdfium::MakeUnique<CPDF_Dictionary>(pDoc->GetByteStringPool()));
pStream->SetData(strClip.GetBuffer(), strClip.GetSize());
CPDF_Array* pArray = ToArray(pContentObj);
if (pArray) {
pArray->InsertNewAt<CPDF_Reference>(0, pDoc, pStream->GetObjNum());
return;
}
CPDF_Reference* pReference = ToReference(pContentObj);
if (!pReference)
return;
CPDF_Object* pDirectObj = pReference->GetDirect();
if (!pDirectObj)
return;
CPDF_Array* pObjArray = pDirectObj->AsArray();
if (pObjArray) {
pObjArray->InsertNewAt<CPDF_Reference>(0, pDoc, pStream->GetObjNum());
return;
}
if (pDirectObj->IsStream()) {
CPDF_Array* pContentArray = pDoc->NewIndirect<CPDF_Array>();
pContentArray->AddNew<CPDF_Reference>(pDoc, pStream->GetObjNum());
pContentArray->AddNew<CPDF_Reference>(pDoc, pDirectObj->GetObjNum());
pPageDic->SetNewFor<CPDF_Reference>("Contents", pDoc,
pContentArray->GetObjNum());
}
}
示例2: rect
DLLEXPORT FPDF_BOOL STDCALL FPDFPage_TransFormWithClip(FPDF_PAGE page,
FS_MATRIX* matrix,
FS_RECTF* clipRect) {
CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
if (!pPage)
return false;
CFX_ByteTextBuf textBuf;
textBuf << "q ";
CFX_FloatRect rect(clipRect->left, clipRect->bottom, clipRect->right,
clipRect->top);
rect.Normalize();
CFX_ByteString bsClipping;
bsClipping.Format("%f %f %f %f re W* n ", rect.left, rect.bottom,
rect.Width(), rect.Height());
textBuf << bsClipping;
CFX_ByteString bsMatix;
bsMatix.Format("%f %f %f %f %f %f cm ", matrix->a, matrix->b, matrix->c,
matrix->d, matrix->e, matrix->f);
textBuf << bsMatix;
CPDF_Dictionary* pPageDic = pPage->m_pFormDict;
CPDF_Object* pContentObj =
pPageDic ? pPageDic->GetObjectFor("Contents") : nullptr;
if (!pContentObj)
pContentObj = pPageDic ? pPageDic->GetArrayFor("Contents") : nullptr;
if (!pContentObj)
return false;
CPDF_Document* pDoc = pPage->m_pDocument;
if (!pDoc)
return false;
CPDF_Stream* pStream = pDoc->NewIndirect<CPDF_Stream>(
nullptr, 0,
pdfium::MakeUnique<CPDF_Dictionary>(pDoc->GetByteStringPool()));
pStream->SetData(textBuf.GetBuffer(), textBuf.GetSize());
CPDF_Stream* pEndStream = pDoc->NewIndirect<CPDF_Stream>(
nullptr, 0,
pdfium::MakeUnique<CPDF_Dictionary>(pDoc->GetByteStringPool()));
pEndStream->SetData((const uint8_t*)" Q", 2);
CPDF_Array* pContentArray = nullptr;
CPDF_Array* pArray = ToArray(pContentObj);
if (pArray) {
pContentArray = pArray;
pContentArray->InsertNewAt<CPDF_Reference>(0, pDoc, pStream->GetObjNum());
pContentArray->AddNew<CPDF_Reference>(pDoc, pEndStream->GetObjNum());
} else if (CPDF_Reference* pReference = ToReference(pContentObj)) {
CPDF_Object* pDirectObj = pReference->GetDirect();
if (pDirectObj) {
CPDF_Array* pObjArray = pDirectObj->AsArray();
if (pObjArray) {
pContentArray = pObjArray;
pContentArray->InsertNewAt<CPDF_Reference>(0, pDoc,
pStream->GetObjNum());
pContentArray->AddNew<CPDF_Reference>(pDoc, pEndStream->GetObjNum());
} else if (pDirectObj->IsStream()) {
pContentArray = pDoc->NewIndirect<CPDF_Array>();
pContentArray->AddNew<CPDF_Reference>(pDoc, pStream->GetObjNum());
pContentArray->AddNew<CPDF_Reference>(pDoc, pDirectObj->GetObjNum());
pContentArray->AddNew<CPDF_Reference>(pDoc, pEndStream->GetObjNum());
pPageDic->SetNewFor<CPDF_Reference>("Contents", pDoc,
pContentArray->GetObjNum());
}
}
}
// Need to transform the patterns as well.
CPDF_Dictionary* pRes = pPageDic->GetDictFor("Resources");
if (pRes) {
CPDF_Dictionary* pPattenDict = pRes->GetDictFor("Pattern");
if (pPattenDict) {
for (const auto& it : *pPattenDict) {
CPDF_Object* pObj = it.second.get();
if (pObj->IsReference())
pObj = pObj->GetDirect();
CPDF_Dictionary* pDict = nullptr;
if (pObj->IsDictionary())
pDict = pObj->AsDictionary();
else if (CPDF_Stream* pObjStream = pObj->AsStream())
pDict = pObjStream->GetDict();
else
continue;
CFX_Matrix m = pDict->GetMatrixFor("Matrix");
CFX_Matrix t = *(CFX_Matrix*)matrix;
m.Concat(t);
pDict->SetMatrixFor("Matrix", m);
}
}
}
return true;
}
示例3: if
DLLEXPORT int STDCALL FPDFPage_Flatten(FPDF_PAGE page, int nFlag) {
CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
if (!page) {
return FLATTEN_FAIL;
}
CPDF_Document* pDocument = pPage->m_pDocument;
CPDF_Dictionary* pPageDict = pPage->m_pFormDict;
if (!pDocument || !pPageDict) {
return FLATTEN_FAIL;
}
CPDF_ObjectArray ObjectArray;
CPDF_RectArray RectArray;
int iRet = FLATTEN_FAIL;
iRet = ParserAnnots(pDocument, pPageDict, &RectArray, &ObjectArray, nFlag);
if (iRet == FLATTEN_NOTHINGTODO || iRet == FLATTEN_FAIL)
return iRet;
CFX_FloatRect rcOriginalCB;
CFX_FloatRect rcMerger = CalculateRect(&RectArray);
CFX_FloatRect rcOriginalMB = pPageDict->GetRectFor("MediaBox");
if (pPageDict->KeyExist("CropBox"))
rcOriginalMB = pPageDict->GetRectFor("CropBox");
if (rcOriginalMB.IsEmpty()) {
rcOriginalMB = CFX_FloatRect(0.0f, 0.0f, 612.0f, 792.0f);
}
rcMerger.left =
rcMerger.left < rcOriginalMB.left ? rcOriginalMB.left : rcMerger.left;
rcMerger.right =
rcMerger.right > rcOriginalMB.right ? rcOriginalMB.right : rcMerger.right;
rcMerger.top =
rcMerger.top > rcOriginalMB.top ? rcOriginalMB.top : rcMerger.top;
rcMerger.bottom = rcMerger.bottom < rcOriginalMB.bottom ? rcOriginalMB.bottom
: rcMerger.bottom;
if (pPageDict->KeyExist("ArtBox"))
rcOriginalCB = pPageDict->GetRectFor("ArtBox");
else
rcOriginalCB = rcOriginalMB;
if (!rcOriginalMB.IsEmpty()) {
CPDF_Array* pMediaBox = new CPDF_Array();
pMediaBox->Add(new CPDF_Number(rcOriginalMB.left));
pMediaBox->Add(new CPDF_Number(rcOriginalMB.bottom));
pMediaBox->Add(new CPDF_Number(rcOriginalMB.right));
pMediaBox->Add(new CPDF_Number(rcOriginalMB.top));
pPageDict->SetFor("MediaBox", pMediaBox);
}
if (!rcOriginalCB.IsEmpty()) {
CPDF_Array* pCropBox = new CPDF_Array();
pCropBox->Add(new CPDF_Number(rcOriginalCB.left));
pCropBox->Add(new CPDF_Number(rcOriginalCB.bottom));
pCropBox->Add(new CPDF_Number(rcOriginalCB.right));
pCropBox->Add(new CPDF_Number(rcOriginalCB.top));
pPageDict->SetFor("ArtBox", pCropBox);
}
CPDF_Dictionary* pRes = pPageDict->GetDictFor("Resources");
if (!pRes) {
pRes = new CPDF_Dictionary(pDocument->GetByteStringPool());
pPageDict->SetFor("Resources", pRes);
}
CPDF_Stream* pNewXObject = new CPDF_Stream(
nullptr, 0, new CPDF_Dictionary(pDocument->GetByteStringPool()));
uint32_t dwObjNum = pDocument->AddIndirectObject(pNewXObject);
CPDF_Dictionary* pPageXObject = pRes->GetDictFor("XObject");
if (!pPageXObject) {
pPageXObject = new CPDF_Dictionary(pDocument->GetByteStringPool());
pRes->SetFor("XObject", pPageXObject);
}
CFX_ByteString key = "";
int nStreams = ObjectArray.GetSize();
if (nStreams > 0) {
for (int iKey = 0; /*iKey < 100*/; iKey++) {
char sExtend[5] = {};
FXSYS_itoa(iKey, sExtend, 10);
key = CFX_ByteString("FFT") + CFX_ByteString(sExtend);
if (!pPageXObject->KeyExist(key))
break;
}
}
SetPageContents(key, pPageDict, pDocument);
CPDF_Dictionary* pNewXORes = nullptr;
if (!key.IsEmpty()) {
pPageXObject->SetReferenceFor(key, pDocument, dwObjNum);
CPDF_Dictionary* pNewOXbjectDic = pNewXObject->GetDict();
//.........这里部分代码省略.........