本文整理汇总了C++中CPDF_Dictionary::SetAtString方法的典型用法代码示例。如果您正苦于以下问题:C++ CPDF_Dictionary::SetAtString方法的具体用法?C++ CPDF_Dictionary::SetAtString怎么用?C++ CPDF_Dictionary::SetAtString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CPDF_Dictionary
的用法示例。
在下文中一共展示了CPDF_Dictionary::SetAtString方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: title
FX_BOOL Document::title(IFXJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError)
{
ASSERT(m_pDocument != NULL);
if (m_pDocument == NULL || m_pDocument->GetDocument() == NULL)
return FALSE;
CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo();
if (!pDictionary)return FALSE;
if (vp.IsGetting())
{
vp << pDictionary->GetUnicodeText("Title");
return TRUE;
}
else
{
if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) return FALSE;
CFX_WideString cstitle;
vp >> cstitle;
pDictionary->SetAtString("Title", PDF_EncodeText(cstitle));
m_pDocument->SetChangeMark();
return TRUE;
}
}
示例3: FPDFDOC_FILESPEC_SetFileName
static void FPDFDOC_FILESPEC_SetFileName(CPDF_Object *pObj, FX_WSTR wsFileName, FX_BOOL bURL)
{
ASSERT(pObj != NULL);
CFX_WideString wsStr;
if (bURL) {
wsStr = wsFileName;
} else {
wsStr = FILESPEC_EncodeFileName(wsFileName);
}
FX_INT32 iType = pObj->GetType();
if (iType == PDFOBJ_STRING) {
pObj->SetString(CFX_ByteString::FromUnicode(wsStr));
} else if (iType == PDFOBJ_DICTIONARY) {
CPDF_Dictionary* pDict = (CPDF_Dictionary*)pObj;
pDict->SetAtString(FX_BSTRC("F"), CFX_ByteString::FromUnicode(wsStr));
pDict->SetAtString(FX_BSTRC("UF"), PDF_EncodeText(wsStr));
}
}
示例4: AddFont
//.........这里部分代码省略.........
flags |= PDFFONT_NONSYMBOLIC;
pFontDict = FX_NEW CPDF_Dictionary;
CFX_ByteString cmap;
CFX_ByteString ordering;
int supplement;
CPDF_Array* pWidthArray = FX_NEW CPDF_Array;
switch (charset) {
case FXFONT_CHINESEBIG5_CHARSET:
cmap = bVert ? "ETenms-B5-V" : "ETenms-B5-H";
ordering = "CNS1";
supplement = 4;
pWidthArray->AddInteger(1);
_InsertWidthArray1(pFont, pEncoding, 0x20, 0x7e, pWidthArray);
break;
case FXFONT_GB2312_CHARSET:
cmap = bVert ? "GBK-EUC-V" : "GBK-EUC-H";
ordering = "GB1", supplement = 2;
pWidthArray->AddInteger(7716);
_InsertWidthArray1(pFont, pEncoding, 0x20, 0x20, pWidthArray);
pWidthArray->AddInteger(814);
_InsertWidthArray1(pFont, pEncoding, 0x21, 0x7e, pWidthArray);
break;
case FXFONT_HANGEUL_CHARSET:
cmap = bVert ? "KSCms-UHC-V" : "KSCms-UHC-H";
ordering = "Korea1";
supplement = 2;
pWidthArray->AddInteger(1);
_InsertWidthArray1(pFont, pEncoding, 0x20, 0x7e, pWidthArray);
break;
case FXFONT_SHIFTJIS_CHARSET:
cmap = bVert ? "90ms-RKSJ-V" : "90ms-RKSJ-H";
ordering = "Japan1";
supplement = 5;
pWidthArray->AddInteger(231);
_InsertWidthArray1(pFont, pEncoding, 0x20, 0x7d, pWidthArray);
pWidthArray->AddInteger(326);
_InsertWidthArray1(pFont, pEncoding, 0xa0, 0xa0, pWidthArray);
pWidthArray->AddInteger(327);
_InsertWidthArray1(pFont, pEncoding, 0xa1, 0xdf, pWidthArray);
pWidthArray->AddInteger(631);
_InsertWidthArray1(pFont, pEncoding, 0x7e, 0x7e, pWidthArray);
break;
}
pBaseDict->SetAtName("Subtype", "Type0");
pBaseDict->SetAtName("BaseFont", basefont);
pBaseDict->SetAtName("Encoding", cmap);
pFontDict->SetAt("W", pWidthArray);
pFontDict->SetAtName("Type", "Font");
pFontDict->SetAtName("Subtype", "CIDFontType2");
pFontDict->SetAtName("BaseFont", basefont);
CPDF_Dictionary* pCIDSysInfo = FX_NEW CPDF_Dictionary;
pCIDSysInfo->SetAtString("Registry", "Adobe");
pCIDSysInfo->SetAtString("Ordering", ordering);
pCIDSysInfo->SetAtInteger("Supplement", supplement);
pFontDict->SetAt("CIDSystemInfo", pCIDSysInfo);
CPDF_Array* pArray = FX_NEW CPDF_Array;
pBaseDict->SetAt("DescendantFonts", pArray);
AddIndirectObject(pFontDict);
pArray->AddReference(this, pFontDict);
}
AddIndirectObject(pBaseDict);
CPDF_Dictionary* pFontDesc = FX_NEW CPDF_Dictionary;
pFontDesc->SetAtName("Type", "FontDescriptor");
pFontDesc->SetAtName("FontName", basefont);
pFontDesc->SetAtInteger("Flags", flags);
pFontDesc->SetAtInteger("ItalicAngle", pFont->m_pSubstFont ? pFont->m_pSubstFont->m_ItalicAngle : 0);
pFontDesc->SetAtInteger("Ascent", pFont->GetAscent());
pFontDesc->SetAtInteger("Descent", pFont->GetDescent());
FX_RECT bbox;
pFont->GetBBox(bbox);
CPDF_Array* pBBox = FX_NEW CPDF_Array;
pBBox->AddInteger(bbox.left);
pBBox->AddInteger(bbox.bottom);
pBBox->AddInteger(bbox.right);
pBBox->AddInteger(bbox.top);
pFontDesc->SetAt("FontBBox", pBBox);
FX_INT32 nStemV = 0;
if (pFont->m_pSubstFont) {
nStemV = pFont->m_pSubstFont->m_Weight / 5;
} else {
static const FX_CHAR stem_chars[] = {'i', 'I', '!', '1'};
const size_t count = sizeof(stem_chars) / sizeof(stem_chars[0]);
FX_DWORD glyph = pEncoding->GlyphFromCharCode(stem_chars[0]);
nStemV = pFont->GetGlyphWidth(glyph);
for (size_t i = 1; i < count; i++) {
glyph = pEncoding->GlyphFromCharCode(stem_chars[i]);
int width = pFont->GetGlyphWidth(glyph);
if (width > 0 && width < nStemV) {
nStemV = width;
}
}
}
if (pEncoding) {
delete pEncoding;
}
pFontDesc->SetAtInteger("StemV", nStemV);
AddIndirectObject(pFontDesc);
pFontDict->SetAtReference("FontDescriptor", this, pFontDesc);
return LoadFont(pBaseDict);
}
示例5: AddMacFont
//.........这里部分代码省略.........
charSets.Add(FXFONT_CHINESEBIG5_CHARSET);
if (IsHasCharSet(languages, charSets)) {
cmap = bVert ? "ETenms-B5-V" : "ETenms-B5-H";
ordering = "CNS1";
supplement = 4;
pWidthArray->AddInteger(1);
_InsertWidthArray(font, 0x20, 0x7e, pWidthArray);
bFound = TRUE;
}
charSets.RemoveAll();
charSets.Add(FXFONT_GB2312_CHARSET);
if (!bFound && IsHasCharSet(languages, charSets)) {
cmap = bVert ? "GBK-EUC-V" : "GBK-EUC-H";
ordering = "GB1", supplement = 2;
pWidthArray->AddInteger(7716);
_InsertWidthArray(font, 0x20, 0x20, pWidthArray);
pWidthArray->AddInteger(814);
_InsertWidthArray(font, 0x21, 0x7e, pWidthArray);
bFound = TRUE;
}
charSets.RemoveAll();
charSets.Add(FXFONT_HANGEUL_CHARSET);
if (!bFound && IsHasCharSet(languages, charSets)) {
cmap = bVert ? "KSCms-UHC-V" : "KSCms-UHC-H";
ordering = "Korea1";
supplement = 2;
pWidthArray->AddInteger(1);
_InsertWidthArray(font, 0x20, 0x7e, pWidthArray);
bFound = TRUE;
}
charSets.RemoveAll();
charSets.Add(FXFONT_SHIFTJIS_CHARSET);
if (!bFound && IsHasCharSet(languages, charSets)) {
cmap = bVert ? "90ms-RKSJ-V" : "90ms-RKSJ-H";
ordering = "Japan1";
supplement = 5;
pWidthArray->AddInteger(231);
_InsertWidthArray(font, 0x20, 0x7d, pWidthArray);
pWidthArray->AddInteger(326);
_InsertWidthArray(font, 0xa0, 0xa0, pWidthArray);
pWidthArray->AddInteger(327);
_InsertWidthArray(font, 0xa1, 0xdf, pWidthArray);
pWidthArray->AddInteger(631);
_InsertWidthArray(font, 0x7e, 0x7e, pWidthArray);
}
pBaseDict->SetAtName("Subtype", "Type0");
pBaseDict->SetAtName("BaseFont", basefont);
pBaseDict->SetAtName("Encoding", cmap);
pFontDict->SetAt("W", pWidthArray);
pFontDict->SetAtName("Type", "Font");
pFontDict->SetAtName("Subtype", "CIDFontType2");
pFontDict->SetAtName("BaseFont", basefont);
CPDF_Dictionary* pCIDSysInfo = FX_NEW CPDF_Dictionary;
pCIDSysInfo->SetAtString("Registry", "Adobe");
pCIDSysInfo->SetAtString("Ordering", ordering);
pCIDSysInfo->SetAtInteger("Supplement", supplement);
pFontDict->SetAt("CIDSystemInfo", pCIDSysInfo);
pArray = FX_NEW CPDF_Array;
pBaseDict->SetAt("DescendantFonts", pArray);
AddIndirectObject(pFontDict);
pArray->AddReference(this, pFontDict);
}
AddIndirectObject(pBaseDict);
CPDF_Dictionary* pFontDesc = FX_NEW CPDF_Dictionary;
pFontDesc->SetAtName("Type", "FontDescriptor");
pFontDesc->SetAtName("FontName", basefont);
pFontDesc->SetAtInteger("Flags", flags);
CPDF_Array* pBBox = FX_NEW CPDF_Array;
for (int i = 0; i < 4; i ++) {
pBBox->AddInteger(bbox[i]);
}
pFontDesc->SetAt("FontBBox", pBBox);
pFontDesc->SetAtInteger("ItalicAngle", italicangle);
pFontDesc->SetAtInteger("Ascent", ascend);
pFontDesc->SetAtInteger("Descent", descend);
pFontDesc->SetAtInteger("CapHeight", capheight);
CGFloat fStemV = 0;
int16_t min_width = SHRT_MAX;
static const UniChar stem_chars[] = {'i', 'I', '!', '1'};
const size_t count = sizeof(stem_chars) / sizeof(stem_chars[0]);
CGGlyph glyphs[count];
CGRect boundingRects[count];
if (CTFontGetGlyphsForCharacters(font, stem_chars, glyphs, count)) {
CTFontGetBoundingRectsForGlyphs(font, kCTFontHorizontalOrientation,
glyphs, boundingRects, count);
for (size_t i = 0; i < count; i++) {
int16_t width = boundingRects[i].size.width;
if (width > 0 && width < min_width) {
min_width = width;
fStemV = min_width;
}
}
}
pFontDesc->SetAtInteger("StemV", fStemV);
AddIndirectObject(pFontDesc);
pFontDict->SetAtReference("FontDescriptor", this, pFontDesc);
CFRelease(traits);
CFRelease(languages);
return LoadFont(pBaseDict);
}
示例6: AddWindowsFont
//.........这里部分代码省略.........
basefont += ",BoldItalic";
} else if (pLogFont->lfWeight > FW_MEDIUM) {
basefont += ",Bold";
} else if (pLogFont->lfItalic) {
basefont += ",Italic";
}
pBaseDict->SetAtName("Subtype", "TrueType");
pBaseDict->SetAtName("BaseFont", basefont);
pBaseDict->SetAtNumber("FirstChar", 32);
pBaseDict->SetAtNumber("LastChar", 255);
int char_widths[224];
GetCharWidth(hDC, 32, 255, char_widths);
CPDF_Array* pWidths = FX_NEW CPDF_Array;
for (int i = 0; i < 224; i ++) {
pWidths->AddInteger(char_widths[i]);
}
pBaseDict->SetAt("Widths", pWidths);
} else {
flags |= PDFFONT_NONSYMBOLIC;
pFontDict = FX_NEW CPDF_Dictionary;
CFX_ByteString cmap;
CFX_ByteString ordering;
int supplement;
CPDF_Array* pWidthArray = FX_NEW CPDF_Array;
switch (pLogFont->lfCharSet) {
case CHINESEBIG5_CHARSET:
cmap = bVert ? "ETenms-B5-V" : "ETenms-B5-H";
ordering = "CNS1";
supplement = 4;
pWidthArray->AddInteger(1);
_InsertWidthArray(hDC, 0x20, 0x7e, pWidthArray);
break;
case GB2312_CHARSET:
cmap = bVert ? "GBK-EUC-V" : "GBK-EUC-H";
ordering = "GB1", supplement = 2;
pWidthArray->AddInteger(7716);
_InsertWidthArray(hDC, 0x20, 0x20, pWidthArray);
pWidthArray->AddInteger(814);
_InsertWidthArray(hDC, 0x21, 0x7e, pWidthArray);
break;
case HANGEUL_CHARSET:
cmap = bVert ? "KSCms-UHC-V" : "KSCms-UHC-H";
ordering = "Korea1";
supplement = 2;
pWidthArray->AddInteger(1);
_InsertWidthArray(hDC, 0x20, 0x7e, pWidthArray);
break;
case SHIFTJIS_CHARSET:
cmap = bVert ? "90ms-RKSJ-V" : "90ms-RKSJ-H";
ordering = "Japan1";
supplement = 5;
pWidthArray->AddInteger(231);
_InsertWidthArray(hDC, 0x20, 0x7d, pWidthArray);
pWidthArray->AddInteger(326);
_InsertWidthArray(hDC, 0xa0, 0xa0, pWidthArray);
pWidthArray->AddInteger(327);
_InsertWidthArray(hDC, 0xa1, 0xdf, pWidthArray);
pWidthArray->AddInteger(631);
_InsertWidthArray(hDC, 0x7e, 0x7e, pWidthArray);
break;
}
pBaseDict->SetAtName("Subtype", "Type0");
pBaseDict->SetAtName("BaseFont", basefont);
pBaseDict->SetAtName("Encoding", cmap);
pFontDict->SetAt("W", pWidthArray);
pFontDict->SetAtName("Type", "Font");
pFontDict->SetAtName("Subtype", "CIDFontType2");
pFontDict->SetAtName("BaseFont", basefont);
CPDF_Dictionary* pCIDSysInfo = FX_NEW CPDF_Dictionary;
pCIDSysInfo->SetAtString("Registry", "Adobe");
pCIDSysInfo->SetAtString("Ordering", ordering);
pCIDSysInfo->SetAtInteger("Supplement", supplement);
pFontDict->SetAt("CIDSystemInfo", pCIDSysInfo);
CPDF_Array* pArray = FX_NEW CPDF_Array;
pBaseDict->SetAt("DescendantFonts", pArray);
AddIndirectObject(pFontDict);
pArray->AddReference(this, pFontDict);
}
AddIndirectObject(pBaseDict);
CPDF_Dictionary* pFontDesc = FX_NEW CPDF_Dictionary;
pFontDesc->SetAtName("Type", "FontDescriptor");
pFontDesc->SetAtName("FontName", basefont);
pFontDesc->SetAtInteger("Flags", flags);
CPDF_Array* pBBox = FX_NEW CPDF_Array;
for (int i = 0; i < 4; i ++) {
pBBox->AddInteger(bbox[i]);
}
pFontDesc->SetAt("FontBBox", pBBox);
pFontDesc->SetAtInteger("ItalicAngle", italicangle);
pFontDesc->SetAtInteger("Ascent", ascend);
pFontDesc->SetAtInteger("Descent", descend);
pFontDesc->SetAtInteger("CapHeight", capheight);
pFontDesc->SetAtInteger("StemV", pLogFont->lfWeight / 5);
AddIndirectObject(pFontDesc);
pFontDict->SetAtReference("FontDescriptor", this, pFontDesc);
hFont = SelectObject(hDC, hFont);
DeleteObject(hFont);
DeleteDC(hDC);
return LoadFont(pBaseDict);
}
示例7: 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 == NULL) {
return NULL;
}
CPDF_Dictionary* pMainDict = pDoc->GetRoot()->GetDict("FDF");
if (!pdf_path.IsEmpty()) {
if (bSimpleFileSpec) {
CFX_WideString wsFilePath = FILESPEC_EncodeFileName(pdf_path);
pMainDict->SetAtString(FX_BSTRC("F"),
CFX_ByteString::FromUnicode(wsFilePath));
pMainDict->SetAtString(FX_BSTRC("UF"), PDF_EncodeText(wsFilePath));
} else {
CPDF_FileSpec filespec;
filespec.SetFileName(pdf_path);
pMainDict->SetAt("F", static_cast<CPDF_Object*>(filespec));
}
}
CPDF_Array* pFields = CPDF_Array::Create();
if (pFields == NULL) {
return NULL;
}
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 == NULL || pField->GetType() == CPDF_FormField::PushButton) {
continue;
}
FX_DWORD dwFlags = pField->GetFieldFlags();
if (dwFlags & 0x04)
continue;
auto it = std::find(fields.begin(), fields.end(), pField);
if (bIncludeOrExclude == (it != fields.end())) {
if ((dwFlags & 0x02) != 0 && pField->m_pDict->GetString("V").IsEmpty())
continue;
CFX_WideString fullname = GetFullName(pField->GetFieldDict());
CPDF_Dictionary* pFieldDict = CPDF_Dictionary::Create();
if (!pFieldDict)
return nullptr;
CPDF_String* pString = CPDF_String::Create(fullname);
if (!pString) {
pFieldDict->Release();
return nullptr;
}
pFieldDict->SetAt("T", pString);
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->Clone(TRUE));
}
pFields->Add(pFieldDict);
}
}
return pDoc;
}