本文整理汇总了C++中CPDF_Stream::GetDict方法的典型用法代码示例。如果您正苦于以下问题:C++ CPDF_Stream::GetDict方法的具体用法?C++ CPDF_Stream::GetDict怎么用?C++ CPDF_Stream::GetDict使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CPDF_Stream
的用法示例。
在下文中一共展示了CPDF_Stream::GetDict方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawControl
void CPDF_FormControl::DrawControl(CFX_RenderDevice* pDevice,
CFX_AffineMatrix* pMatrix,
CPDF_Page* pPage,
CPDF_Annot::AppearanceMode mode,
const CPDF_RenderOptions* pOptions) {
if (m_pWidgetDict->GetInteger("F") & ANNOTFLAG_HIDDEN) {
return;
}
CPDF_Stream* pStream = FPDFDOC_GetAnnotAP(m_pWidgetDict, mode);
if (pStream == NULL) {
return;
}
CFX_FloatRect form_bbox = pStream->GetDict()->GetRect("BBox");
CFX_AffineMatrix form_matrix = pStream->GetDict()->GetMatrix("Matrix");
form_matrix.TransformRect(form_bbox);
CFX_FloatRect arect = m_pWidgetDict->GetRect("Rect");
CFX_AffineMatrix matrix;
matrix.MatchRect(arect, form_bbox);
matrix.Concat(*pMatrix);
CPDF_Form form(m_pField->m_pForm->m_pDocument,
m_pField->m_pForm->m_pFormDict->GetDict("DR"), pStream);
form.ParseContent(NULL, NULL, NULL, NULL);
CPDF_RenderContext context;
context.Create(pPage);
context.DrawObjectList(pDevice, &form, &matrix, pOptions);
}
示例2: DrawControl
void CPDF_FormControl::DrawControl(CFX_RenderDevice* pDevice,
CFX_Matrix* pMatrix,
CPDF_Page* pPage,
CPDF_Annot::AppearanceMode mode,
const CPDF_RenderOptions* pOptions) {
if (m_pWidgetDict->GetIntegerBy("F") & ANNOTFLAG_HIDDEN)
return;
CPDF_Stream* pStream = FPDFDOC_GetAnnotAP(m_pWidgetDict, mode);
if (!pStream)
return;
CFX_FloatRect form_bbox = pStream->GetDict()->GetRectBy("BBox");
CFX_Matrix form_matrix = pStream->GetDict()->GetMatrixBy("Matrix");
form_matrix.TransformRect(form_bbox);
CFX_FloatRect arect = m_pWidgetDict->GetRectBy("Rect");
CFX_Matrix matrix;
matrix.MatchRect(arect, form_bbox);
matrix.Concat(*pMatrix);
CPDF_Form form(m_pField->m_pForm->m_pDocument,
m_pField->m_pForm->m_pFormDict->GetDictBy("DR"), pStream);
form.ParseContent(nullptr, nullptr, nullptr);
CPDF_RenderContext context(pPage);
context.AppendLayer(&form, &matrix);
context.Render(pDevice, pOptions, nullptr);
}
示例3: Handle_ExecuteXObject
void CPDF_StreamContentParser::Handle_ExecuteXObject() {
CFX_ByteString name = GetString(0);
if (name == m_LastImageName && m_pLastImage && m_pLastImage->GetStream() &&
m_pLastImage->GetStream()->GetObjNum()) {
AddImage(nullptr, m_pLastImage, FALSE);
return;
}
if (m_Options.m_bTextOnly) {
if (!m_pResources)
return;
CPDF_Dictionary* pList = m_pResources->GetDict("XObject");
if (!pList && m_pPageResources && m_pResources != m_pPageResources)
pList = m_pPageResources->GetDict("XObject");
if (!pList)
return;
CPDF_Reference* pRes = ToReference(pList->GetElement(name));
if (!pRes)
return;
FX_BOOL bForm;
if (m_pDocument->IsFormStream(pRes->GetRefObjNum(), bForm) && !bForm)
return;
}
CPDF_Stream* pXObject = ToStream(FindResourceObj("XObject", name));
if (!pXObject) {
m_bResourceMissing = TRUE;
return;
}
CFX_ByteStringC type = pXObject->GetDict()
? pXObject->GetDict()->GetConstString("Subtype")
: CFX_ByteStringC();
if (type == "Image") {
if (m_Options.m_bTextOnly) {
return;
}
CPDF_ImageObject* pObj = AddImage(pXObject, NULL, FALSE);
m_LastImageName = name;
m_pLastImage = pObj->m_pImage;
if (!m_pObjectList->m_bHasImageMask)
m_pObjectList->m_bHasImageMask = m_pLastImage->IsMask();
} else if (type == "Form") {
AddForm(pXObject);
} else {
return;
}
}
示例4: AddFontToAnnotDict
void CBA_FontMap::AddFontToAnnotDict(CPDF_Font* pFont, const CFX_ByteString& sAlias)
{
if (!pFont) return;
ASSERT(m_pAnnotDict != NULL);
ASSERT(m_pDocument != NULL);
CPDF_Dictionary* pAPDict = m_pAnnotDict->GetDict("AP");
if (pAPDict == NULL)
{
pAPDict = new CPDF_Dictionary;
m_pAnnotDict->SetAt("AP", pAPDict);
}
//to avoid checkbox and radiobutton
CPDF_Object* pObject = pAPDict->GetElement(m_sAPType);
if (pObject && pObject->GetType() == PDFOBJ_DICTIONARY)
return;
CPDF_Stream* pStream = pAPDict->GetStream(m_sAPType);
if (pStream == NULL)
{
pStream = new CPDF_Stream(NULL, 0, NULL);
FX_INT32 objnum = m_pDocument->AddIndirectObject(pStream);
pAPDict->SetAtReference(m_sAPType, m_pDocument, objnum);
}
CPDF_Dictionary * pStreamDict = pStream->GetDict();
if (!pStreamDict)
{
pStreamDict = new CPDF_Dictionary;
pStream->InitStream(NULL, 0, pStreamDict);
}
if (pStreamDict)
{
CPDF_Dictionary* pStreamResList = pStreamDict->GetDict("Resources");
if (!pStreamResList)
{
pStreamResList = new CPDF_Dictionary();
pStreamDict->SetAt("Resources", pStreamResList);
}
if (pStreamResList)
{
CPDF_Dictionary* pStreamResFontList = pStreamResList->GetDict("Font");
if (!pStreamResFontList)
{
pStreamResFontList = new CPDF_Dictionary;
FX_INT32 objnum = m_pDocument->AddIndirectObject(pStreamResFontList);
pStreamResList->SetAtReference("Font", m_pDocument, objnum);
}
if (!pStreamResFontList->KeyExist(sAlias))
pStreamResFontList->SetAtReference(sAlias, m_pDocument, pFont->GetFontDict());
}
}
}
示例5: v_Init
FX_BOOL CPDF_SampledFunc::v_Init(CPDF_Object* pObj) {
if (pObj->GetType() != PDFOBJ_STREAM) {
return FALSE;
}
CPDF_Stream* pStream = (CPDF_Stream*)pObj;
CPDF_Dictionary* pDict = pStream->GetDict();
CPDF_Array* pSize = pDict->GetArray(FX_BSTRC("Size"));
CPDF_Array* pEncode = pDict->GetArray(FX_BSTRC("Encode"));
CPDF_Array* pDecode = pDict->GetArray(FX_BSTRC("Decode"));
m_nBitsPerSample = pDict->GetInteger(FX_BSTRC("BitsPerSample"));
if (m_nBitsPerSample > 32) {
return FALSE;
}
m_SampleMax = 0xffffffff >> (32 - m_nBitsPerSample);
m_pSampleStream = new CPDF_StreamAcc;
m_pSampleStream->LoadAllData(pStream, FALSE);
m_pEncodeInfo = FX_Alloc(SampleEncodeInfo, m_nInputs);
FX_SAFE_DWORD nTotalSampleBits = 1;
for (int i = 0; i < m_nInputs; i++) {
m_pEncodeInfo[i].sizes = pSize ? pSize->GetInteger(i) : 0;
if (!pSize && i == 0) {
m_pEncodeInfo[i].sizes = pDict->GetInteger(FX_BSTRC("Size"));
}
nTotalSampleBits *= m_pEncodeInfo[i].sizes;
if (pEncode) {
m_pEncodeInfo[i].encode_min = pEncode->GetFloat(i * 2);
m_pEncodeInfo[i].encode_max = pEncode->GetFloat(i * 2 + 1);
} else {
m_pEncodeInfo[i].encode_min = 0;
if (m_pEncodeInfo[i].sizes == 1) {
m_pEncodeInfo[i].encode_max = 1;
} else {
m_pEncodeInfo[i].encode_max = (FX_FLOAT)m_pEncodeInfo[i].sizes - 1;
}
}
}
nTotalSampleBits *= m_nBitsPerSample;
nTotalSampleBits *= m_nOutputs;
FX_SAFE_DWORD nTotalSampleBytes = nTotalSampleBits;
nTotalSampleBytes += 7;
nTotalSampleBytes /= 8;
if (!nTotalSampleBytes.IsValid() || nTotalSampleBytes.ValueOrDie() == 0 ||
nTotalSampleBytes.ValueOrDie() > m_pSampleStream->GetSize()) {
return FALSE;
}
m_pDecodeInfo = FX_Alloc(SampleDecodeInfo, m_nOutputs);
for (int i = 0; i < m_nOutputs; i++) {
if (pDecode) {
m_pDecodeInfo[i].decode_min = pDecode->GetFloat(2 * i);
m_pDecodeInfo[i].decode_max = pDecode->GetFloat(2 * i + 1);
} else {
m_pDecodeInfo[i].decode_min = m_pRanges[i * 2];
m_pDecodeInfo[i].decode_max = m_pRanges[i * 2 + 1];
}
}
return TRUE;
}
示例6: 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;
}
示例7: WriteAppearance
void CPDFSDK_BAAnnot::WriteAppearance(const CFX_ByteString& sAPType,
const CPDF_Rect& rcBBox,
const CFX_Matrix& matrix,
const CFX_ByteString& sContents,
const CFX_ByteString& sAPState) {
CPDF_Dictionary* pAPDict = m_pAnnot->GetAnnotDict()->GetDictBy("AP");
if (!pAPDict) {
pAPDict = new CPDF_Dictionary;
m_pAnnot->GetAnnotDict()->SetAt("AP", pAPDict);
}
CPDF_Stream* pStream = nullptr;
CPDF_Dictionary* pParentDict = nullptr;
if (sAPState.IsEmpty()) {
pParentDict = pAPDict;
pStream = pAPDict->GetStreamBy(sAPType);
} else {
CPDF_Dictionary* pAPTypeDict = pAPDict->GetDictBy(sAPType);
if (!pAPTypeDict) {
pAPTypeDict = new CPDF_Dictionary;
pAPDict->SetAt(sAPType, pAPTypeDict);
}
pParentDict = pAPTypeDict;
pStream = pAPTypeDict->GetStreamBy(sAPState);
}
if (!pStream) {
pStream = new CPDF_Stream(nullptr, 0, nullptr);
CPDF_Document* pDoc = m_pPageView->GetPDFDocument();
int32_t objnum = pDoc->AddIndirectObject(pStream);
pParentDict->SetAtReference(sAPType, pDoc, objnum);
}
CPDF_Dictionary* pStreamDict = pStream->GetDict();
if (!pStreamDict) {
pStreamDict = new CPDF_Dictionary;
pStreamDict->SetAtName("Type", "XObject");
pStreamDict->SetAtName("Subtype", "Form");
pStreamDict->SetAtInteger("FormType", 1);
pStream->InitStream(nullptr, 0, pStreamDict);
}
if (pStreamDict) {
pStreamDict->SetAtMatrix("Matrix", matrix);
pStreamDict->SetAtRect("BBox", rcBBox);
}
pStream->SetData((uint8_t*)sContents.c_str(), sContents.GetLength(), FALSE,
FALSE);
}
示例8: v_Init
FX_BOOL CPDF_SampledFunc::v_Init(CPDF_Object* pObj) {
CPDF_Stream* pStream = pObj->AsStream();
if (!pStream)
return false;
CPDF_Dictionary* pDict = pStream->GetDict();
CPDF_Array* pSize = pDict->GetArrayBy("Size");
CPDF_Array* pEncode = pDict->GetArrayBy("Encode");
CPDF_Array* pDecode = pDict->GetArrayBy("Decode");
m_nBitsPerSample = pDict->GetIntegerBy("BitsPerSample");
if (!IsValidBitsPerSample(m_nBitsPerSample))
return FALSE;
m_SampleMax = 0xffffffff >> (32 - m_nBitsPerSample);
m_pSampleStream.reset(new CPDF_StreamAcc);
m_pSampleStream->LoadAllData(pStream, FALSE);
FX_SAFE_UINT32 nTotalSampleBits = 1;
m_EncodeInfo.resize(m_nInputs);
for (uint32_t i = 0; i < m_nInputs; i++) {
m_EncodeInfo[i].sizes = pSize ? pSize->GetIntegerAt(i) : 0;
if (!pSize && i == 0)
m_EncodeInfo[i].sizes = pDict->GetIntegerBy("Size");
nTotalSampleBits *= m_EncodeInfo[i].sizes;
if (pEncode) {
m_EncodeInfo[i].encode_min = pEncode->GetFloatAt(i * 2);
m_EncodeInfo[i].encode_max = pEncode->GetFloatAt(i * 2 + 1);
} else {
m_EncodeInfo[i].encode_min = 0;
m_EncodeInfo[i].encode_max =
m_EncodeInfo[i].sizes == 1 ? 1 : (FX_FLOAT)m_EncodeInfo[i].sizes - 1;
}
}
nTotalSampleBits *= m_nBitsPerSample;
nTotalSampleBits *= m_nOutputs;
FX_SAFE_UINT32 nTotalSampleBytes = nTotalSampleBits;
nTotalSampleBytes += 7;
nTotalSampleBytes /= 8;
if (!nTotalSampleBytes.IsValid() || nTotalSampleBytes.ValueOrDie() == 0 ||
nTotalSampleBytes.ValueOrDie() > m_pSampleStream->GetSize()) {
return FALSE;
}
m_DecodeInfo.resize(m_nOutputs);
for (uint32_t i = 0; i < m_nOutputs; i++) {
if (pDecode) {
m_DecodeInfo[i].decode_min = pDecode->GetFloatAt(2 * i);
m_DecodeInfo[i].decode_max = pDecode->GetFloatAt(2 * i + 1);
} else {
m_DecodeInfo[i].decode_min = m_pRanges[i * 2];
m_DecodeInfo[i].decode_max = m_pRanges[i * 2 + 1];
}
}
return TRUE;
}
示例9: IsFormStream
FX_BOOL CPDF_Document::IsFormStream(FX_DWORD objnum, FX_BOOL& bForm) const {
auto it = m_IndirectObjs.find(objnum);
if (it != m_IndirectObjs.end()) {
CPDF_Stream* pStream = it->second->AsStream();
bForm = pStream && pStream->GetDict()->GetString("Subtype") == "Form";
return TRUE;
}
if (!m_pParser) {
bForm = FALSE;
return TRUE;
}
return m_pParser->IsFormStream(objnum, bForm);
}
示例10: AddFontToAnnotDict
void CBA_FontMap::AddFontToAnnotDict(CPDF_Font* pFont,
const CFX_ByteString& sAlias) {
if (!pFont)
return;
CPDF_Dictionary* pAPDict = m_pAnnotDict->GetDictBy("AP");
if (!pAPDict) {
pAPDict = new CPDF_Dictionary;
m_pAnnotDict->SetAt("AP", pAPDict);
}
// to avoid checkbox and radiobutton
CPDF_Object* pObject = pAPDict->GetObjectBy(m_sAPType);
if (ToDictionary(pObject))
return;
CPDF_Stream* pStream = pAPDict->GetStreamBy(m_sAPType);
if (!pStream) {
pStream = new CPDF_Stream(nullptr, 0, nullptr);
int32_t objnum = m_pDocument->AddIndirectObject(pStream);
pAPDict->SetAtReference(m_sAPType, m_pDocument, objnum);
}
CPDF_Dictionary* pStreamDict = pStream->GetDict();
if (!pStreamDict) {
pStreamDict = new CPDF_Dictionary;
pStream->InitStream(nullptr, 0, pStreamDict);
}
if (pStreamDict) {
CPDF_Dictionary* pStreamResList = pStreamDict->GetDictBy("Resources");
if (!pStreamResList) {
pStreamResList = new CPDF_Dictionary();
pStreamDict->SetAt("Resources", pStreamResList);
}
if (pStreamResList) {
CPDF_Dictionary* pStreamResFontList = pStreamResList->GetDictBy("Font");
if (!pStreamResFontList) {
pStreamResFontList = new CPDF_Dictionary;
int32_t objnum = m_pDocument->AddIndirectObject(pStreamResFontList);
pStreamResList->SetAtReference("Font", m_pDocument, objnum);
}
if (!pStreamResFontList->KeyExist(sAlias))
pStreamResFontList->SetAtReference(sAlias, m_pDocument,
pFont->GetFontDict());
}
}
}
示例11: GetFormStream
static CPDF_Stream* GetFormStream(CPDF_Document* pDoc, CPDF_Object* pResObj)
{
if (pResObj->GetType() != PDFOBJ_REFERENCE) {
return NULL;
}
CPDF_Reference* pRef = (CPDF_Reference*)pResObj;
FX_BOOL bForm;
if (pDoc->IsFormStream(pRef->GetRefObjNum(), bForm) && !bForm) {
return NULL;
}
pResObj = pRef->GetDirect();
if (pResObj->GetType() != PDFOBJ_STREAM) {
return NULL;
}
CPDF_Stream* pXObject = (CPDF_Stream*)pResObj;
if (pXObject->GetDict()->GetString(FX_BSTRC("Subtype")) != FX_BSTRC("Form")) {
return NULL;
}
return pXObject;
}
示例12: Init
FX_BOOL CPDF_Function::Init(CPDF_Object* pObj) {
CPDF_Stream* pStream = pObj->AsStream();
CPDF_Dictionary* pDict = pStream ? pStream->GetDict() : pObj->AsDictionary();
CPDF_Array* pDomains = pDict->GetArrayBy("Domain");
if (!pDomains)
return FALSE;
m_nInputs = pDomains->GetCount() / 2;
if (m_nInputs == 0)
return FALSE;
m_pDomains = FX_Alloc2D(FX_FLOAT, m_nInputs, 2);
for (uint32_t i = 0; i < m_nInputs * 2; i++) {
m_pDomains[i] = pDomains->GetFloatAt(i);
}
CPDF_Array* pRanges = pDict->GetArrayBy("Range");
m_nOutputs = 0;
if (pRanges) {
m_nOutputs = pRanges->GetCount() / 2;
m_pRanges = FX_Alloc2D(FX_FLOAT, m_nOutputs, 2);
for (uint32_t i = 0; i < m_nOutputs * 2; i++)
m_pRanges[i] = pRanges->GetFloatAt(i);
}
uint32_t old_outputs = m_nOutputs;
if (!v_Init(pObj))
return FALSE;
if (m_pRanges && m_nOutputs > old_outputs) {
m_pRanges = FX_Realloc(FX_FLOAT, m_pRanges, m_nOutputs * 2);
if (m_pRanges) {
FXSYS_memset(m_pRanges + (old_outputs * 2), 0,
sizeof(FX_FLOAT) * (m_nOutputs - old_outputs) * 2);
}
}
return TRUE;
}
示例13: v_Load
FX_BOOL CPDF_ICCBasedCS::v_Load(CPDF_Document* pDoc, CPDF_Array* pArray)
{
CPDF_Stream* pStream = pArray->GetStream(1);
if (pStream == NULL) {
return FALSE;
}
m_pProfile = pDoc->LoadIccProfile(pStream);
if (!m_pProfile) {
return FALSE;
}
m_nComponents = m_pProfile->GetComponents(); //Try using the nComponents from ICC profile
CPDF_Dictionary* pDict = pStream->GetDict();
if (m_pProfile->m_pTransform == NULL) { // No valid ICC profile or using sRGB
CPDF_Object* pAlterCSObj = pDict ? pDict->GetElementValue(FX_BSTRC("Alternate")) : NULL;
if (pAlterCSObj) {
CPDF_ColorSpace* pAlterCS = CPDF_ColorSpace::Load(pDoc, pAlterCSObj);
if (pAlterCS) {
if (m_nComponents == 0) { // NO valid ICC profile
if (pAlterCS->CountComponents() > 0) { // Use Alternative colorspace
m_nComponents = pAlterCS->CountComponents();
m_pAlterCS = pAlterCS;
m_bOwn = TRUE;
}
else { // No valid alternative colorspace
pAlterCS->ReleaseCS();
int32_t nDictComponents = pDict ? pDict->GetInteger(FX_BSTRC("N")) : 0;
if (nDictComponents != 1 && nDictComponents != 3 && nDictComponents != 4) {
return FALSE;
}
m_nComponents = nDictComponents;
}
}
else { // Using sRGB
if (pAlterCS->CountComponents() != m_nComponents) {
pAlterCS->ReleaseCS();
}
else {
m_pAlterCS = pAlterCS;
m_bOwn = TRUE;
}
}
}
}
if (!m_pAlterCS) {
if (m_nComponents == 1) {
m_pAlterCS = GetStockCS(PDFCS_DEVICEGRAY);
}
else if (m_nComponents == 3) {
m_pAlterCS = GetStockCS(PDFCS_DEVICERGB);
}
else if (m_nComponents == 4) {
m_pAlterCS = GetStockCS(PDFCS_DEVICECMYK);
}
}
}
CPDF_Array* pRanges = pDict->GetArray(FX_BSTRC("Range"));
m_pRanges = FX_Alloc2D(FX_FLOAT, m_nComponents, 2);
for (int i = 0; i < m_nComponents * 2; i ++) {
if (pRanges) {
m_pRanges[i] = pRanges->GetNumber(i);
} else if (i % 2) {
m_pRanges[i] = 1.0f;
} else {
m_pRanges[i] = 0;
}
}
return TRUE;
}
示例14: TraceObject
FX_BOOL CFFL_Utils::TraceObject(CPDF_Object* pObj)
{
if (!pObj) return FALSE;
FX_DWORD dwObjNum = pObj->GetObjNum();
switch (pObj->GetType())
{
case PDFOBJ_ARRAY:
{
CPDF_Array* pArray = (CPDF_Array*)pObj;
for (FX_DWORD i = 0; i < pArray->GetCount(); i ++)
{
CPDF_Object* pElement = pArray->GetElementValue(i);
TraceObject(pElement);
}
}
break;
case PDFOBJ_DICTIONARY:
{
CPDF_Dictionary* pDict = (CPDF_Dictionary*)pObj;
FX_POSITION fPos = pDict->GetStartPos();
CFX_ByteString csKey;
do
{
CPDF_Object* pElement = pDict->GetNextElement(fPos, csKey);
//TRACE(csKey + "\n");
if (!pElement) break;
TraceObject(pElement);
}while (TRUE);
}
break;
case PDFOBJ_STREAM:
{
CPDF_Stream* pStream = (CPDF_Stream*)pObj;
CPDF_Dictionary* pDict = pStream->GetDict();
TraceObject(pDict);
}
break;
case PDFOBJ_REFERENCE:
{
CPDF_Object* pDirectObj = pObj->GetDirect();
TraceObject(pDirectObj);
}
break;
case PDFOBJ_BOOLEAN:
break;
case PDFOBJ_NUMBER:
//TRACE("%d\n",(int32_t)pObj);
break;
case PDFOBJ_STRING:
//TRACE(((CPDF_String*)pObj)->GetString() + "\n");
break;
case PDFOBJ_NAME:
//TRACE(((CPDF_Name*)pObj)->GetString() + "\n");
break;
case PDFOBJ_NULL:
// case PDFOBJ_KEYWORD:
// case PDFOBJ_EOF:
default:
break;
}
if (dwObjNum == 0) return FALSE;
return TRUE;
}
示例15: 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->GetElement("Contents") : nullptr;
if (!pContentObj)
pContentObj = pPageDic ? pPageDic->GetArrayBy("Contents") : nullptr;
if (!pContentObj)
return FALSE;
CPDF_Dictionary* pDic = new CPDF_Dictionary;
CPDF_Stream* pStream = new CPDF_Stream(nullptr, 0, pDic);
pStream->SetData(textBuf.GetBuffer(), textBuf.GetSize(), FALSE, FALSE);
CPDF_Document* pDoc = pPage->m_pDocument;
if (!pDoc)
return FALSE;
pDoc->AddIndirectObject(pStream);
pDic = new CPDF_Dictionary;
CPDF_Stream* pEndStream = new CPDF_Stream(nullptr, 0, pDic);
pEndStream->SetData((const uint8_t*)" Q", 2, FALSE, FALSE);
pDoc->AddIndirectObject(pEndStream);
CPDF_Array* pContentArray = nullptr;
if (CPDF_Array* pArray = ToArray(pContentObj)) {
pContentArray = pArray;
CPDF_Reference* pRef = new CPDF_Reference(pDoc, pStream->GetObjNum());
pContentArray->InsertAt(0, pRef);
pContentArray->AddReference(pDoc, pEndStream);
} else if (CPDF_Reference* pReference = ToReference(pContentObj)) {
CPDF_Object* pDirectObj = pReference->GetDirect();
if (pDirectObj) {
if (CPDF_Array* pArray = pDirectObj->AsArray()) {
pContentArray = pArray;
CPDF_Reference* pRef = new CPDF_Reference(pDoc, pStream->GetObjNum());
pContentArray->InsertAt(0, pRef);
pContentArray->AddReference(pDoc, pEndStream);
} else if (pDirectObj->IsStream()) {
pContentArray = new CPDF_Array();
pContentArray->AddReference(pDoc, pStream->GetObjNum());
pContentArray->AddReference(pDoc, pDirectObj->GetObjNum());
pContentArray->AddReference(pDoc, pEndStream);
pPageDic->SetAtReference("Contents", pDoc,
pDoc->AddIndirectObject(pContentArray));
}
}
}
// Need to transform the patterns as well.
CPDF_Dictionary* pRes = pPageDic->GetDictBy("Resources");
if (pRes) {
CPDF_Dictionary* pPattenDict = pRes->GetDictBy("Pattern");
if (pPattenDict) {
for (const auto& it : *pPattenDict) {
CPDF_Object* pObj = it.second;
if (pObj->IsReference())
pObj = pObj->GetDirect();
CPDF_Dictionary* pDict = nullptr;
if (pObj->IsDictionary())
pDict = pObj->AsDictionary();
else if (CPDF_Stream* pStream = pObj->AsStream())
pDict = pStream->GetDict();
else
continue;
CFX_Matrix m = pDict->GetMatrixBy("Matrix");
CFX_Matrix t = *(CFX_Matrix*)matrix;
m.Concat(t);
pDict->SetAtMatrix("Matrix", m);
}
}
}
return TRUE;
}