本文整理汇总了C++中pdf_dict_gets函数的典型用法代码示例。如果您正苦于以下问题:C++ pdf_dict_gets函数的具体用法?C++ pdf_dict_gets怎么用?C++ pdf_dict_gets使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pdf_dict_gets函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pdf_load_name_tree_imp
static void
pdf_load_name_tree_imp(pdf_obj *dict, pdf_document *xref, pdf_obj *node)
{
fz_context *ctx = xref->ctx;
pdf_obj *kids = pdf_dict_gets(node, "Kids");
pdf_obj *names = pdf_dict_gets(node, "Names");
int i;
if (kids && !pdf_dict_mark(node))
{
for (i = 0; i < pdf_array_len(kids); i++)
pdf_load_name_tree_imp(dict, xref, pdf_array_get(kids, i));
pdf_dict_unmark(node);
}
if (names)
{
for (i = 0; i + 1 < pdf_array_len(names); i += 2)
{
pdf_obj *key = pdf_array_get(names, i);
pdf_obj *val = pdf_array_get(names, i + 1);
if (pdf_is_string(key))
{
key = pdf_to_utf8_name(ctx, key);
pdf_dict_put(dict, key, val);
pdf_drop_obj(key);
}
else if (pdf_is_name(key))
{
pdf_dict_put(dict, key, val);
}
}
}
}
示例2: save_attachments
/* returns the number of attachments saved */
int save_attachments(int pageno, char *targetdir)
{
pdf_page *page = pdf_load_page(doc, pageno-1);
pdf_annot *annot;
int saved_count = 0;
for (annot = page->annots; annot ; annot = annot->next) {
pdf_obj *fs_obj = pdf_dict_gets(annot->obj, "FS");
if (fs_obj) {
pdf_obj *ef_obj;
char *name = basename(strdup(pdf_to_str_buf(pdf_dict_gets(fs_obj, "F"))));
ef_obj = pdf_dict_gets(fs_obj, "EF");
if (ef_obj) {
pdf_obj *f_obj = pdf_dict_gets(ef_obj, "F");
if (f_obj && pdf_is_indirect(f_obj)) {
static char pathname[PATH_MAX];
sprintf(pathname, "%s/%s", targetdir, name);
FILE *fout = fopen(pathname, "w");
if (!fout) {
fprintf(stderr, "extr: cannot write to file %s\n", pathname);
exit(1);
}
dump_stream(pdf_to_num(f_obj), fout);
fclose(fout);
saved_count++;
}
}
}
}
return saved_count;
}
示例3: pdf_load_type0_font
static pdf_font_desc *
pdf_load_type0_font(pdf_document *xref, pdf_obj *dict)
{
pdf_obj *dfonts;
pdf_obj *dfont;
pdf_obj *subtype;
pdf_obj *encoding;
pdf_obj *to_unicode;
dfonts = pdf_dict_gets(dict, "DescendantFonts");
if (!dfonts)
fz_throw(xref->ctx, "cid font is missing descendant fonts");
dfont = pdf_array_get(dfonts, 0);
subtype = pdf_dict_gets(dfont, "Subtype");
encoding = pdf_dict_gets(dict, "Encoding");
to_unicode = pdf_dict_gets(dict, "ToUnicode");
if (pdf_is_name(subtype) && !strcmp(pdf_to_name(subtype), "CIDFontType0"))
return load_cid_font(xref, dfont, encoding, to_unicode);
else if (pdf_is_name(subtype) && !strcmp(pdf_to_name(subtype), "CIDFontType2"))
return load_cid_font(xref, dfont, encoding, to_unicode);
else
fz_throw(xref->ctx, "syntaxerror: unknown cid font type");
return NULL; /* Stupid MSVC */
}
示例4: load_icc_based
static fz_colorspace *
load_icc_based(pdf_document *doc, pdf_obj *dict)
{
int n;
n = pdf_to_int(pdf_dict_gets(dict, "N"));
/* SumatraPDF: support alternate colorspaces for ICCBased */
if (pdf_dict_gets(dict, "Alternate"))
{
fz_colorspace *cs_alt = pdf_load_colorspace(doc, pdf_dict_gets(dict, "Alternate"));
if (cs_alt->n != n)
{
fz_drop_colorspace(doc->ctx, cs_alt);
fz_throw(doc->ctx, FZ_ERROR_GENERIC, "ICCBased /Alternate colorspace must have %d components (not %d)", n, cs_alt->n);
}
return cs_alt;
}
switch (n)
{
case 1: return fz_device_gray(doc->ctx);
case 3: return fz_device_rgb(doc->ctx);
case 4: return fz_device_cmyk(doc->ctx);
}
fz_throw(doc->ctx, FZ_ERROR_GENERIC, "syntaxerror: ICCBased must have 1, 3 or 4 components");
return NULL; /* Stupid MSVC */
}
示例5: pdf_load_linear_shading
static void
pdf_load_linear_shading(fz_context *ctx, pdf_document *doc, fz_shade *shade, pdf_obj *dict, int funcs, fz_function **func)
{
pdf_obj *obj;
float d0, d1;
int e0, e1;
obj = pdf_dict_gets(ctx, dict, "Coords");
shade->u.l_or_r.coords[0][0] = pdf_to_real(ctx, pdf_array_get(ctx, obj, 0));
shade->u.l_or_r.coords[0][1] = pdf_to_real(ctx, pdf_array_get(ctx, obj, 1));
shade->u.l_or_r.coords[1][0] = pdf_to_real(ctx, pdf_array_get(ctx, obj, 2));
shade->u.l_or_r.coords[1][1] = pdf_to_real(ctx, pdf_array_get(ctx, obj, 3));
d0 = 0;
d1 = 1;
obj = pdf_dict_gets(ctx, dict, "Domain");
if (obj)
{
d0 = pdf_to_real(ctx, pdf_array_get(ctx, obj, 0));
d1 = pdf_to_real(ctx, pdf_array_get(ctx, obj, 1));
}
e0 = e1 = 0;
obj = pdf_dict_gets(ctx, dict, "Extend");
if (obj)
{
e0 = pdf_to_bool(ctx, pdf_array_get(ctx, obj, 0));
e1 = pdf_to_bool(ctx, pdf_array_get(ctx, obj, 1));
}
pdf_sample_shade_function(ctx, shade, funcs, func, d0, d1);
shade->u.l_or_r.extend[0] = e0;
shade->u.l_or_r.extend[1] = e1;
}
示例6: execute_action
static void execute_action(pdf_document *doc, pdf_obj *obj, pdf_obj *a)
{
fz_context *ctx = doc->ctx;
if (a)
{
char *type = pdf_to_name(pdf_dict_gets(a, "S"));
if (!strcmp(type, "JavaScript"))
{
pdf_obj *js = pdf_dict_gets(a, "JS");
if (js)
{
char *code = pdf_to_utf8(doc, js);
fz_try(ctx)
{
pdf_js_execute(doc->js, code);
}
fz_always(ctx)
{
fz_free(ctx, code);
}
fz_catch(ctx)
{
fz_rethrow(ctx);
}
}
}
else if (!strcmp(type, "ResetForm"))
示例7: find_destination_pages
static int find_destination_pages(fz_context *ctx, pdf_obj *current, int page_num, pdf_obj **dest_pages, int *index)
{
if(!strcmp(pdf_to_name(ctx, pdf_dict_gets(ctx, current, "Type")), "Page")) {
return(--page_num);
} if(!strcmp(pdf_to_name(ctx, pdf_dict_gets(ctx, current, "Type")), "Pages")) {
pdf_obj *kids = pdf_dict_gets(ctx, current, "Kids");
pdf_obj *count_obj = pdf_dict_gets(ctx, current, "Count");
if(!pdf_is_array(ctx, kids) || !pdf_is_int(ctx, count_obj))
return(-2);
int count = pdf_to_int(ctx, count_obj);
int i;
for(i = 0; i < count; i++) {
pdf_obj *current_kid = pdf_array_get(ctx, kids, i);
page_num = find_destination_pages(ctx, current_kid, page_num, dest_pages, index);
if(page_num == -1) {
*index = i;
*dest_pages = current;
return(-2);
} else if(page_num == -2) {
return(-2); // just return, preserve index and dest_pages
}
}
return(page_num);
}
return(page_num);
}
示例8: find_head_of_field_group
/* Find the point in a field hierarchy where all descendents
* share the same name */
static pdf_obj *find_head_of_field_group(pdf_obj *obj)
{
if (obj == NULL || pdf_dict_gets(obj, "T"))
return obj;
else
return find_head_of_field_group(pdf_dict_gets(obj, "Parent"));
}
示例9: pdf_lookup_dest
pdf_obj *
pdf_lookup_dest(pdf_document *xref, pdf_obj *needle)
{
fz_context *ctx = xref->ctx;
pdf_obj *root = pdf_dict_gets(xref->trailer, "Root");
pdf_obj *dests = pdf_dict_gets(root, "Dests");
pdf_obj *names = pdf_dict_gets(root, "Names");
pdf_obj *dest = NULL;
/* PDF 1.1 has destinations in a dictionary */
if (dests)
{
if (pdf_is_name(needle))
return pdf_dict_get(dests, needle);
else
return pdf_dict_gets(dests, pdf_to_str_buf(needle));
}
/* PDF 1.2 has destinations in a name tree */
if (names && !dest)
{
pdf_obj *tree = pdf_dict_gets(names, "Dests");
return pdf_lookup_name_imp(ctx, tree, needle);
}
return NULL;
}
示例10: pdf_update_annot
void
pdf_update_annot(pdf_document *doc, pdf_annot *annot)
{
/* SumatraPDF: prevent regressions */
#if 0
pdf_obj *obj, *ap, *as, *n;
fz_context *ctx = doc->ctx;
if (doc->update_appearance)
doc->update_appearance(doc, annot);
obj = annot->obj;
ap = pdf_dict_gets(obj, "AP");
as = pdf_dict_gets(obj, "AS");
if (pdf_is_dict(ap))
{
pdf_hotspot *hp = &doc->hotspot;
n = NULL;
if (hp->num == pdf_to_num(obj)
&& hp->gen == pdf_to_gen(obj)
&& (hp->state & HOTSPOT_POINTER_DOWN))
{
n = pdf_dict_gets(ap, "D"); /* down state */
}
if (n == NULL)
n = pdf_dict_gets(ap, "N"); /* normal state */
/* lookup current state in sub-dictionary */
if (!pdf_is_stream(doc, pdf_to_num(n), pdf_to_gen(n)))
n = pdf_dict_get(n, as);
pdf_drop_xobject(ctx, annot->ap);
annot->ap = NULL;
if (pdf_is_stream(doc, pdf_to_num(n), pdf_to_gen(n)))
{
fz_try(ctx)
{
annot->ap = pdf_load_xobject(doc, n);
pdf_transform_annot(annot);
annot->ap_iteration = annot->ap->iteration;
}
fz_catch(ctx)
{
fz_rethrow_if(ctx, FZ_ERROR_TRYLATER);
fz_warn(ctx, "ignoring broken annotation");
}
}
}
#endif
}
示例11: pdf_insert_page
void
pdf_insert_page(pdf_document *doc, pdf_page *page, int at)
{
fz_context *ctx = doc->ctx;
int count = pdf_count_pages(doc);
pdf_obj *parent, *kids;
pdf_obj *page_ref;
int i;
page_ref = pdf_new_ref(doc, page->me);
fz_try(ctx)
{
if (count == 0)
{
/* TODO: create new page tree? */
fz_throw(ctx, FZ_ERROR_GENERIC, "empty page tree, cannot insert page");
}
else if (at >= count)
{
if (at > count)
fz_throw(ctx, FZ_ERROR_GENERIC, "cannot insert page beyond end of page tree");
/* append after last page */
pdf_lookup_page_loc(doc, count - 1, &parent, &i);
kids = pdf_dict_gets(parent, "Kids");
pdf_array_insert(kids, page_ref, i + 1);
}
else
{
/* insert before found page */
pdf_lookup_page_loc(doc, at, &parent, &i);
kids = pdf_dict_gets(parent, "Kids");
pdf_array_insert(kids, page_ref, i);
}
pdf_dict_puts(page->me, "Parent", parent);
/* Adjust page counts */
while (parent)
{
int count = pdf_to_int(pdf_dict_gets(parent, "Count"));
pdf_dict_puts_drop(parent, "Count", pdf_new_int(doc, count + 1));
parent = pdf_dict_gets(parent, "Parent");
}
}
fz_always(ctx)
{
pdf_drop_obj(page_ref);
}
fz_catch(ctx)
{
fz_rethrow(ctx);
}
}
示例12: pdf_lookup_name
pdf_obj *
pdf_lookup_name(pdf_document *xref, char *which, pdf_obj *needle)
{
fz_context *ctx = xref->ctx;
pdf_obj *root = pdf_dict_gets(xref->trailer, "Root");
pdf_obj *names = pdf_dict_gets(root, "Names");
pdf_obj *tree = pdf_dict_gets(names, which);
return pdf_lookup_name_imp(ctx, tree, needle);
}
示例13: pdf_pattern_uses_blending
static int
pdf_pattern_uses_blending(pdf_document *doc, pdf_obj *dict)
{
pdf_obj *obj;
obj = pdf_dict_gets(dict, "Resources");
if (pdf_resources_use_blending(doc, obj))
return 1;
obj = pdf_dict_gets(dict, "ExtGState");
return pdf_extgstate_uses_blending(doc, obj);
}
示例14: pdf_resources_use_blending
static int
pdf_resources_use_blending(pdf_document *doc, pdf_obj *rdb)
{
fz_context *ctx = doc->ctx;
pdf_obj *obj;
int i, n, useBM = 0;
if (!rdb)
return 0;
/* Have we been here before and remembered an answer? */
if (pdf_obj_memo(rdb, &useBM))
return useBM;
/* stop on cyclic resource dependencies */
if (pdf_mark_obj(rdb))
return 0;
fz_try(ctx)
{
obj = pdf_dict_gets(rdb, "ExtGState");
n = pdf_dict_len(obj);
for (i = 0; i < n; i++)
if (pdf_extgstate_uses_blending(doc, pdf_dict_get_val(obj, i)))
goto found;
obj = pdf_dict_gets(rdb, "Pattern");
n = pdf_dict_len(obj);
for (i = 0; i < n; i++)
if (pdf_pattern_uses_blending(doc, pdf_dict_get_val(obj, i)))
goto found;
obj = pdf_dict_gets(rdb, "XObject");
n = pdf_dict_len(obj);
for (i = 0; i < n; i++)
if (pdf_xobject_uses_blending(doc, pdf_dict_get_val(obj, i)))
goto found;
if (0)
{
found:
useBM = 1;
}
}
fz_always(ctx)
{
pdf_unmark_obj(rdb);
}
fz_catch(ctx)
{
fz_rethrow(ctx);
}
pdf_set_obj_memo(rdb, useBM);
return useBM;
}
示例15: pdf_lookup_page_loc
pdf_obj *
pdf_lookup_page_loc(pdf_document *doc, int needle, pdf_obj **parentp, int *indexp)
{
pdf_obj *root = pdf_dict_gets(pdf_trailer(doc), "Root");
pdf_obj *node = pdf_dict_gets(root, "Pages");
int skip = needle;
pdf_obj *hit = pdf_lookup_page_loc_imp(doc, node, &skip, parentp, indexp);
if (!hit)
fz_throw(doc->ctx, FZ_ERROR_GENERIC, "cannot find page %d in page tree", needle);
return hit;
}