本文整理汇总了C++中pdf_to_gen函数的典型用法代码示例。如果您正苦于以下问题:C++ pdf_to_gen函数的具体用法?C++ pdf_to_gen怎么用?C++ pdf_to_gen使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pdf_to_gen函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:EvoGroupTN,项目名称:mupdf,代码行数:31,代码来源:pdf-font.c
示例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;
}
开发者ID:JosephLi141242,项目名称:android-pdf-viewer,代码行数:33,代码来源:pdf_font.c
示例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
}
开发者ID:Andy-Amoy,项目名称:sumatrapdf,代码行数:56,代码来源:pdf-annot-edit.c
示例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");
}
}
}
}
开发者ID:Leadrive,项目名称:mupdf-converter,代码行数:52,代码来源:pdf-annot-edit.c
示例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;
}
开发者ID:PuzzleFlow,项目名称:mupdf,代码行数:27,代码来源:pdf-stream.c
示例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;
}
开发者ID:PuzzleFlow,项目名称:mupdf,代码行数:30,代码来源:pdf-stream.c
示例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;
}
开发者ID:JMQCode,项目名称:iBooks,代码行数:27,代码来源:pdf_stream.c
示例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);
}
开发者ID:azaleafisitania,项目名称:sumatrapdf,代码行数:59,代码来源:pdf-colorspace.c
示例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;
}
}
开发者ID:ArphonePei,项目名称:PDFConverter,代码行数:43,代码来源:pdfinfo.c
示例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);
}
开发者ID:HelloZhu,项目名称:mupdf,代码行数:10,代码来源:pdf-store.c
示例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;
}
开发者ID:ArphonePei,项目名称:PDFConverter,代码行数:42,代码来源:pdf-form.c
示例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);
}
开发者ID:Buminta,项目名称:BibDroid,代码行数:11,代码来源:pdf_store.c
示例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;
}
开发者ID:Buminta,项目名称:BibDroid,代码行数:11,代码来源:pdf_store.c
示例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));
}
开发者ID:zyma678,项目名称:iOSMuPDFSource,代码行数:11,代码来源:pdf-shade.c
示例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;
}
开发者ID:HelloZhu,项目名称:mupdf,代码行数:12,代码来源:pdf-store.c
示例16: gatherforms
static void
gatherforms(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 *xobjdict;
pdf_obj *type;
pdf_obj *subtype;
pdf_obj *group;
pdf_obj *groupsubtype;
pdf_obj *reference;
int k;
xobjdict = pdf_dict_get_val(dict, i);
if (!pdf_is_dict(xobjdict))
{
fz_warn(ctx, "not a xobject dict (%d %d R)", pdf_to_num(xobjdict), pdf_to_gen(xobjdict));
continue;
}
type = pdf_dict_gets(xobjdict, "Subtype");
if (strcmp(pdf_to_name(type), "Form"))
continue;
subtype = pdf_dict_gets(xobjdict, "Subtype2");
if (!strcmp(pdf_to_name(subtype), "PS"))
continue;
group = pdf_dict_gets(xobjdict, "Group");
groupsubtype = pdf_dict_gets(group, "S");
reference = pdf_dict_gets(xobjdict, "Ref");
for (k = 0; k < forms; k++)
if (!pdf_objcmp(form[k].u.form.obj, xobjdict))
break;
if (k < forms)
continue;
form = fz_resize_array(ctx, form, forms+1, sizeof(struct info));
forms++;
form[forms - 1].page = page;
form[forms - 1].pageref = pageref;
form[forms - 1].pageobj = pageobj;
form[forms - 1].u.form.obj = xobjdict;
form[forms - 1].u.form.groupsubtype = groupsubtype;
form[forms - 1].u.form.reference = reference;
}
}
开发者ID:ArphonePei,项目名称:PDFConverter,代码行数:53,代码来源:pdfinfo.c
示例17: pdf_debug_key
static void
pdf_debug_key(FILE *out, void *key_)
{
pdf_obj *key = (pdf_obj *)key_;
if (pdf_is_indirect(key))
{
fprintf(out, "(%d %d R) ", pdf_to_num(key), pdf_to_gen(key));
}
else
pdf_fprint_obj(out, key, 0);
}
开发者ID:Andy-Amoy,项目名称:sumatrapdf,代码行数:12,代码来源:pdf-store.c
示例18: juggler_add_pages_from_file
ErrorCode juggler_add_pages_from_file(juggler_t *dest, juggler_t *src, int dest_index)
{
pdf_obj *dest_pages = pdf_dict_getp(dest->ctx,
pdf_trailer(dest->ctx, dest->pdf), "Root/Pages");
int dest_pages_index = pdf_array_len(dest->ctx,
pdf_dict_gets(dest->ctx, dest_pages, "Kids"));
/* be aware that this function does not change the two variables if the page
index is greater than the number of pages */
find_destination_pages(dest->ctx,
dest_pages, dest_index, &dest_pages, &dest_pages_index);
pdf_obj *dest_kids = pdf_dict_gets(dest->ctx, dest_pages, "Kids");
if(!pdf_is_indirect(dest->ctx, dest_pages) ||
!pdf_is_dict(dest->ctx, dest_pages) || !pdf_is_array(dest->ctx, dest_kids))
{
return(ERROR_INVALID_RANGE);
}
pdf_obj *pages_root = pdf_dict_getp(src->ctx, pdf_trailer(src->ctx, src->pdf), "Root/Pages");
if(!pdf_is_indirect(src->ctx, pages_root) || !pdf_is_dict(src->ctx, pages_root))
return(ERROR_NO_PAGES);
/* if we copy the root pages-node and it's referenced objects, we will copy
all pages and all objects those pages need */
pdf_obj *new_pages_ref = copy_object_single(dest->ctx, dest->pdf, src->ctx, src->pdf, pages_root);
/* insert new pages-node */
pdf_array_insert_drop(dest->ctx, dest_kids, new_pages_ref, dest_pages_index);
/* update the parent */
pdf_obj *new_pages_parent = pdf_new_indirect(dest->ctx, dest->pdf,
pdf_to_num(dest->ctx, dest_pages), pdf_to_gen(dest->ctx, dest_pages));
pdf_dict_puts_drop(dest->ctx, new_pages_ref, "Parent", new_pages_parent);
/* TODO: If dest_pages contains anything inheritable but not the new node
we need to insert empty items to prevent this inerhitance */
/* update count */
int new_count = pdf_to_int(dest->ctx,
pdf_dict_gets(dest->ctx, dest_pages, "Count")) + src->pagecount;
pdf_dict_puts_drop(dest->ctx, dest_pages, "Count",
pdf_new_int(dest->ctx, dest->pdf, new_count));
/* let MuPDF rebuild the page tree */
pdf_finish_edit(dest->ctx, dest->pdf);
dest->pdf->page_count = new_count;
/* update juggler's state */
juggler_page_tree_changed_due_to_insert(dest, dest_index, src->pagecount);
return(NoError);
}
开发者ID:s-k2,项目名称:Juggler,代码行数:53,代码来源:page-add.c
示例19: pdf_load_type6_shade
static void
pdf_load_type6_shade(fz_shade *shade, pdf_document *xref, pdf_obj *dict,
int funcs, pdf_function **func)
{
fz_context *ctx = xref->ctx;
pdf_load_mesh_params(shade, xref, 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(xref, pdf_to_num(dict), pdf_to_gen(dict));
}
开发者ID:modulexcite,项目名称:windows8,代码行数:13,代码来源:pdf_shade.c
示例20: pdf_load_type5_shade
static void
pdf_load_type5_shade(fz_shade *shade, pdf_document *xref, pdf_obj *dict,
int funcs, pdf_function **func)
{
fz_context *ctx = xref->ctx;
struct mesh_params p;
struct vertex *buf, *ref;
int first;
int ncomp;
int i, k;
fz_stream *stream;
pdf_load_mesh_params(xref, dict, &p);
if (funcs > 0)
{
ncomp = 1;
pdf_sample_shade_function(ctx, shade, funcs, func, p.c0[0], p.c1[0]);
}
else
ncomp = shade->colorspace->n;
ref = fz_malloc_array(ctx, p.vprow, sizeof(struct vertex));
buf = fz_malloc_array(ctx, p.vprow, sizeof(struct vertex));
first = 1;
stream = pdf_open_stream(xref, pdf_to_num(dict), pdf_to_gen(dict));
while (!fz_is_eof_bits(stream))
{
for (i = 0; i < p.vprow; i++)
{
buf[i].x = read_sample(stream, p.bpcoord, p.x0, p.x1);
buf[i].y = read_sample(stream, p.bpcoord, p.y0, p.y1);
for (k = 0; k < ncomp; k++)
buf[i].c[k] = read_sample(stream, p.bpcomp, p.c0[k], p.c1[k]);
}
if (!first)
for (i = 0; i < p.vprow - 1; i++)
pdf_add_quad(ctx, shade,
&ref[i], &ref[i+1], &buf[i+1], &buf[i]);
memcpy(ref, buf, p.vprow * sizeof(struct vertex));
first = 0;
}
fz_free(ctx, ref);
fz_free(ctx, buf);
fz_close(stream);
}
开发者ID:UIKit0,项目名称:mupdf,代码行数:51,代码来源:pdf_shade.c
注:本文中的pdf_to_gen函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论