本文整理汇总了C++中pdf_dict_get函数的典型用法代码示例。如果您正苦于以下问题:C++ pdf_dict_get函数的具体用法?C++ pdf_dict_get怎么用?C++ pdf_dict_get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pdf_dict_get函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: strip_outlines
static int strip_outlines(fz_context *ctx, pdf_document *doc, pdf_obj *outlines, int page_count, int *page_object_nums, pdf_obj *names_list)
{
int nc;
pdf_obj *first;
pdf_obj *last;
first = pdf_dict_get(ctx, outlines, PDF_NAME_First);
if (first == NULL)
nc = 0;
else
nc = strip_outline(ctx, doc, first, page_count, page_object_nums, names_list, &first, &last);
if (nc == 0)
{
pdf_dict_del(ctx, outlines, PDF_NAME_First);
pdf_dict_del(ctx, outlines, PDF_NAME_Last);
pdf_dict_del(ctx, outlines, PDF_NAME_Count);
}
else
{
int old_count = pdf_to_int(ctx, pdf_dict_get(ctx, outlines, PDF_NAME_Count));
pdf_dict_put(ctx, outlines, PDF_NAME_First, first);
pdf_dict_put(ctx, outlines, PDF_NAME_Last, last);
pdf_dict_put(ctx, outlines, PDF_NAME_Count, pdf_new_int(ctx, doc, old_count > 0 ? nc : -nc));
}
return nc;
}
示例2: 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(fz_context *ctx, pdf_obj *obj)
{
if (obj == NULL || pdf_dict_get(ctx, obj, PDF_NAME_T))
return obj;
else
return find_head_of_field_group(ctx, pdf_dict_get(ctx, obj, PDF_NAME_Parent));
}
示例3: pdf_load_linear_shading
static void
pdf_load_linear_shading(fz_context *ctx, pdf_document *doc, fz_shade *shade, pdf_obj *dict, int funcs, pdf_function **func)
{
pdf_obj *obj;
float d0, d1;
int e0, e1;
obj = pdf_dict_get(ctx, dict, PDF_NAME(Coords));
shade->u.l_or_r.coords[0][0] = pdf_array_get_real(ctx, obj, 0);
shade->u.l_or_r.coords[0][1] = pdf_array_get_real(ctx, obj, 1);
shade->u.l_or_r.coords[1][0] = pdf_array_get_real(ctx, obj, 2);
shade->u.l_or_r.coords[1][1] = pdf_array_get_real(ctx, obj, 3);
d0 = 0;
d1 = 1;
obj = pdf_dict_get(ctx, dict, PDF_NAME(Domain));
if (obj)
{
d0 = pdf_array_get_real(ctx, obj, 0);
d1 = pdf_array_get_real(ctx, obj, 1);
}
e0 = e1 = 0;
obj = pdf_dict_get(ctx, dict, PDF_NAME(Extend));
if (obj)
{
e0 = pdf_array_get_bool(ctx, obj, 0);
e1 = pdf_array_get_bool(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;
}
示例4: pdf_xobject_transparency
int pdf_xobject_transparency(fz_context *ctx, pdf_obj *xobj)
{
pdf_obj *group = pdf_dict_get(ctx, xobj, PDF_NAME(Group));
if (group)
if (pdf_name_eq(ctx, pdf_dict_get(ctx, group, PDF_NAME(S)), PDF_NAME(Transparency)))
return 1;
return 0;
}
示例5: build_filter
/*
* Create a filter given a name and param dictionary.
*/
static fz_stream *
build_filter(fz_context *ctx, fz_stream *chain, pdf_document *doc, pdf_obj *f, pdf_obj *p, int num, int gen, fz_compression_params *params)
{
fz_compression_params local_params;
if (params == NULL)
params = &local_params;
build_compression_params(ctx, f, p, params);
/* If we were using params we were passed in, and we successfully
* recognised the image type, we can use the existing filter and
* shortstop here. */
if (params != &local_params && params->type != FZ_IMAGE_RAW)
return chain;
if (params->type != FZ_IMAGE_RAW)
return fz_open_image_decomp_stream(ctx, chain, params, NULL);
if (pdf_name_eq(ctx, f, PDF_NAME_ASCIIHexDecode) || pdf_name_eq(ctx, f, PDF_NAME_AHx))
return fz_open_ahxd(ctx, chain);
else if (pdf_name_eq(ctx, f, PDF_NAME_ASCII85Decode) || pdf_name_eq(ctx, f, PDF_NAME_A85))
return fz_open_a85d(ctx, chain);
else if (pdf_name_eq(ctx, f, PDF_NAME_JBIG2Decode))
{
fz_jbig2_globals *globals = NULL;
pdf_obj *obj = pdf_dict_get(ctx, p, PDF_NAME_JBIG2Globals);
if (pdf_is_indirect(ctx, obj))
globals = pdf_load_jbig2_globals(ctx, doc, obj);
/* fz_open_jbig2d takes possession of globals */
return fz_open_jbig2d(ctx, chain, globals);
}
else if (pdf_name_eq(ctx, f, PDF_NAME_JPXDecode))
return chain; /* JPX decoding is special cased in the image loading code */
else if (pdf_name_eq(ctx, f, PDF_NAME_Crypt))
{
pdf_obj *name;
if (!doc->crypt)
{
fz_warn(ctx, "crypt filter in unencrypted document");
return chain;
}
name = pdf_dict_get(ctx, p, PDF_NAME_Name);
if (pdf_is_name(ctx, name))
return pdf_open_crypt_with_filter(ctx, chain, doc->crypt, name, num, gen);
return chain;
}
fz_warn(ctx, "unknown filter name (%s)", pdf_to_name(ctx, f));
return chain;
}
示例6: parse_dict
static void
parse_dict (fz_context *ctx, pdf_obj *dict, pdfout_data *hash)
{
/* Check Style key. */
pdf_obj *style = pdf_dict_get (ctx, dict, PDF_NAME_S);
if (style)
{
const char *value;
if (pdf_is_name (ctx, style) == false)
pdfout_throw (ctx, "style key 'S' not a name object");
/* pdf_to_name returns the empty string, not NULL, on all errors,
so the strcmps are allowed. */
if (pdf_name_eq (ctx, style, PDF_NAME_D))
value = "arabic";
else if (pdf_name_eq (ctx, style, PDF_NAME_R))
value = "Roman";
else if (pdf_name_eq (ctx, style, PDF_NAME_A))
value = "Letters";
else
{
/* FIXME once PDF_NAMES for "r" and "a" available. */
const char *string = pdf_to_name (ctx, style);
if (streq(string, "r"))
value = "roman";
else if (streq (string, "a"))
value = "letters";
else
pdfout_throw (ctx, "unknown numbering style '%s'", string);
}
int len = strlen (value);
pdfout_data_hash_push_key_value (ctx, hash, "style", value, len);
}
pdf_obj *first = pdf_dict_gets (ctx, dict, "St");
if (first)
{
int value = pdf_to_int (ctx, first);
if (value < 1)
pdfout_throw (ctx, "value %d of 'St' is < 1 or not an int", value);
push_int_key (ctx, hash, "first", value);
}
pdf_obj *prefix = pdf_dict_get (ctx, dict, PDF_NAME_P);
if (prefix)
{
if (pdf_is_string (ctx, prefix) == false)
pdfout_throw (ctx, "value of 'P' not a string");
int utf8_len;
char *utf8 = pdfout_str_obj_to_utf8 (ctx, prefix, &utf8_len);
pdfout_data_hash_push_key_value (ctx, hash, "prefix", utf8, utf8_len);
free (utf8);
}
}
示例7: load_portfolio
static void
load_portfolio(fz_context *ctx, pdf_document *doc)
{
pdf_obj *obj;
int i, n;
pdf_portfolio **pp;
obj = pdf_dict_getl(ctx, pdf_trailer(ctx, doc), PDF_NAME_Root, PDF_NAME_Collection, PDF_NAME_Schema, NULL);
n = pdf_dict_len(ctx, obj);
for (i = 0; i < n; i++)
{
pdf_obj *k = pdf_dict_get_key(ctx, obj, i);
pdf_obj *v = pdf_dict_get_val(ctx, obj, i);
int sort = pdf_to_int(ctx, pdf_dict_get(ctx, v, PDF_NAME_O));
pdf_obj *eo = pdf_dict_get(ctx, v, PDF_NAME_E);
int editable = eo ? pdf_to_bool(ctx, eo) : 0;
pdf_obj *vo = pdf_dict_get(ctx, v, PDF_NAME_V);
int visible = vo ? pdf_to_bool(ctx, vo) : 1;
char *subtype = pdf_to_name(ctx, pdf_dict_get(ctx, v, PDF_NAME_Subtype));
pdf_obj *name = pdf_dict_get(ctx, v, PDF_NAME_N);
pdf_portfolio *p = fz_malloc_struct(ctx, pdf_portfolio);
p->key = pdf_keep_obj(ctx, k);
p->val = pdf_keep_obj(ctx, v);
p->sort = sort;
p->entry.visible = visible;
p->entry.editable = editable;
p->entry.name = pdf_keep_obj(ctx, name);
if (!strcmp(subtype, "S"))
p->entry.type = PDF_SCHEMA_TEXT;
else if (!strcmp(subtype, "D"))
p->entry.type = PDF_SCHEMA_DATE;
else if (!strcmp(subtype, "N"))
p->entry.type = PDF_SCHEMA_NUMBER;
else if (!strcmp(subtype, "F"))
p->entry.type = PDF_SCHEMA_FILENAME;
else if (!strcmp(subtype, "Desc"))
p->entry.type = PDF_SCHEMA_DESC;
else if (!strcmp(subtype, "ModDate"))
p->entry.type = PDF_SCHEMA_MODDATE;
else if (!strcmp(subtype, "CreationDate"))
p->entry.type = PDF_SCHEMA_CREATIONDATE;
else if (!strcmp(subtype, "Size"))
p->entry.type = PDF_SCHEMA_SIZE;
else
p->entry.type = PDF_SCHEMA_UNKNOWN;
/* Now insert p */
pp = &doc->portfolio;
while (*pp && (*pp)->sort <= p->sort)
pp = &(*pp)->next;
p->next = *pp;
*pp = p;
}
}
示例8: pdf_annot_border
float
pdf_annot_border(fz_context *ctx, pdf_annot *annot)
{
pdf_obj *bs, *bs_w;
bs = pdf_dict_get(ctx, annot->obj, PDF_NAME(BS));
bs_w = pdf_dict_get(ctx, bs, PDF_NAME(W));
if (pdf_is_number(ctx, bs_w))
return pdf_to_real(ctx, bs_w);
return 1;
}
示例9: pdf_portfolio_entry_obj_name
pdf_obj *pdf_portfolio_entry_info(fz_context *ctx, pdf_document *doc, int entry, int schema_entry)
{
pdf_obj *obj = pdf_portfolio_entry_obj_name(ctx, doc, entry, NULL);
pdf_portfolio *p;
pdf_obj *lookup;
int ef = 0;
if (!obj)
return NULL;
for (p = doc->portfolio; p != NULL && schema_entry > 0; p = p->next, schema_entry--);
if (schema_entry)
fz_throw(ctx, FZ_ERROR_GENERIC, "schema_entry out of range");
switch (p->entry.type)
{
default:
case PDF_SCHEMA_TEXT:
case PDF_SCHEMA_DATE:
case PDF_SCHEMA_NUMBER:
lookup = NULL;
break;
case PDF_SCHEMA_FILENAME:
lookup = PDF_NAME_UF;
break;
case PDF_SCHEMA_DESC:
lookup = PDF_NAME_Desc;
break;
case PDF_SCHEMA_MODDATE:
lookup = PDF_NAME_ModDate;
ef = 1;
break;
case PDF_SCHEMA_CREATIONDATE:
lookup = PDF_NAME_CreationDate;
ef = 1;
break;
case PDF_SCHEMA_SIZE:
lookup = PDF_NAME_Size;
ef = 1;
break;
}
if (lookup)
{
pdf_obj *res;
if (ef)
obj = pdf_dict_getl(ctx, obj, PDF_NAME_EF, PDF_NAME_F, PDF_NAME_Params, NULL);
res = pdf_dict_get(ctx, obj, lookup);
if (res == NULL && lookup == PDF_NAME_UF)
res = pdf_dict_get(ctx, obj, PDF_NAME_F);
return res;
}
return pdf_dict_getl(ctx, obj, PDF_NAME_CI, p->key, NULL);
}
示例10: pdf_update_annot
void
pdf_update_annot(fz_context *ctx, pdf_document *doc, pdf_annot *annot)
{
pdf_obj *obj, *ap, *as, *n;
if (doc->update_appearance)
doc->update_appearance(ctx, doc, annot);
obj = annot->obj;
ap = pdf_dict_get(ctx, obj, PDF_NAME_AP);
as = pdf_dict_get(ctx, obj, PDF_NAME_AS);
if (pdf_is_dict(ctx, ap))
{
pdf_hotspot *hp = &doc->hotspot;
n = NULL;
if (hp->num == pdf_to_num(ctx, obj)
&& hp->gen == pdf_to_gen(ctx, obj)
&& (hp->state & HOTSPOT_POINTER_DOWN))
{
n = pdf_dict_get(ctx, ap, PDF_NAME_D); /* down state */
}
if (n == NULL)
n = pdf_dict_get(ctx, ap, PDF_NAME_N); /* normal state */
/* lookup current state in sub-dictionary */
if (!pdf_is_stream(ctx, doc, pdf_to_num(ctx, n), pdf_to_gen(ctx, n)))
n = pdf_dict_get(ctx, n, as);
pdf_drop_xobject(ctx, annot->ap);
annot->ap = NULL;
if (pdf_is_stream(ctx, doc, pdf_to_num(ctx, n), pdf_to_gen(ctx, n)))
{
fz_try(ctx)
{
annot->ap = pdf_load_xobject(ctx, doc, n);
pdf_transform_annot(ctx, annot);
annot->ap_iteration = annot->ap->iteration;
}
fz_catch(ctx)
{
fz_rethrow_if(ctx, FZ_ERROR_TRYLATER);
fz_warn(ctx, "ignoring broken annotation");
}
}
}
}
示例11: do_name_tree_map
static int
do_name_tree_map(fz_context *ctx, pdf_obj *tree, pdf_name_tree_map_fn *fn, void *arg)
{
int i;
int n = 0;
int m = 0;
fz_var(n);
fz_var(m);
if (pdf_mark_obj(ctx, tree))
fz_throw(ctx, FZ_ERROR_GENERIC, "Recursive name tree!");
fz_try(ctx)
{
pdf_obj *arr = pdf_dict_get(ctx, tree, PDF_NAME_Kids);
n = pdf_array_len(ctx, arr);
for (i = n; i > 0;)
{
i--;
if (do_name_tree_map(ctx, pdf_array_get(ctx, arr, i), fn, arg))
{
pdf_array_delete(ctx, arr, i);
n--;
}
}
arr = pdf_dict_get(ctx, tree, PDF_NAME_Names);
m = pdf_array_len(ctx, arr);
if (m & 1)
fz_throw(ctx, FZ_ERROR_GENERIC, "Malformed Names array");
for (i = m; i > 0;)
{
i -= 2;
if (fn(ctx, tree, pdf_array_get(ctx, arr, i), pdf_array_get(ctx, arr, i+1), arg))
{
pdf_array_delete(ctx, arr, i+1);
pdf_array_delete(ctx, arr, i);
m -= 2;
}
}
}
fz_always(ctx)
pdf_unmark_obj(ctx, tree);
fz_catch(ctx)
fz_rethrow(ctx);
return n == 0 && m == 0;
}
示例12: pdf_load_outline
fz_outline *
pdf_load_outline(fz_context *ctx, pdf_document *doc)
{
pdf_obj *root, *obj, *first;
root = pdf_dict_get(ctx, pdf_trailer(ctx, doc), PDF_NAME_Root);
obj = pdf_dict_get(ctx, root, PDF_NAME_Outlines);
first = pdf_dict_get(ctx, obj, PDF_NAME_First);
if (first)
return pdf_load_outline_imp(ctx, doc, first);
return NULL;
}
示例13: pdf_parse_file_spec
char *
pdf_parse_file_spec(fz_context *ctx, pdf_document *doc, pdf_obj *file_spec, pdf_obj *dest)
{
pdf_obj *filename = NULL;
const char *path;
char *uri;
char frag[256];
if (pdf_is_string(ctx, file_spec))
filename = file_spec;
if (pdf_is_dict(ctx, file_spec)) {
#ifdef _WIN32
filename = pdf_dict_get(ctx, file_spec, PDF_NAME(DOS));
#else
filename = pdf_dict_get(ctx, file_spec, PDF_NAME(Unix));
#endif
if (!filename)
filename = pdf_dict_geta(ctx, file_spec, PDF_NAME(UF), PDF_NAME(F));
}
if (!pdf_is_string(ctx, filename))
{
fz_warn(ctx, "cannot parse file specification");
return NULL;
}
if (pdf_is_array(ctx, dest))
fz_snprintf(frag, sizeof frag, "#page=%d", pdf_array_get_int(ctx, dest, 0) + 1);
else if (pdf_is_name(ctx, dest))
fz_snprintf(frag, sizeof frag, "#%s", pdf_to_name(ctx, dest));
else if (pdf_is_string(ctx, dest))
fz_snprintf(frag, sizeof frag, "#%s", pdf_to_str_buf(ctx, dest));
else
frag[0] = 0;
path = pdf_to_text_string(ctx, filename);
uri = NULL;
#ifdef _WIN32
if (!pdf_name_eq(ctx, pdf_dict_get(ctx, file_spec, PDF_NAME(FS)), PDF_NAME(URL)))
{
/* Fix up the drive letter (change "/C/Documents/Foo" to "C:/Documents/Foo") */
if (path[0] == '/' && (('A' <= path[1] && path[1] <= 'Z') || ('a' <= path[1] && path[1] <= 'z')) && path[2] == '/')
uri = fz_asprintf(ctx, "file://%c:%s%s", path[1], path+2, frag);
}
#endif
if (!uri)
uri = fz_asprintf(ctx, "file://%s%s", path, frag);
return uri;
}
示例14: pdf_load_image_stream
static fz_buffer *
pdf_load_image_stream(fz_context *ctx, pdf_document *doc, int num, int gen, int orig_num, int orig_gen, fz_compression_params *params, int *truncated)
{
fz_stream *stm = NULL;
pdf_obj *dict, *obj;
int i, len, n;
fz_buffer *buf;
fz_var(buf);
if (num > 0 && num < pdf_xref_len(ctx, doc))
{
pdf_xref_entry *entry = pdf_get_xref_entry(ctx, doc, num);
/* Return ref to existing buffer, but only if uncompressed,
* or shortstoppable */
if (can_reuse_buffer(ctx, entry, params))
return fz_keep_buffer(ctx, entry->stm_buf);
}
dict = pdf_load_object(ctx, doc, num, gen);
len = pdf_to_int(ctx, pdf_dict_get(ctx, dict, PDF_NAME_Length));
obj = pdf_dict_get(ctx, dict, PDF_NAME_Filter);
len = pdf_guess_filter_length(len, pdf_to_name(ctx, obj));
n = pdf_array_len(ctx, obj);
for (i = 0; i < n; i++)
len = pdf_guess_filter_length(len, pdf_to_name(ctx, pdf_array_get(ctx, obj, i)));
pdf_drop_obj(ctx, dict);
stm = pdf_open_image_stream(ctx, doc, num, gen, orig_num, orig_gen, params);
fz_try(ctx)
{
if (truncated)
buf = fz_read_best(ctx, stm, len, truncated);
else
buf = fz_read_all(ctx, stm, len);
}
fz_always(ctx)
{
fz_drop_stream(ctx, stm);
}
fz_catch(ctx)
{
fz_rethrow_message(ctx, "cannot read raw stream (%d %d R)", num, gen);
}
return buf;
}
示例15: pdf_load_function_based_shading
static void
pdf_load_function_based_shading(fz_context *ctx, pdf_document *doc, fz_shade *shade, pdf_obj *dict, pdf_function *func)
{
pdf_obj *obj;
float x0, y0, x1, y1;
float fv[2];
fz_matrix matrix;
int xx, yy;
float *p;
int n = fz_colorspace_n(ctx, shade->colorspace);
x0 = y0 = 0;
x1 = y1 = 1;
obj = pdf_dict_get(ctx, dict, PDF_NAME(Domain));
if (obj)
{
x0 = pdf_array_get_real(ctx, obj, 0);
x1 = pdf_array_get_real(ctx, obj, 1);
y0 = pdf_array_get_real(ctx, obj, 2);
y1 = pdf_array_get_real(ctx, obj, 3);
}
obj = pdf_dict_get(ctx, dict, PDF_NAME(Matrix));
if (obj)
pdf_to_matrix(ctx, obj, &matrix);
else
matrix = fz_identity;
shade->u.f.matrix = matrix;
shade->u.f.xdivs = FUNSEGS;
shade->u.f.ydivs = FUNSEGS;
shade->u.f.fn_vals = fz_malloc(ctx, (FUNSEGS+1)*(FUNSEGS+1)*n*sizeof(float));
shade->u.f.domain[0][0] = x0;
shade->u.f.domain[0][1] = y0;
shade->u.f.domain[1][0] = x1;
shade->u.f.domain[1][1] = y1;
p = shade->u.f.fn_vals;
for (yy = 0; yy <= FUNSEGS; yy++)
{
fv[1] = y0 + (y1 - y0) * yy / FUNSEGS;
for (xx = 0; xx <= FUNSEGS; xx++)
{
fv[0] = x0 + (x1 - x0) * xx / FUNSEGS;
pdf_eval_function(ctx, func, fv, 2, p, n);
p += n;
}
}
}