本文整理汇总了C++中CPDF_Dictionary::SetAt方法的典型用法代码示例。如果您正苦于以下问题:C++ CPDF_Dictionary::SetAt方法的具体用法?C++ CPDF_Dictionary::SetAt怎么用?C++ CPDF_Dictionary::SetAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CPDF_Dictionary
的用法示例。
在下文中一共展示了CPDF_Dictionary::SetAt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ExportToFDF
CFDF_Document* CPDF_InterForm::ExportToFDF(
const CFX_WideStringC& pdf_path,
const std::vector<CPDF_FormField*>& fields,
bool bIncludeOrExclude,
bool bSimpleFileSpec) const {
CFDF_Document* pDoc = CFDF_Document::CreateNewDoc();
if (!pDoc)
return nullptr;
CPDF_Dictionary* pMainDict = pDoc->GetRoot()->GetDictBy("FDF");
if (!pdf_path.IsEmpty()) {
if (bSimpleFileSpec) {
CFX_WideString wsFilePath = CPDF_FileSpec::EncodeFileName(pdf_path);
pMainDict->SetAtString("F", CFX_ByteString::FromUnicode(wsFilePath));
pMainDict->SetAtString("UF", PDF_EncodeText(wsFilePath));
} else {
CPDF_FileSpec filespec;
filespec.SetFileName(pdf_path);
pMainDict->SetAt("F", filespec.GetObj());
}
}
CPDF_Array* pFields = new CPDF_Array;
pMainDict->SetAt("Fields", pFields);
int nCount = m_pFieldTree->m_Root.CountFields();
for (int i = 0; i < nCount; i++) {
CPDF_FormField* pField = m_pFieldTree->m_Root.GetField(i);
if (!pField || pField->GetType() == CPDF_FormField::PushButton)
continue;
uint32_t dwFlags = pField->GetFieldFlags();
if (dwFlags & 0x04)
continue;
if (bIncludeOrExclude == pdfium::ContainsValue(fields, pField)) {
if ((dwFlags & 0x02) != 0 && pField->m_pDict->GetStringBy("V").IsEmpty())
continue;
CFX_WideString fullname = FPDF_GetFullName(pField->GetFieldDict());
CPDF_Dictionary* pFieldDict = new CPDF_Dictionary;
pFieldDict->SetAt("T", new CPDF_String(fullname));
if (pField->GetType() == CPDF_FormField::CheckBox ||
pField->GetType() == CPDF_FormField::RadioButton) {
CFX_WideString csExport = pField->GetCheckValue(FALSE);
CFX_ByteString csBExport = PDF_EncodeText(csExport);
CPDF_Object* pOpt = FPDF_GetFieldAttr(pField->m_pDict, "Opt");
if (pOpt)
pFieldDict->SetAtString("V", csBExport);
else
pFieldDict->SetAtName("V", csBExport);
} else {
CPDF_Object* pV = FPDF_GetFieldAttr(pField->m_pDict, "V");
if (pV)
pFieldDict->SetAt("V", pV->CloneDirectObject());
}
pFields->Add(pFieldDict);
}
}
return pDoc;
}
示例2: CPDFDocumentFromFPDFDocument
DLLEXPORT FPDF_PAGE STDCALL FPDFPage_New(FPDF_DOCUMENT document,
int page_index,
double width,
double height) {
CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document);
if (!pDoc)
return nullptr;
if (page_index < 0)
page_index = 0;
if (pDoc->GetPageCount() < page_index)
page_index = pDoc->GetPageCount();
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;
}
示例3: FPDFDocumentFromCPDFDocument
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(¤tTime)) {
tm* pTM = localtime(¤tTime);
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 FPDFDocumentFromCPDFDocument(pDoc);
}
示例4: CPDFXFA_Page
DLLEXPORT FPDF_PAGE STDCALL FPDFPage_New(FPDF_DOCUMENT document,
int page_index,
double width,
double height) {
CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document);
if (!pDoc)
return nullptr;
page_index = std::min(std::max(page_index, 0), pDoc->GetPageCount());
CPDF_Dictionary* pPageDict = pDoc->CreateNewPage(page_index);
if (!pPageDict)
return nullptr;
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);
#ifdef PDF_ENABLE_XFA
CPDFXFA_Page* pPage =
new CPDFXFA_Page((CPDFXFA_Document*)document, page_index);
pPage->LoadPDFPage(pPageDict);
#else // PDF_ENABLE_XFA
CPDF_Page* pPage = new CPDF_Page(pDoc, pPageDict, true);
pPage->ParseContent();
#endif // PDF_ENABLE_XFA
return pPage;
}
示例5:
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 = FX_NEW CPDF_Array;
pMediaBoxArray->Add(FX_NEW CPDF_Number(0));
pMediaBoxArray->Add(FX_NEW CPDF_Number(0));
pMediaBoxArray->Add(FX_NEW CPDF_Number(FX_FLOAT(width)));
pMediaBoxArray->Add(FX_NEW CPDF_Number(FX_FLOAT(height)));
pPageDict->SetAt("MediaBox", pMediaBoxArray);
pPageDict->SetAt("Rotate", FX_NEW CPDF_Number(0));
pPageDict->SetAt("Resources", FX_NEW CPDF_Dictionary);
CPDF_Page* pPage = FX_NEW CPDF_Page;
pPage->Load(pDoc,pPageDict);
pPage->ParseContent();
return pPage;
}
示例6: InsertNewPage
static int InsertNewPage(CPDF_Document* pDoc, int iPage, CPDF_Dictionary* pPageDict, CFX_DWordArray &pageList)
{
CPDF_Dictionary* pRoot = pDoc->GetRoot();
if (!pRoot) {
return -1;
}
CPDF_Dictionary* pPages = pRoot->GetDict(FX_BSTRC("Pages"));
if (!pPages) {
return -1;
}
int nPages = pDoc->GetPageCount();
if (iPage < 0 || iPage > nPages) {
return -1;
}
if (iPage == nPages) {
CPDF_Array* pPagesList = pPages->GetArray(FX_BSTRC("Kids"));
if (!pPagesList) {
pPagesList = FX_NEW CPDF_Array;
pPages->SetAt(FX_BSTRC("Kids"), pPagesList);
}
pPagesList->Add(pPageDict, pDoc);
pPages->SetAtInteger(FX_BSTRC("Count"), nPages + 1);
pPageDict->SetAtReference(FX_BSTRC("Parent"), pDoc, pPages->GetObjNum());
} else {
CFX_PtrArray stack;
stack.Add(pPages);
if (InsertDeletePDFPage(pDoc, pPages, iPage, pPageDict, TRUE, stack) < 0) {
return -1;
}
}
pageList.InsertAt(iPage, pPageDict->GetObjNum());
return iPage;
}
示例7: 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());
}
}
}
示例8: InitJPEG
CPDF_Dictionary* CPDF_Image::InitJPEG(uint8_t* pData, FX_DWORD size) {
int32_t width;
int32_t height;
int32_t num_comps;
int32_t bits;
FX_BOOL color_trans;
if (!CPDF_ModuleMgr::Get()->GetJpegModule()->LoadInfo(
pData, size, width, height, num_comps, bits, color_trans)) {
return NULL;
}
CPDF_Dictionary* pDict = new CPDF_Dictionary;
pDict->SetAtName("Type", "XObject");
pDict->SetAtName("Subtype", "Image");
pDict->SetAtInteger("Width", width);
pDict->SetAtInteger("Height", height);
const FX_CHAR* csname = NULL;
if (num_comps == 1) {
csname = "DeviceGray";
} else if (num_comps == 3) {
csname = "DeviceRGB";
} else if (num_comps == 4) {
csname = "DeviceCMYK";
CPDF_Array* pDecode = new CPDF_Array;
for (int n = 0; n < 4; n++) {
pDecode->AddInteger(1);
pDecode->AddInteger(0);
}
pDict->SetAt("Decode", pDecode);
}
pDict->SetAtName("ColorSpace", csname);
pDict->SetAtInteger("BitsPerComponent", bits);
pDict->SetAtName("Filter", "DCTDecode");
if (!color_trans) {
CPDF_Dictionary* pParms = new CPDF_Dictionary;
pDict->SetAt("DecodeParms", pParms);
pParms->SetAtInteger("ColorTransform", 0);
}
m_bIsMask = FALSE;
m_Width = width;
m_Height = height;
if (!m_pStream) {
m_pStream = new CPDF_Stream(NULL, 0, NULL);
}
return pDict;
}
示例9: CPDFPageFromFPDFPage
DLLEXPORT void STDCALL FPDFPage_SetRotation(FPDF_PAGE page, int rotate) {
CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
if (!IsPageObject(pPage))
return;
CPDF_Dictionary* pDict = pPage->m_pFormDict;
rotate %= 4;
pDict->SetAt("Rotate", new CPDF_Number(rotate * 90));
}
示例10: GetStandardFont
CPDF_Font* CPDF_DocPageData::GetStandardFont(FX_BSTR fontName, CPDF_FontEncoding* pEncoding)
{
if (fontName.IsEmpty()) {
return NULL;
}
FX_POSITION pos = m_FontMap.GetStartPosition();
while (pos) {
CPDF_Dictionary* fontDict;
CPDF_CountedObject<CPDF_Font*>* fontData;
m_FontMap.GetNextAssoc(pos, fontDict, fontData);
CPDF_Font* pFont = fontData->m_Obj;
if (!pFont) {
continue;
}
if (pFont->GetBaseFont() != fontName) {
continue;
}
if (pFont->IsEmbedded()) {
continue;
}
if (pFont->GetFontType() != PDFFONT_TYPE1) {
continue;
}
if (pFont->GetFontDict()->KeyExist(FX_BSTRC("Widths"))) {
continue;
}
CPDF_Type1Font* pT1Font = pFont->GetType1Font();
if (pEncoding && !pT1Font->GetEncoding()->IsIdentical(pEncoding)) {
continue;
}
fontData->m_nCount ++;
return pFont;
}
CPDF_Dictionary* pDict = FX_NEW CPDF_Dictionary;
pDict->SetAtName(FX_BSTRC("Type"), FX_BSTRC("Font"));
pDict->SetAtName(FX_BSTRC("Subtype"), FX_BSTRC("Type1"));
pDict->SetAtName(FX_BSTRC("BaseFont"), fontName);
if (pEncoding) {
pDict->SetAt(FX_BSTRC("Encoding"), pEncoding->Realize());
}
m_pPDFDoc->AddIndirectObject(pDict);
CPDF_CountedObject<CPDF_Font*>* fontData = FX_NEW CPDF_CountedObject<CPDF_Font*>;
if (!fontData) {
return NULL;
}
CPDF_Font* pFont = CPDF_Font::CreateFontF(m_pPDFDoc, pDict);
if (!pFont) {
delete fontData;
return NULL;
}
fontData->m_nCount = 2;
fontData->m_Obj = pFont;
m_FontMap.SetAt(pDict, fontData);
return pFont;
}
示例11: 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);
}
示例12: CPDFPageFromFPDFPage
DLLEXPORT void STDCALL FPDFPage_SetRotation(FPDF_PAGE page, int rotate) {
CPDF_Page* pPage = CPDFPageFromFPDFPage(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));
}
示例13: 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());
}
}
}
示例14: SetBorderDash
void CPDFSDK_BAAnnot::SetBorderDash(const CFX_IntArray& array) {
CPDF_Dictionary* pBSDict = m_pAnnot->GetAnnotDict()->GetDictBy("BS");
if (!pBSDict) {
pBSDict = new CPDF_Dictionary;
m_pAnnot->GetAnnotDict()->SetAt("BS", pBSDict);
}
CPDF_Array* pArray = new CPDF_Array;
for (int i = 0, sz = array.GetSize(); i < sz; i++) {
pArray->AddInteger(array[i]);
}
pBSDict->SetAt("D", pArray);
}
示例15: CreateNewDoc
void CPDF_Document::CreateNewDoc() {
ASSERT(!m_pRootDict && !m_pInfoDict);
m_pRootDict = new CPDF_Dictionary;
m_pRootDict->SetAtName("Type", "Catalog");
int objnum = AddIndirectObject(m_pRootDict);
CPDF_Dictionary* pPages = new CPDF_Dictionary;
pPages->SetAtName("Type", "Pages");
pPages->SetAtNumber("Count", 0);
pPages->SetAt("Kids", new CPDF_Array);
objnum = AddIndirectObject(pPages);
m_pRootDict->SetAtReference("Pages", this, objnum);
m_pInfoDict = new CPDF_Dictionary;
AddIndirectObject(m_pInfoDict);
}