本文整理汇总了C++中CPDF_Dictionary::SetAtName方法的典型用法代码示例。如果您正苦于以下问题:C++ CPDF_Dictionary::SetAtName方法的具体用法?C++ CPDF_Dictionary::SetAtName怎么用?C++ CPDF_Dictionary::SetAtName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CPDF_Dictionary
的用法示例。
在下文中一共展示了CPDF_Dictionary::SetAtName方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetImage
void CPDF_Image::SetImage(const CFX_DIBitmap* pBitmap,
int32_t iCompress,
IFX_FileWrite* pFileWrite,
IFX_FileRead* pFileRead,
const CFX_DIBitmap* pMask,
const CPDF_ImageSetParam* pParam) {
int32_t BitmapWidth = pBitmap->GetWidth();
int32_t BitmapHeight = pBitmap->GetHeight();
if (BitmapWidth < 1 || BitmapHeight < 1) {
return;
}
uint8_t* src_buf = pBitmap->GetBuffer();
int32_t src_pitch = pBitmap->GetPitch();
int32_t bpp = pBitmap->GetBPP();
FX_BOOL bUseMatte =
pParam && pParam->pMatteColor && (pBitmap->GetFormat() == FXDIB_Argb);
CPDF_Dictionary* pDict = new CPDF_Dictionary;
pDict->SetAtName("Type", "XObject");
pDict->SetAtName("Subtype", "Image");
pDict->SetAtInteger("Width", BitmapWidth);
pDict->SetAtInteger("Height", BitmapHeight);
uint8_t* dest_buf = NULL;
FX_STRSIZE dest_pitch = 0, dest_size = 0, opType = -1;
if (bpp == 1) {
int32_t reset_a = 0, reset_r = 0, reset_g = 0, reset_b = 0;
int32_t set_a = 0, set_r = 0, set_g = 0, set_b = 0;
if (!pBitmap->IsAlphaMask()) {
ArgbDecode(pBitmap->GetPaletteArgb(0), reset_a, reset_r, reset_g,
reset_b);
ArgbDecode(pBitmap->GetPaletteArgb(1), set_a, set_r, set_g, set_b);
}
if (set_a == 0 || reset_a == 0) {
pDict->SetAt("ImageMask", new CPDF_Boolean(TRUE));
if (reset_a == 0) {
CPDF_Array* pArray = new CPDF_Array;
pArray->AddInteger(1);
pArray->AddInteger(0);
pDict->SetAt("Decode", pArray);
}
} else {
CPDF_Array* pCS = new CPDF_Array;
pCS->AddName("Indexed");
pCS->AddName("DeviceRGB");
pCS->AddInteger(1);
CFX_ByteString ct;
FX_CHAR* pBuf = ct.GetBuffer(6);
pBuf[0] = (FX_CHAR)reset_r;
pBuf[1] = (FX_CHAR)reset_g;
pBuf[2] = (FX_CHAR)reset_b;
pBuf[3] = (FX_CHAR)set_r;
pBuf[4] = (FX_CHAR)set_g;
pBuf[5] = (FX_CHAR)set_b;
ct.ReleaseBuffer(6);
pCS->Add(new CPDF_String(ct, TRUE));
pDict->SetAt("ColorSpace", pCS);
}
pDict->SetAtInteger("BitsPerComponent", 1);
dest_pitch = (BitmapWidth + 7) / 8;
if ((iCompress & 0x03) == PDF_IMAGE_NO_COMPRESS) {
opType = 1;
} else {
opType = 0;
}
} else if (bpp == 8) {
int32_t iPalette = pBitmap->GetPaletteSize();
if (iPalette > 0) {
CPDF_Array* pCS = new CPDF_Array;
m_pDocument->AddIndirectObject(pCS);
pCS->AddName("Indexed");
pCS->AddName("DeviceRGB");
pCS->AddInteger(iPalette - 1);
uint8_t* pColorTable = FX_Alloc2D(uint8_t, iPalette, 3);
uint8_t* ptr = pColorTable;
for (int32_t i = 0; i < iPalette; i++) {
FX_DWORD argb = pBitmap->GetPaletteArgb(i);
ptr[0] = (uint8_t)(argb >> 16);
ptr[1] = (uint8_t)(argb >> 8);
ptr[2] = (uint8_t)argb;
ptr += 3;
}
CPDF_Stream* pCTS =
new CPDF_Stream(pColorTable, iPalette * 3, new CPDF_Dictionary);
m_pDocument->AddIndirectObject(pCTS);
pCS->AddReference(m_pDocument, pCTS);
pDict->SetAtReference("ColorSpace", m_pDocument, pCS);
} else {
示例2: AddTerminalField
CPDF_FormField* CPDF_InterForm::AddTerminalField(CPDF_Dictionary* pFieldDict) {
if (!pFieldDict->KeyExist("T"))
return nullptr;
CPDF_Dictionary* pDict = pFieldDict;
CFX_WideString csWName = FPDF_GetFullName(pFieldDict);
if (csWName.IsEmpty())
return nullptr;
CPDF_FormField* pField = nullptr;
pField = m_pFieldTree->GetField(csWName);
if (!pField) {
CPDF_Dictionary* pParent = pFieldDict;
if (!pFieldDict->KeyExist("T") &&
pFieldDict->GetStringBy("Subtype") == "Widget") {
pParent = pFieldDict->GetDictBy("Parent");
if (!pParent)
pParent = pFieldDict;
}
if (pParent && pParent != pFieldDict && !pParent->KeyExist("FT")) {
if (pFieldDict->KeyExist("FT")) {
CPDF_Object* pFTValue = pFieldDict->GetDirectObjectBy("FT");
if (pFTValue)
pParent->SetAt("FT", pFTValue->Clone());
}
if (pFieldDict->KeyExist("Ff")) {
CPDF_Object* pFfValue = pFieldDict->GetDirectObjectBy("Ff");
if (pFfValue)
pParent->SetAt("Ff", pFfValue->Clone());
}
}
pField = new CPDF_FormField(this, pParent);
CPDF_Object* pTObj = pDict->GetObjectBy("T");
if (ToReference(pTObj)) {
CPDF_Object* pClone = pTObj->CloneDirectObject();
if (pClone)
pDict->SetAt("T", pClone);
else
pDict->SetAtName("T", "");
}
m_pFieldTree->SetField(csWName, pField);
}
CPDF_Array* pKids = pFieldDict->GetArrayBy("Kids");
if (!pKids) {
if (pFieldDict->GetStringBy("Subtype") == "Widget")
AddControl(pField, pFieldDict);
} else {
for (size_t i = 0; i < pKids->GetCount(); i++) {
CPDF_Dictionary* pKid = pKids->GetDictAt(i);
if (!pKid)
continue;
if (pKid->GetStringBy("Subtype") != "Widget")
continue;
AddControl(pField, pKid);
}
}
return pField;
}
示例3: Handle_BeginImage
void CPDF_StreamContentParser::Handle_BeginImage()
{
FX_FILESIZE savePos = m_pSyntax->GetPos();
CPDF_Dictionary* pDict = CPDF_Dictionary::Create();
while (1) {
CPDF_StreamParser::SyntaxType type = m_pSyntax->ParseNextElement();
if (type == CPDF_StreamParser::Keyword) {
CFX_ByteString bsKeyword(m_pSyntax->GetWordBuf(), m_pSyntax->GetWordSize());
if (bsKeyword != FX_BSTRC("ID")) {
m_pSyntax->SetPos(savePos);
pDict->Release();
return;
}
}
if (type != CPDF_StreamParser::Name) {
break;
}
CFX_ByteString key((const FX_CHAR*)m_pSyntax->GetWordBuf() + 1, m_pSyntax->GetWordSize() - 1);
CPDF_Object* pObj = m_pSyntax->ReadNextObject();
if (!key.IsEmpty()) {
pDict->SetAt(key, pObj, m_pDocument);
} else if (pObj) {
pObj->Release();
}
}
_PDF_ReplaceAbbr(pDict);
CPDF_Object* pCSObj = NULL;
if (pDict->KeyExist(FX_BSTRC("ColorSpace"))) {
pCSObj = pDict->GetElementValue(FX_BSTRC("ColorSpace"));
if (pCSObj->GetType() == PDFOBJ_NAME) {
CFX_ByteString name = pCSObj->GetString();
if (name != FX_BSTRC("DeviceRGB") && name != FX_BSTRC("DeviceGray") && name != FX_BSTRC("DeviceCMYK")) {
pCSObj = FindResourceObj(FX_BSTRC("ColorSpace"), name);
if (pCSObj && !pCSObj->GetObjNum()) {
pCSObj = pCSObj->Clone();
pDict->SetAt(FX_BSTRC("ColorSpace"), pCSObj, m_pDocument);
}
}
}
}
CPDF_Stream* pStream = m_pSyntax->ReadInlineStream(m_pDocument, pDict, pCSObj, m_Options.m_bDecodeInlineImage);
while (1) {
CPDF_StreamParser::SyntaxType type = m_pSyntax->ParseNextElement();
if (type == CPDF_StreamParser::EndOfData) {
break;
}
if (type != CPDF_StreamParser::Keyword) {
continue;
}
if (m_pSyntax->GetWordSize() == 2 && m_pSyntax->GetWordBuf()[0] == 'E' &&
m_pSyntax->GetWordBuf()[1] == 'I') {
break;
}
}
if (m_Options.m_bTextOnly) {
if (pStream) {
pStream->Release();
} else {
pDict->Release();
}
return;
}
pDict->SetAtName(FX_BSTRC("Subtype"), FX_BSTRC("Image"));
CPDF_ImageObject *pImgObj = AddImage(pStream, NULL, TRUE);
if (!pImgObj) {
if (pStream) {
pStream->Release();
} else {
pDict->Release();
}
}
}
示例4: AddMacFont
CPDF_Font* CPDF_Document::AddMacFont(CTFontRef pFont, FX_BOOL bVert, FX_BOOL bTranslateName)
{
CTFontRef font = (CTFontRef)pFont;
CTFontDescriptorRef descriptor = CTFontCopyFontDescriptor(font);
if (descriptor == NULL) {
return NULL;
}
CFX_ByteString basefont;
FX_BOOL bCJK = FALSE;
int flags = 0, italicangle = 0, ascend = 0, descend = 0, capheight = 0, bbox[4];
FXSYS_memset32(bbox, 0, sizeof(int) * 4);
CFArrayRef languages = (CFArrayRef)CTFontDescriptorCopyAttribute(descriptor, kCTFontLanguagesAttribute);
if (languages == NULL) {
CFRelease(descriptor);
return NULL;
}
CFX_DWordArray charSets;
charSets.Add(FXFONT_CHINESEBIG5_CHARSET);
charSets.Add(FXFONT_GB2312_CHARSET);
charSets.Add(FXFONT_HANGEUL_CHARSET);
charSets.Add(FXFONT_SHIFTJIS_CHARSET);
if (IsHasCharSet(languages, charSets)) {
bCJK = TRUE;
}
CFRelease(descriptor);
CFDictionaryRef traits = (CFDictionaryRef)CTFontCopyTraits(font);
if (traits == NULL) {
CFRelease(languages);
return NULL;
}
CFNumberRef sybolicTrait = (CFNumberRef)CFDictionaryGetValue(traits, kCTFontSymbolicTrait);
CTFontSymbolicTraits trait = 0;
CFNumberGetValue(sybolicTrait, kCFNumberSInt32Type, &trait);
if (trait & kCTFontItalicTrait) {
flags |= PDFFONT_ITALIC;
}
if (trait & kCTFontMonoSpaceTrait) {
flags |= PDFFONT_FIXEDPITCH;
}
if (trait & kCTFontModernSerifsClass) {
flags |= PDFFONT_SERIF;
}
if (trait & kCTFontScriptsClass) {
flags |= PDFFONT_SCRIPT;
}
CFNumberRef weightTrait = (CFNumberRef)CFDictionaryGetValue(traits, kCTFontWeightTrait);
Float32 weight = 0;
CFNumberGetValue(weightTrait, kCFNumberFloat32Type, &weight);
italicangle = CTFontGetSlantAngle(font);
ascend = CTFontGetAscent(font);
descend = CTFontGetDescent(font);
capheight = CTFontGetCapHeight(font);
CGRect box = CTFontGetBoundingBox(font);
bbox[0] = box.origin.x;
bbox[1] = box.origin.y;
bbox[2] = box.origin.x + box.size.width;
bbox[3] = box.origin.y + box.size.height;
if (bTranslateName && bCJK) {
CFStringRef postName = CTFontCopyPostScriptName(font);
_CFString2CFXByteString(postName, basefont);
CFRelease(postName);
}
if (basefont.IsEmpty()) {
CFStringRef fullName = CTFontCopyFullName(font);
_CFString2CFXByteString(fullName, basefont);
CFRelease(fullName);
}
basefont.Replace(" ", "");
CPDF_Dictionary* pFontDict = NULL;
CPDF_Dictionary* pBaseDict = FX_NEW CPDF_Dictionary;
pFontDict = pBaseDict;
if (!bCJK) {
charSets.RemoveAll();
charSets.Add(FXFONT_ANSI_CHARSET);
charSets.Add(FXFONT_DEFAULT_CHARSET);
charSets.Add(FXFONT_SYMBOL_CHARSET);
if (IsHasCharSet(languages, charSets)) {
charSets.RemoveAll();
charSets.Add(FXFONT_SYMBOL_CHARSET);
if (IsHasCharSet(languages, charSets)) {
flags |= PDFFONT_SYMBOLIC;
} else {
flags |= PDFFONT_NONSYMBOLIC;
}
pBaseDict->SetAtName(FX_BSTRC("Encoding"), "WinAnsiEncoding");
} else {
flags |= PDFFONT_NONSYMBOLIC;
int i;
for (i = 0; i < sizeof g_FX_CharsetUnicodes / sizeof(FX_CharsetUnicodes); i ++) {
charSets.RemoveAll();
charSets.Add(g_FX_CharsetUnicodes[i].m_Charset);
if (IsHasCharSet(languages, charSets)) {
break;
}
}
if (i < sizeof g_FX_CharsetUnicodes / sizeof(FX_CharsetUnicodes)) {
CPDF_Dictionary* pEncoding = FX_NEW CPDF_Dictionary;
pEncoding->SetAtName(FX_BSTRC("BaseEncoding"), "WinAnsiEncoding");
CPDF_Array* pArray = FX_NEW CPDF_Array;
pArray->AddInteger(128);
//.........这里部分代码省略.........
示例5: AddFont
CPDF_Font* CPDF_Document::AddFont(CFX_Font* pFont, int charset, FX_BOOL bVert)
{
if (pFont == NULL) {
return NULL;
}
FX_BOOL bCJK = charset == FXFONT_CHINESEBIG5_CHARSET || charset == FXFONT_GB2312_CHARSET ||
charset == FXFONT_HANGEUL_CHARSET || charset == FXFONT_SHIFTJIS_CHARSET;
CFX_ByteString basefont = pFont->GetFamilyName();
basefont.Replace(" ", "");
int flags = 0;
if (pFont->IsBold()) {
flags |= PDFFONT_FORCEBOLD;
}
if (pFont->IsItalic()) {
flags |= PDFFONT_ITALIC;
}
if (pFont->IsFixedWidth()) {
flags |= PDFFONT_FIXEDPITCH;
}
CPDF_Dictionary* pBaseDict = FX_NEW CPDF_Dictionary;
pBaseDict->SetAtName("Type", "Font");
IFX_FontEncoding* pEncoding = FXGE_CreateUnicodeEncoding(pFont);
CPDF_Dictionary* pFontDict = pBaseDict;
if (!bCJK) {
CPDF_Array* pWidths = FX_NEW CPDF_Array;
int charcode;
for (charcode = 32; charcode < 128; charcode ++) {
int glyph_index = pEncoding->GlyphFromCharCode(charcode);
int char_width = pFont->GetGlyphWidth(glyph_index);
pWidths->AddInteger(char_width);
}
if (charset == FXFONT_ANSI_CHARSET || charset == FXFONT_DEFAULT_CHARSET ||
charset == FXFONT_SYMBOL_CHARSET) {
if (charset == FXFONT_SYMBOL_CHARSET) {
flags |= PDFFONT_SYMBOLIC;
} else {
flags |= PDFFONT_NONSYMBOLIC;
}
pBaseDict->SetAtName(FX_BSTRC("Encoding"), "WinAnsiEncoding");
for (charcode = 128; charcode <= 255; charcode ++) {
int glyph_index = pEncoding->GlyphFromCharCode(charcode);
int char_width = pFont->GetGlyphWidth(glyph_index);
pWidths->AddInteger(char_width);
}
} else {
flags |= PDFFONT_NONSYMBOLIC;
int i;
for (i = 0; i < sizeof g_FX_CharsetUnicodes / sizeof(FX_CharsetUnicodes); i ++)
if (g_FX_CharsetUnicodes[i].m_Charset == charset) {
break;
}
if (i < sizeof g_FX_CharsetUnicodes / sizeof(FX_CharsetUnicodes)) {
CPDF_Dictionary* pEncodingDict = FX_NEW CPDF_Dictionary;
pEncodingDict->SetAtName(FX_BSTRC("BaseEncoding"), "WinAnsiEncoding");
CPDF_Array* pArray = FX_NEW CPDF_Array;
pArray->AddInteger(128);
const FX_WCHAR* pUnicodes = g_FX_CharsetUnicodes[i].m_pUnicodes;
for (int j = 0; j < 128; j ++) {
CFX_ByteString name = PDF_AdobeNameFromUnicode(pUnicodes[j]);
if (name.IsEmpty()) {
pArray->AddName(FX_BSTRC(".notdef"));
} else {
pArray->AddName(name);
}
int glyph_index = pEncoding->GlyphFromCharCode(pUnicodes[j]);
int char_width = pFont->GetGlyphWidth(glyph_index);
pWidths->AddInteger(char_width);
}
pEncodingDict->SetAt(FX_BSTRC("Differences"), pArray);
AddIndirectObject(pEncodingDict);
pBaseDict->SetAtReference(FX_BSTRC("Encoding"), this, pEncodingDict);
}
}
if (pFont->IsBold() && pFont->IsItalic()) {
basefont += ",BoldItalic";
} else if (pFont->IsBold()) {
basefont += ",Bold";
} else if (pFont->IsItalic()) {
basefont += ",Italic";
}
pBaseDict->SetAtName("Subtype", "TrueType");
pBaseDict->SetAtName("BaseFont", basefont);
pBaseDict->SetAtNumber("FirstChar", 32);
pBaseDict->SetAtNumber("LastChar", 255);
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 (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;
//.........这里部分代码省略.........
示例6: AddWindowsFont
CPDF_Font* CPDF_Document::AddWindowsFont(LOGFONTA* pLogFont, FX_BOOL bVert, FX_BOOL bTranslateName)
{
pLogFont->lfHeight = -1000;
pLogFont->lfWidth = 0;
HGDIOBJ hFont = CreateFontIndirectA(pLogFont);
HDC hDC = CreateCompatibleDC(NULL);
hFont = SelectObject(hDC, hFont);
int tm_size = GetOutlineTextMetrics(hDC, 0, NULL);
if (tm_size == 0) {
hFont = SelectObject(hDC, hFont);
DeleteObject(hFont);
DeleteDC(hDC);
return NULL;
}
LPBYTE tm_buf = FX_Alloc(BYTE, tm_size);
OUTLINETEXTMETRIC* ptm = (OUTLINETEXTMETRIC*)tm_buf;
GetOutlineTextMetrics(hDC, tm_size, ptm);
int flags = 0, italicangle, ascend, descend, capheight, bbox[4];
if (pLogFont->lfItalic) {
flags |= PDFFONT_ITALIC;
}
if ((pLogFont->lfPitchAndFamily & 3) == FIXED_PITCH) {
flags |= PDFFONT_FIXEDPITCH;
}
if ((pLogFont->lfPitchAndFamily & 0xf8) == FF_ROMAN) {
flags |= PDFFONT_SERIF;
}
if ((pLogFont->lfPitchAndFamily & 0xf8) == FF_SCRIPT) {
flags |= PDFFONT_SCRIPT;
}
FX_BOOL bCJK = pLogFont->lfCharSet == CHINESEBIG5_CHARSET || pLogFont->lfCharSet == GB2312_CHARSET ||
pLogFont->lfCharSet == HANGEUL_CHARSET || pLogFont->lfCharSet == SHIFTJIS_CHARSET;
CFX_ByteString basefont;
if (bTranslateName && bCJK) {
basefont = _FPDF_GetPSNameFromTT(hDC);
}
if (basefont.IsEmpty()) {
basefont = pLogFont->lfFaceName;
}
italicangle = ptm->otmItalicAngle / 10;
ascend = ptm->otmrcFontBox.top;
descend = ptm->otmrcFontBox.bottom;
capheight = ptm->otmsCapEmHeight;
bbox[0] = ptm->otmrcFontBox.left;
bbox[1] = ptm->otmrcFontBox.bottom;
bbox[2] = ptm->otmrcFontBox.right;
bbox[3] = ptm->otmrcFontBox.top;
FX_Free(tm_buf);
basefont.Replace(" ", "");
CPDF_Dictionary* pBaseDict = FX_NEW CPDF_Dictionary;
pBaseDict->SetAtName("Type", "Font");
CPDF_Dictionary* pFontDict = pBaseDict;
if (!bCJK) {
if (pLogFont->lfCharSet == ANSI_CHARSET || pLogFont->lfCharSet == DEFAULT_CHARSET ||
pLogFont->lfCharSet == SYMBOL_CHARSET) {
if (pLogFont->lfCharSet == SYMBOL_CHARSET) {
flags |= PDFFONT_SYMBOLIC;
} else {
flags |= PDFFONT_NONSYMBOLIC;
}
pBaseDict->SetAtName(FX_BSTRC("Encoding"), "WinAnsiEncoding");
} else {
flags |= PDFFONT_NONSYMBOLIC;
int i;
for (i = 0; i < sizeof g_FX_CharsetUnicodes / sizeof(FX_CharsetUnicodes); i ++)
if (g_FX_CharsetUnicodes[i].m_Charset == pLogFont->lfCharSet) {
break;
}
if (i < sizeof g_FX_CharsetUnicodes / sizeof(FX_CharsetUnicodes)) {
CPDF_Dictionary* pEncoding = FX_NEW CPDF_Dictionary;
pEncoding->SetAtName(FX_BSTRC("BaseEncoding"), "WinAnsiEncoding");
CPDF_Array* pArray = FX_NEW CPDF_Array;
pArray->AddInteger(128);
const FX_WCHAR* pUnicodes = g_FX_CharsetUnicodes[i].m_pUnicodes;
for (int j = 0; j < 128; j ++) {
CFX_ByteString name = PDF_AdobeNameFromUnicode(pUnicodes[j]);
if (name.IsEmpty()) {
pArray->AddName(FX_BSTRC(".notdef"));
} else {
pArray->AddName(name);
}
}
pEncoding->SetAt(FX_BSTRC("Differences"), pArray);
AddIndirectObject(pEncoding);
pBaseDict->SetAtReference(FX_BSTRC("Encoding"), this, pEncoding);
}
}
if (pLogFont->lfWeight > FW_MEDIUM && pLogFont->lfItalic) {
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);
//.........这里部分代码省略.........
示例7: WriteAppearance
void CPDFSDK_Annot::WriteAppearance(const CFX_ByteString& sAPType, const CPDF_Rect& rcBBox,
const CPDF_Matrix& matrix, const CFX_ByteString& sContents,
const CFX_ByteString& sAPState)
{
ASSERT(m_pAnnot != NULL);
ASSERT(m_pAnnot->m_pAnnotDict != NULL);
CPDF_Dictionary* pAPDict = m_pAnnot->m_pAnnotDict->GetDict("AP");
if (!pAPDict)
{
pAPDict = FX_NEW CPDF_Dictionary;
m_pAnnot->m_pAnnotDict->SetAt("AP", pAPDict);
}
CPDF_Stream* pStream = NULL;
CPDF_Dictionary* pParentDict = NULL;
if (sAPState.IsEmpty())
{
pParentDict = pAPDict;
pStream = pAPDict->GetStream(sAPType);
}
else
{
CPDF_Dictionary* pAPTypeDict = pAPDict->GetDict(sAPType);
if (!pAPTypeDict)
{
pAPTypeDict = FX_NEW CPDF_Dictionary;
pAPDict->SetAt(sAPType, pAPTypeDict);
}
pParentDict = pAPTypeDict;
pStream = pAPTypeDict->GetStream(sAPState);
}
if (!pStream)
{
ASSERT(m_pPageView != NULL);
CPDF_Document* pDoc = m_pPageView->GetPDFDocument();
ASSERT(pDoc != NULL);
pStream = FX_NEW CPDF_Stream(NULL, 0, NULL);
FX_INT32 objnum = pDoc->AddIndirectObject(pStream);
//pAPDict->SetAtReference(sAPType, pDoc, objnum);
ASSERT(pParentDict != NULL);
pParentDict->SetAtReference(sAPType, pDoc, objnum);
}
CPDF_Dictionary * pStreamDict = pStream->GetDict();
if (!pStreamDict)
{
pStreamDict = FX_NEW CPDF_Dictionary;
pStreamDict->SetAtName("Type", "XObject");
pStreamDict->SetAtName("Subtype", "Form");
pStreamDict->SetAtInteger("FormType", 1);
pStream->InitStream(NULL,0,pStreamDict);
}
if (pStreamDict)
{
pStreamDict->SetAtMatrix("Matrix",matrix);
pStreamDict->SetAtRect("BBox", rcBBox);
}
pStream->SetData((FX_BYTE*)sContents.c_str(), sContents.GetLength(), FALSE, FALSE);
}
示例8: 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;
}
示例9: AddTerminalField
CPDF_FormField* CPDF_InterForm::AddTerminalField(CPDF_Dictionary* pFieldDict) {
if (!pFieldDict->KeyExist(FX_BSTRC("T"))) {
return NULL;
}
CPDF_Dictionary* pDict = pFieldDict;
CFX_WideString csWName = GetFullName(pFieldDict);
if (csWName.IsEmpty()) {
return NULL;
}
CPDF_FormField* pField = NULL;
pField = m_pFieldTree->GetField(csWName);
if (pField == NULL) {
CPDF_Dictionary* pParent = pFieldDict;
if (!pFieldDict->KeyExist(FX_BSTRC("T")) &&
pFieldDict->GetString(FX_BSTRC("Subtype")) == FX_BSTRC("Widget")) {
pParent = pFieldDict->GetDict(FX_BSTRC("Parent"));
if (!pParent) {
pParent = pFieldDict;
}
}
if (pParent && pParent != pFieldDict &&
!pParent->KeyExist(FX_BSTRC("FT"))) {
if (pFieldDict->KeyExist(FX_BSTRC("FT"))) {
CPDF_Object* pFTValue = pFieldDict->GetElementValue(FX_BSTRC("FT"));
if (pFTValue) {
pParent->SetAt(FX_BSTRC("FT"), pFTValue->Clone());
}
}
if (pFieldDict->KeyExist(FX_BSTRC("Ff"))) {
CPDF_Object* pFfValue = pFieldDict->GetElementValue(FX_BSTRC("Ff"));
if (pFfValue) {
pParent->SetAt(FX_BSTRC("Ff"), pFfValue->Clone());
}
}
}
pField = new CPDF_FormField(this, pParent);
CPDF_Object* pTObj = pDict->GetElement("T");
if (ToReference(pTObj)) {
CPDF_Object* pClone = pTObj->Clone(TRUE);
if (pClone)
pDict->SetAt("T", pClone);
else
pDict->SetAtName("T", "");
}
m_pFieldTree->SetField(csWName, pField);
}
CPDF_Array* pKids = pFieldDict->GetArray("Kids");
if (pKids == NULL) {
if (pFieldDict->GetString("Subtype") == "Widget") {
AddControl(pField, pFieldDict);
}
} else {
for (FX_DWORD i = 0; i < pKids->GetCount(); i++) {
CPDF_Dictionary* pKid = pKids->GetDict(i);
if (pKid == NULL) {
continue;
}
if (pKid->GetString("Subtype") != "Widget") {
continue;
}
AddControl(pField, pKid);
}
}
return pField;
}
示例10: if
//.........这里部分代码省略.........
CPDF_Dictionary* pPageXObject = pRes->GetDict("XObject");
if (!pPageXObject)
{
pPageXObject = FX_NEW CPDF_Dictionary;
pRes->SetAt("XObject", pPageXObject);
}
CFX_ByteString key = "";
int nStreams = ObjectArray.GetSize();
if (nStreams > 0)
{
for (int iKey = 0; /*iKey < 100*/; iKey++)
{
char sExtend[5] = {0};
FXSYS_itoa(iKey, sExtend, 10);
key = CFX_ByteString("FFT") + CFX_ByteString(sExtend);
if (!pPageXObject->KeyExist(key))
break;
}
}
SetPageContents(key, pPageDict, pDocument);
CPDF_Dictionary* pNewXORes = NULL;
if (!key.IsEmpty())
{
pPageXObject->SetAtReference(key, pDocument, dwObjNum);
CPDF_Dictionary* pNewOXbjectDic = pNewXObject->GetDict();
pNewXORes = FX_NEW CPDF_Dictionary;
pNewOXbjectDic->SetAt("Resources", pNewXORes);
pNewOXbjectDic->SetAtName("Type", "XObject");
pNewOXbjectDic->SetAtName("Subtype", "Form");
pNewOXbjectDic->SetAtInteger("FormType", 1);
pNewOXbjectDic->SetAtName("Name", "FRM");
CPDF_Rect rcBBox = pPageDict->GetRect("ArtBox");
pNewOXbjectDic->SetAtRect("BBox", rcBBox);
}
for (int i = 0; i < nStreams; i++)
{
CPDF_Dictionary* pAnnotDic = ObjectArray.GetAt(i);
if (!pAnnotDic)continue;
CPDF_Rect rcAnnot = pAnnotDic->GetRect("Rect");
rcAnnot.Normalize();
CFX_ByteString sAnnotState = pAnnotDic->GetString("AS");
CPDF_Dictionary* pAnnotAP = pAnnotDic->GetDict("AP");
if (!pAnnotAP)continue;
CPDF_Stream* pAPStream = pAnnotAP->GetStream("N");
if (!pAPStream)
{
CPDF_Dictionary* pAPDic = pAnnotAP->GetDict("N");
if (!pAPDic)continue;
if (!sAnnotState.IsEmpty())
{
pAPStream = pAPDic->GetStream(sAnnotState);
}
else
{
FX_POSITION pos = pAPDic->GetStartPos();