本文整理汇总了C++中pdf_to_gen函数的典型用法代码示例。如果您正苦于以下问题:C++ pdf_to_gen函数的具体用法?C++ pdf_to_gen怎么用?C++ pdf_to_gen使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pdf_to_gen函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pdf_load_embedded_font
static void
pdf_load_embedded_font(pdf_document *doc, pdf_font_desc *fontdesc, char *fontname, pdf_obj *stmref)
{
fz_buffer *buf;
fz_context *ctx = doc->ctx;
fz_try(ctx)
{
buf = pdf_load_stream(doc, pdf_to_num(stmref), pdf_to_gen(stmref));
}
fz_catch(ctx)
{
fz_rethrow_message(ctx, "cannot load font stream (%d %d R)", pdf_to_num(stmref), pdf_to_gen(stmref));
}
fz_try(ctx)
{
fontdesc->font = fz_new_font_from_buffer(ctx, fontname, buf, 0, 1);
}
fz_always(ctx)
{
fz_drop_buffer(ctx, buf);
}
fz_catch(ctx)
{
fz_rethrow_message(ctx, "cannot load embedded font (%d %d R)", pdf_to_num(stmref), pdf_to_gen(stmref));
}
fontdesc->size += buf->len;
fontdesc->is_embedded = 1;
}
示例2: pdf_load_embedded_font
static void
pdf_load_embedded_font(pdf_document *xref, pdf_font_desc *fontdesc, char *fontname, pdf_obj *stmref)
{
fz_buffer *buf;
fz_context *ctx = xref->ctx;
fz_try(ctx)
{
buf = pdf_load_stream(xref, pdf_to_num(stmref), pdf_to_gen(stmref));
}
fz_catch(ctx)
{
fz_throw(ctx, "cannot load font stream (%d %d R)", pdf_to_num(stmref), pdf_to_gen(stmref));
}
fz_try(ctx)
{
fontdesc->font = fz_new_font_from_memory(ctx, fontname, buf->data, buf->len, 0, 1);
}
fz_catch(ctx)
{
fz_drop_buffer(ctx, buf);
fz_throw(ctx, "cannot load embedded font (%d %d R)", pdf_to_num(stmref), pdf_to_gen(stmref));
}
fontdesc->size += buf->len;
/* save the buffer so we can free it later */
fontdesc->font->ft_data = buf->data;
fontdesc->font->ft_size = buf->len;
fz_free(ctx, buf); /* only free the fz_buffer struct, not the contained data */
fontdesc->is_embedded = 1;
}
示例3: 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
}
示例4: 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");
}
}
}
}
示例5: pdf_open_object_array
static fz_stream *
pdf_open_object_array(fz_context *ctx, pdf_document *doc, pdf_obj *list)
{
fz_stream *stm;
int i, n;
n = pdf_array_len(ctx, list);
stm = fz_open_concat(ctx, n, 1);
fz_var(i); /* Workaround Mac compiler bug */
for (i = 0; i < n; i++)
{
pdf_obj *obj = pdf_array_get(ctx, list, i);
fz_try(ctx)
{
fz_concat_push(ctx, stm, pdf_open_stream(ctx, doc, pdf_to_num(ctx, obj), pdf_to_gen(ctx, obj)));
}
fz_catch(ctx)
{
fz_rethrow_if(ctx, FZ_ERROR_TRYLATER);
fz_warn(ctx, "cannot load content stream part %d/%d", i + 1, n);
continue;
}
}
return stm;
}
示例6: pdf_load_jbig2_globals
static fz_jbig2_globals *
pdf_load_jbig2_globals(fz_context *ctx, pdf_document *doc, pdf_obj *dict)
{
fz_jbig2_globals *globals;
fz_buffer *buf = NULL;
fz_var(buf);
if ((globals = pdf_find_item(ctx, fz_drop_jbig2_globals_imp, dict)) != NULL)
{
return globals;
}
fz_try(ctx)
{
buf = pdf_load_stream(ctx, doc, pdf_to_num(ctx, dict), pdf_to_gen(ctx, dict));
globals = fz_load_jbig2_globals(ctx, buf->data, buf->len);
pdf_store_item(ctx, dict, globals, buf->len);
}
fz_always(ctx)
{
fz_drop_buffer(ctx, buf);
}
fz_catch(ctx)
{
fz_rethrow(ctx);
}
return globals;
}
示例7: pdf_open_object_array
static fz_stream *
pdf_open_object_array(pdf_document *xref, pdf_obj *list)
{
int i, n;
fz_context *ctx = xref->ctx;
fz_stream *stm;
n = pdf_array_len(list);
stm = fz_open_concat(ctx, n, 1);
fz_var(i); /* Workaround Mac compiler bug */
for (i = 0; i < n; i++)
{
pdf_obj *obj = pdf_array_get(list, i);
fz_try(ctx)
{
fz_concat_push(stm, pdf_open_stream(xref, pdf_to_num(obj), pdf_to_gen(obj)));
}
fz_catch(ctx)
{
fz_warn(ctx, "cannot load content stream part %d/%d", i + 1, n);
continue;
}
}
return stm;
}
示例8: load_indexed
static fz_colorspace *
load_indexed(pdf_document *doc, pdf_obj *array)
{
fz_context *ctx = doc->ctx;
pdf_obj *baseobj = pdf_array_get(array, 1);
pdf_obj *highobj = pdf_array_get(array, 2);
pdf_obj *lookupobj = pdf_array_get(array, 3);
fz_colorspace *base = NULL;
fz_colorspace *cs;
int i, n, high;
unsigned char *lookup = NULL;
fz_var(base);
fz_var(lookup);
fz_try(ctx)
{
base = pdf_load_colorspace(doc, baseobj);
high = pdf_to_int(highobj);
high = fz_clampi(high, 0, 255);
n = base->n * (high + 1);
lookup = fz_malloc_array(ctx, 1, n);
if (pdf_is_string(lookupobj) && pdf_to_str_len(lookupobj) >= n)
{
unsigned char *buf = (unsigned char *) pdf_to_str_buf(lookupobj);
for (i = 0; i < n; i++)
lookup[i] = buf[i];
}
else if (pdf_is_indirect(lookupobj))
{
fz_stream *file = NULL;
fz_var(file);
fz_try(ctx)
{
file = pdf_open_stream(doc, pdf_to_num(lookupobj), pdf_to_gen(lookupobj));
i = fz_read(file, lookup, n);
if (i < n)
memset(lookup+i, 0, n-i);
}
fz_always(ctx)
{
fz_close(file);
}
fz_catch(ctx)
{
fz_rethrow_message(ctx, "cannot open colorspace lookup table (%d 0 R)", pdf_to_num(lookupobj));
}
}
else
{
fz_rethrow_message(ctx, "cannot parse colorspace lookup table");
}
cs = fz_new_indexed_colorspace(ctx, base, high, lookup);
}
示例9: gathershadings
static void
gathershadings(int page, pdf_obj *pageref, pdf_obj *pageobj, pdf_obj *dict)
{
int i, n;
n = pdf_dict_len(dict);
for (i = 0; i < n; i++)
{
pdf_obj *shade;
pdf_obj *type;
int k;
shade = pdf_dict_get_val(dict, i);
if (!pdf_is_dict(shade))
{
fz_warn(ctx, "not a shading dict (%d %d R)", pdf_to_num(shade), pdf_to_gen(shade));
continue;
}
type = pdf_dict_gets(shade, "ShadingType");
if (!pdf_is_int(type) || pdf_to_int(type) < 1 || pdf_to_int(type) > 7)
{
fz_warn(ctx, "not a shading type (%d %d R)", pdf_to_num(shade), pdf_to_gen(shade));
type = NULL;
}
for (k = 0; k < shadings; k++)
if (!pdf_objcmp(shading[k].u.shading.obj, shade))
break;
if (k < shadings)
continue;
shading = fz_resize_array(ctx, shading, shadings+1, sizeof(struct info));
shadings++;
shading[shadings - 1].page = page;
shading[shadings - 1].pageref = pageref;
shading[shadings - 1].pageobj = pageobj;
shading[shadings - 1].u.shading.obj = shade;
shading[shadings - 1].u.shading.type = type;
}
}
示例10: pdf_print_key
static void
pdf_print_key(fz_context *ctx, fz_output *out, void *key_)
{
pdf_obj *key = (pdf_obj *)key_;
if (pdf_is_indirect(ctx, key))
fz_printf(ctx, out, "(%d %d R) ", pdf_to_num(ctx, key), pdf_to_gen(ctx, key));
else
pdf_print_obj(ctx, out, key, 0);
}
示例11: fz_var
static char *get_string_or_stream(pdf_document *doc, pdf_obj *obj)
{
fz_context *ctx = doc->ctx;
int len = 0;
char *buf = NULL;
fz_buffer *strmbuf = NULL;
char *text = NULL;
fz_var(strmbuf);
fz_var(text);
fz_try(ctx)
{
if (pdf_is_string(obj))
{
len = pdf_to_str_len(obj);
buf = pdf_to_str_buf(obj);
}
else if (pdf_is_stream(doc, pdf_to_num(obj), pdf_to_gen(obj)))
{
strmbuf = pdf_load_stream(doc, pdf_to_num(obj), pdf_to_gen(obj));
len = fz_buffer_storage(ctx, strmbuf, (unsigned char **)&buf);
}
if (buf)
{
text = fz_malloc(ctx, len+1);
memcpy(text, buf, len);
text[len] = 0;
}
}
fz_always(ctx)
{
fz_drop_buffer(ctx, strmbuf);
}
fz_catch(ctx)
{
fz_free(ctx, text);
fz_rethrow(ctx);
}
return text;
}
示例12: pdf_debug_key
static void
pdf_debug_key(void *key_)
{
pdf_obj *key = (pdf_obj *)key_;
if (pdf_is_indirect(key))
{
printf("(%d %d R) ", pdf_to_num(key), pdf_to_gen(key));
} else
pdf_print_obj(key);
}
示例13: pdf_make_hash_key
static int
pdf_make_hash_key(fz_store_hash *hash, void *key_)
{
pdf_obj *key = (pdf_obj *)key_;
if (!pdf_is_indirect(key))
return 0;
hash->u.i.i0 = pdf_to_num(key);
hash->u.i.i1 = pdf_to_gen(key);
return 1;
}
示例14: pdf_load_type7_shade
static void
pdf_load_type7_shade(fz_context *ctx, pdf_document *doc, fz_shade *shade, pdf_obj *dict, int funcs, fz_function **func)
{
pdf_load_mesh_params(ctx, doc, shade, dict);
if (funcs > 0)
pdf_sample_shade_function(ctx, shade, funcs, func, shade->u.m.c0[0], shade->u.m.c1[0]);
shade->buffer = pdf_load_compressed_stream(ctx, doc, pdf_to_num(ctx, dict), pdf_to_gen(ctx, dict));
}
示例15: pdf_make_hash_key
static int
pdf_make_hash_key(fz_context *ctx, fz_store_hash *hash, void *key_)
{
pdf_obj *key = (pdf_obj *)key_;
if (!pdf_is_indirect(ctx, key))
return 0;
hash->u.i.i0 = pdf_to_num(ctx, key);
hash->u.i.i1 = pdf_to_gen(ctx, key);
hash->u.i.ptr = pdf_get_indirect_document(ctx, key);
return 1;
}