本文整理汇总了C++中HPDF_Dict_New函数的典型用法代码示例。如果您正苦于以下问题:C++ HPDF_Dict_New函数的具体用法?C++ HPDF_Dict_New怎么用?C++ HPDF_Dict_New使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了HPDF_Dict_New函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HPDF_LinkAnnot_SetJavaScript
HPDF_LinkAnnot_SetJavaScript(HPDF_Annotation annot, HPDF_JavaScript javascript)
{
HPDF_Dict action;
HPDF_STATUS ret;
HPDF_PTRACE((" HPDF_LinkAnnot_SetJavaScript\n"));
if (!CheckSubType (annot, HPDF_ANNOT_LINK))
return HPDF_INVALID_ANNOTATION;
/* create action dictionary */
action = HPDF_Dict_New (annot->mmgr);
if (!action)
return HPDF_CheckError ( annot->error);
ret = HPDF_Dict_Add (annot, "A", action);
if (ret != HPDF_OK)
return HPDF_CheckError (annot->error);
ret += HPDF_Dict_Add (action, "JS", javascript);
ret += HPDF_Dict_AddName (action, "S", "JavaScript");
if (ret != HPDF_OK)
return HPDF_CheckError (annot->error);
return HPDF_OK;
}
示例2: HPDF_Pages_New
HPDF_Pages
HPDF_Pages_New (HPDF_MMgr mmgr,
HPDF_Pages parent,
HPDF_Xref xref)
{
HPDF_STATUS ret = HPDF_OK;
HPDF_Pages pages;
HPDF_PTRACE((" HPDF_Pages_New\n"));
pages = HPDF_Dict_New (mmgr);
if (!pages)
return NULL;
pages->header.obj_class |= HPDF_OSUBCLASS_PAGES;
pages->before_write_fn = Pages_BeforeWrite;
if (HPDF_Xref_Add (xref, pages) != HPDF_OK)
return NULL;
/* add requiered elements */
ret += HPDF_Dict_AddName (pages, "Type", "Pages");
ret += HPDF_Dict_Add (pages, "Kids", HPDF_Array_New (pages->mmgr));
ret += HPDF_Dict_Add (pages, "Count", HPDF_Number_New (pages->mmgr, 0));
if (ret == HPDF_OK && parent)
ret += HPDF_Pages_AddKids (parent, pages);
if (ret != HPDF_OK)
return NULL;
return pages;
}
示例3: HPDF_URILinkAnnot_New
HPDF_Annotation
HPDF_URILinkAnnot_New (HPDF_MMgr mmgr,
HPDF_Xref xref,
HPDF_Rect rect,
const char *uri)
{
HPDF_Annotation annot;
HPDF_Dict action;
HPDF_STATUS ret;
HPDF_PTRACE((" HPDF_URILinkAnnot_New\n"));
annot = HPDF_Annotation_New (mmgr, xref, HPDF_ANNOT_LINK, rect);
if (!annot)
return NULL;
/* create action dictionary */
action = HPDF_Dict_New (mmgr);
if (!action)
return NULL;
ret = HPDF_Dict_Add (annot, "A", action);
if (ret != HPDF_OK)
return NULL;
ret += HPDF_Dict_AddName (action, "Type", "Action");
ret += HPDF_Dict_AddName (action, "S", "URI");
ret += HPDF_Dict_Add (action, "URI", HPDF_String_New (mmgr, uri, NULL));
if (ret != HPDF_OK)
return NULL;
return annot;
}
示例4: HPDF_NameTree_New
HPDF_NameTree
HPDF_NameTree_New (HPDF_MMgr mmgr,
HPDF_Xref xref)
{
HPDF_STATUS ret = HPDF_OK;
HPDF_NameTree ntree;
HPDF_Array items;
HPDF_PTRACE (" HPDF_NameTree_New\n");
ntree = HPDF_Dict_New (mmgr);
if (!ntree)
return NULL;
if (HPDF_Xref_Add (xref, ntree) != HPDF_OK)
return NULL;
ntree->header.obj_class |= HPDF_OSUBCLASS_NAMETREE;
items = HPDF_Array_New (mmgr);
if (!ntree)
return NULL;
ret += HPDF_Dict_Add (ntree, "Names", items);
if (ret != HPDF_OK)
return NULL;
return ntree;
}
示例5: HPDF_Catalog_New
HPDF_Catalog
HPDF_Catalog_New (HPDF_MMgr mmgr,
HPDF_Xref xref)
{
HPDF_Catalog catalog;
HPDF_STATUS ret = 0;
catalog = HPDF_Dict_New (mmgr);
if (!catalog)
return NULL;
catalog->header.obj_class |= HPDF_OSUBCLASS_CATALOG;
if (HPDF_Xref_Add (xref, catalog) != HPDF_OK)
return NULL;
/* add requiered elements */
ret += HPDF_Dict_AddName (catalog, "Type", "Catalog");
ret += HPDF_Dict_Add (catalog, "Pages", HPDF_Pages_New (mmgr, NULL, xref));
if (ret != HPDF_OK)
return NULL;
return catalog;
}
示例6: HPDF_3DAnnotExData_New
HPDF_ExData
HPDF_3DAnnotExData_New(HPDF_MMgr mmgr,
HPDF_Xref xref)
{
HPDF_ExData exdata;
HPDF_STATUS ret = HPDF_OK;
HPDF_PTRACE (" HPDF_ExData_New\n");
exdata = HPDF_Dict_New (mmgr);
if (!exdata)
return NULL;
if (HPDF_Xref_Add (xref, exdata) != HPDF_OK)
return NULL;
ret += HPDF_Dict_AddName (exdata, "Type", "ExData");
ret += HPDF_Dict_AddName (exdata, "Subtype", "3DM");
if (ret != HPDF_OK)
return NULL;
return exdata;
}
示例7: HPDF_EncryptDict_New
HPDF_EncryptDict
HPDF_EncryptDict_New (HPDF_MMgr mmgr,
HPDF_Xref xref)
{
HPDF_Encrypt attr;
HPDF_EncryptDict dict;
HPDF_PTRACE((" HPDF_EncryptDict_New\n"));
dict = HPDF_Dict_New (mmgr);
if (!dict)
return NULL;
dict->header.obj_class |= HPDF_OSUBCLASS_ENCRYPT;
dict->free_fn = HPDF_EncryptDict_OnFree;
attr = HPDF_GetMem (dict->mmgr, sizeof(HPDF_Encrypt_Rec));
if (!attr) {
HPDF_Dict_Free (dict);
return NULL;
}
dict->attr = attr;
HPDF_Encrypt_Init (attr);
if (HPDF_Xref_Add (xref, dict) != HPDF_OK)
return NULL;
return dict;
}
示例8: HPDF_EXPORT
HPDF_EXPORT(HPDF_STATUS) HPDF_3DView_SetOrthogonalProjection(HPDF_Dict view, HPDF_REAL mag)
{
HPDF_STATUS ret = HPDF_OK;
HPDF_Dict projection;
HPDF_PTRACE ((" HPDF_3DView_SetOrthogonalProjection\n"));
if (view == NULL || mag <= 0) {
return HPDF_INVALID_U3D_DATA;
}
projection = HPDF_Dict_New (view->mmgr);
if (!projection) {
return HPDF_Error_GetCode (view->error);
}
ret = HPDF_Dict_AddName (projection, "Subtype", "O");
if (ret != HPDF_OK) {
HPDF_Dict_Free (projection);
return ret;
}
ret = HPDF_Dict_AddReal (projection, "OS", mag);
if (ret != HPDF_OK) {
HPDF_Dict_Free (projection);
return ret;
}
ret = HPDF_Dict_Add (view, "P", projection);
if (ret != HPDF_OK) {
HPDF_Dict_Free (projection);
return ret;
}
return ret;
}
示例9: AddResource
HPDF_STATUS
AddResource (HPDF_Page page)
{
HPDF_STATUS ret = HPDF_OK;
HPDF_Dict resource;
HPDF_Array procset;
HPDF_PTRACE((" HPDF_Page_AddResource\n"));
resource = HPDF_Dict_New (page->mmgr);
if (!resource)
return HPDF_Error_GetCode (page->error);
/* althoth ProcSet-entry is obsolete, add it to resouce for
* compatibility
*/
ret += HPDF_Dict_Add (page, "Resources", resource);
procset = HPDF_Array_New (page->mmgr);
if (!procset)
return HPDF_Error_GetCode (page->error);
ret += HPDF_Dict_Add (resource, "ProcSet", procset);
ret += HPDF_Array_Add (procset, HPDF_Name_New (page->mmgr, "PDF"));
ret += HPDF_Array_Add (procset, HPDF_Name_New (page->mmgr, "Text"));
ret += HPDF_Array_Add (procset, HPDF_Name_New (page->mmgr, "ImageB"));
ret += HPDF_Array_Add (procset, HPDF_Name_New (page->mmgr, "ImageC"));
ret += HPDF_Array_Add (procset, HPDF_Name_New (page->mmgr, "ImageI"));
return ret;
}
示例10: HPDF_EmbeddedFile_New
HPDF_EmbeddedFile
HPDF_EmbeddedFile_New (HPDF_MMgr mmgr,
HPDF_Xref xref,
const char *file)
{
HPDF_STATUS ret = HPDF_OK;
HPDF_Dict ef; /* the dictionary for the embedded file: /Type /EF */
HPDF_String name; /* the name of the file: /F (name) */
HPDF_Dict eff; /* ef has an /EF <<blah>> key - this is it */
HPDF_Dict filestream; /* the stream that /EF <</F _ _ R>> refers to */
HPDF_Stream stream;
ef = HPDF_Dict_New (mmgr);
if (!ef)
return NULL;
if (HPDF_Xref_Add (xref, ef) != HPDF_OK)
return NULL;
filestream = HPDF_DictStream_New (mmgr, xref);
if (!filestream)
return NULL;
stream = HPDF_FileReader_New (mmgr, file);
if (!stream)
return NULL;
HPDF_Stream_Free(filestream->stream);
filestream->stream = stream;
filestream->filter = HPDF_STREAM_FILTER_FLATE_DECODE;
eff = HPDF_Dict_New (mmgr);
if (!eff)
return NULL;
name = HPDF_String_New (mmgr, file, NULL);
if (!name)
return NULL;
ret += HPDF_Dict_AddName (ef, "Type", "F");
ret += HPDF_Dict_Add (ef, "F", name);
ret += HPDF_Dict_Add (ef, "EF", eff);
ret += HPDF_Dict_Add (eff, "F", filestream);
if (ret != HPDF_OK)
return NULL;
return ef;
}
示例11: HPDF_Page_New
HPDF_Page
HPDF_Page_New (HPDF_MMgr mmgr,
HPDF_Xref xref)
{
HPDF_STATUS ret;
HPDF_PageAttr attr;
HPDF_Page page;
HPDF_PTRACE((" HPDF_Page_New\n"));
page = HPDF_Dict_New (mmgr);
if (!page)
return NULL;
page->header.obj_class |= HPDF_OSUBCLASS_PAGE;
page->free_fn = Page_OnFree;
page->before_write_fn = Page_BeforeWrite;
attr = HPDF_GetMem (page->mmgr, sizeof(HPDF_PageAttr_Rec));
if (!attr) {
HPDF_Dict_Free (page);
return NULL;
}
page->attr = attr;
HPDF_MemSet (attr, 0, sizeof(HPDF_PageAttr_Rec));
attr->gmode = HPDF_GMODE_PAGE_DESCRIPTION;
attr->cur_pos = HPDF_ToPoint (0, 0);
attr->text_pos = HPDF_ToPoint (0, 0);
ret = HPDF_Xref_Add (xref, page);
if (ret != HPDF_OK)
return NULL;
attr->gstate = HPDF_GState_New (page->mmgr, NULL);
attr->contents = HPDF_DictStream_New (page->mmgr, xref);
if (!attr->gstate || !attr->contents)
return NULL;
attr->stream = attr->contents->stream;
attr->xref = xref;
/* add requiered elements */
ret += HPDF_Dict_AddName (page, "Type", "Page");
ret += HPDF_Dict_Add (page, "MediaBox", HPDF_Box_Array_New (page->mmgr,
HPDF_ToBox (0, 0, (HPDF_INT16)(HPDF_DEF_PAGE_WIDTH), (HPDF_INT16)(HPDF_DEF_PAGE_HEIGHT))));
ret += HPDF_Dict_Add (page, "Contents", attr->contents);
ret += AddResource (page);
if (ret != HPDF_OK)
return NULL;
return page;
}
示例12: HPDF_Xref_New
HPDF_Xref
HPDF_Xref_New (HPDF_MMgr mmgr,
HPDF_UINT32 offset)
{
HPDF_Xref xref;
HPDF_XrefEntry new_entry;
HPDF_PTRACE((" HPDF_Xref_New\n"));
xref = (HPDF_Xref)HPDF_GetMem (mmgr, sizeof(HPDF_Xref_Rec));
if (!xref)
return NULL;
HPDF_MemSet (xref, 0, sizeof(HPDF_Xref_Rec));
xref->mmgr = mmgr;
xref->error = mmgr->error;
xref->start_offset = offset;
xref->entries = HPDF_List_New (mmgr, HPDF_DEFALUT_XREF_ENTRY_NUM);
if (!xref->entries)
goto Fail;
xref->addr = 0;
if (xref->start_offset == 0) {
new_entry = (HPDF_XrefEntry)HPDF_GetMem (mmgr,
sizeof(HPDF_XrefEntry_Rec));
if (!new_entry)
goto Fail;
if (HPDF_List_Add (xref->entries, new_entry) != HPDF_OK) {
HPDF_FreeMem (mmgr, new_entry);
goto Fail;
}
/* add first entry which is free entry and whose generation
* number is 0
*/
new_entry->entry_typ = HPDF_FREE_ENTRY;
new_entry->byte_offset = 0;
new_entry->gen_no = HPDF_MAX_GENERATION_NUM;
new_entry->obj = NULL;
}
xref->trailer = HPDF_Dict_New (mmgr);
if (!xref->trailer)
goto Fail;
return xref;
Fail:
HPDF_PTRACE((" HPDF_Xref_New failed\n"));
HPDF_Xref_Free (xref);
return NULL;
}
示例13: HPDF_PageLabel_New
HPDF_Dict
HPDF_PageLabel_New (HPDF_Doc pdf,
HPDF_PageNumStyle style,
HPDF_INT first_page,
const char *prefix)
{
HPDF_Dict obj = HPDF_Dict_New (pdf->mmgr);
HPDF_PTRACE ((" HPDF_PageLabel_New\n"));
if (!obj)
return NULL;
switch (style) {
case HPDF_PAGE_NUM_STYLE_DECIMAL:
if (HPDF_Dict_AddName (obj, "S", "D") != HPDF_OK)
goto Fail;
break;
case HPDF_PAGE_NUM_STYLE_UPPER_ROMAN:
if (HPDF_Dict_AddName (obj, "S", "R") != HPDF_OK)
goto Fail;
break;
case HPDF_PAGE_NUM_STYLE_LOWER_ROMAN:
if (HPDF_Dict_AddName (obj, "S", "r") != HPDF_OK)
goto Fail;
break;
case HPDF_PAGE_NUM_STYLE_UPPER_LETTERS:
if (HPDF_Dict_AddName (obj, "S", "A") != HPDF_OK)
goto Fail;
break;
case HPDF_PAGE_NUM_STYLE_LOWER_LETTERS:
if (HPDF_Dict_AddName (obj, "S", "a") != HPDF_OK)
goto Fail;
break;
default:
HPDF_SetError (&pdf->error, HPDF_PAGE_NUM_STYLE_OUT_OF_RANGE,
(HPDF_STATUS)style);
goto Fail;
}
if (prefix && prefix[0] != 0)
if (HPDF_Dict_Add (obj, "P", HPDF_String_New (pdf->mmgr, prefix,
pdf->def_encoder)) != HPDF_OK)
goto Fail;
if (first_page != 0)
if (HPDF_Dict_AddNumber (obj, "St", first_page) != HPDF_OK)
goto Fail;
return obj;
Fail:
HPDF_Dict_Free (obj);
return NULL;
}
示例14: HPDF_Page_GetLocalFontName
const char*
HPDF_Page_GetLocalFontName (HPDF_Page page,
HPDF_Font font)
{
HPDF_PageAttr attr = (HPDF_PageAttr )page->attr;
const char *key;
HPDF_PTRACE((" HPDF_Page_GetLocalFontName\n"));
/* whether check font-resource exists. when it does not exists,
* create font-resource
* 2006.07.21 Fixed a problem which may cause a memory leak.
*/
if (!attr->fonts) {
HPDF_Dict resources;
HPDF_Dict fonts;
resources = HPDF_Page_GetInheritableItem (page, "Resources",
HPDF_OCLASS_DICT);
if (!resources)
return NULL;
fonts = HPDF_Dict_New (page->mmgr);
if (!fonts)
return NULL;
if (HPDF_Dict_Add (resources, "Font", fonts) != HPDF_OK)
return NULL;
attr->fonts = fonts;
}
/* search font-object from font-resource */
key = HPDF_Dict_GetKeyByObj (attr->fonts, font);
if (!key) {
/* if the font is not resisterd in font-resource, register font to
* font-resource.
*/
char fontName[HPDF_LIMIT_MAX_NAME_LEN + 1];
char *ptr;
char *end_ptr = fontName + HPDF_LIMIT_MAX_NAME_LEN;
ptr = (char *)HPDF_StrCpy (fontName, "F", end_ptr);
HPDF_IToA (ptr, attr->fonts->list->count + 1, end_ptr);
if (HPDF_Dict_Add (attr->fonts, fontName, font) != HPDF_OK)
return NULL;
key = HPDF_Dict_GetKeyByObj (attr->fonts, font);
}
return key;
}
示例15: HPDF_Page_GetExtGStateName
const char*
HPDF_Page_GetExtGStateName (HPDF_Page page,
HPDF_ExtGState state)
{
HPDF_PageAttr attr = (HPDF_PageAttr )page->attr;
const char *key;
HPDF_PTRACE((" HPDF_Page_GetExtGStateName\n"));
if (!attr->ext_gstates) {
HPDF_Dict resources;
HPDF_Dict ext_gstates;
resources = HPDF_Page_GetInheritableItem (page, "Resources",
HPDF_OCLASS_DICT);
if (!resources)
return NULL;
ext_gstates = HPDF_Dict_New (page->mmgr);
if (!ext_gstates)
return NULL;
if (HPDF_Dict_Add (resources, "ExtGState", ext_gstates) != HPDF_OK)
return NULL;
attr->ext_gstates = ext_gstates;
}
/* search ext_gstate-object from ext_gstate-resource */
key = HPDF_Dict_GetKeyByObj (attr->ext_gstates, state);
if (!key) {
/* if the ext-gstate is not resisterd in ext-gstate resource, register
* to ext-gstate resource.
*/
char ext_gstate_name[HPDF_LIMIT_MAX_NAME_LEN + 1];
char *ptr;
char *end_ptr = ext_gstate_name + HPDF_LIMIT_MAX_NAME_LEN;
ptr = (char *)HPDF_StrCpy (ext_gstate_name, "E", end_ptr);
HPDF_IToA (ptr, attr->ext_gstates->list->count + 1, end_ptr);
if (HPDF_Dict_Add (attr->ext_gstates, ext_gstate_name, state) != HPDF_OK)
return NULL;
key = HPDF_Dict_GetKeyByObj (attr->ext_gstates, state);
}
return key;
}