本文整理汇总了C++中pdf_drop_obj函数的典型用法代码示例。如果您正苦于以下问题:C++ pdf_drop_obj函数的具体用法?C++ pdf_drop_obj怎么用?C++ pdf_drop_obj使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pdf_drop_obj函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pdf_delete_portfolio_schema
void pdf_delete_portfolio_schema(fz_context *ctx, pdf_document *doc, int entry)
{
pdf_portfolio **pp;
pdf_portfolio *p;
pdf_obj *s;
if (!doc)
fz_throw(ctx, FZ_ERROR_GENERIC, "Bad pdf_delete_portfolio_schema call");
if (doc->portfolio == NULL)
load_portfolio(ctx, doc);
pp = &doc->portfolio;
while (*pp && entry > 0)
pp = &(*pp)->next, entry--;
p = *pp;
if (p == NULL || entry)
fz_throw(ctx, FZ_ERROR_GENERIC, "entry out of range in pdf_delete_portfolio_schema");
*pp = p->next;
/* Delete the key from the schema */
s = pdf_dict_getl(ctx, pdf_trailer(ctx, doc), PDF_NAME_Root, PDF_NAME_Collection, PDF_NAME_Schema, NULL);
pdf_dict_del(ctx, s, p->key);
/* Delete this entry from all the collection entries */
s = pdf_dict_getl(ctx, pdf_trailer(ctx, doc), PDF_NAME_Root, PDF_NAME_Names, PDF_NAME_EmbeddedFiles, NULL);
pdf_name_tree_map(ctx, s, delete_from_node, p->key);
pdf_drop_obj(ctx, p->entry.name);
pdf_drop_obj(ctx, p->key);
pdf_drop_obj(ctx, p->val);
fz_free(ctx, p);
}
示例2: pdf_free_xref_sections
static void pdf_free_xref_sections(pdf_document *doc)
{
fz_context *ctx = doc->ctx;
int x, e;
for (x = 0; x < doc->num_xref_sections; x++)
{
pdf_xref *xref = &doc->xref_sections[x];
for (e = 0; e < xref->len; e++)
{
pdf_xref_entry *entry = &xref->table[e];
if (entry->obj)
{
pdf_drop_obj(entry->obj);
fz_drop_buffer(ctx, entry->stm_buf);
}
}
fz_free(ctx, xref->table);
pdf_drop_obj(xref->trailer);
}
fz_free(ctx, doc->xref_sections);
doc->xref_sections = NULL;
doc->num_xref_sections = 0;
}
示例3: pdf_clean_stream_object
static void
pdf_clean_stream_object(fz_context *ctx, pdf_document *doc, pdf_obj *obj, pdf_obj *orig_res, fz_cookie *cookie, int own_res)
{
pdf_processor *proc_buffer = NULL;
pdf_processor *proc_filter = NULL;
pdf_obj *res = NULL;
pdf_obj *ref = NULL;
fz_buffer *buffer;
if (!obj)
return;
fz_var(res);
fz_var(ref);
fz_var(proc_buffer);
fz_var(proc_filter);
buffer = fz_new_buffer(ctx, 1024);
fz_try(ctx)
{
if (own_res)
{
pdf_obj *r = pdf_dict_get(ctx, obj, PDF_NAME_Resources);
if (r)
orig_res = r;
}
res = pdf_new_dict(ctx, doc, 1);
proc_buffer = pdf_new_buffer_processor(ctx, buffer);
proc_filter = pdf_new_filter_processor(ctx, proc_buffer, doc, orig_res, res);
pdf_process_contents(ctx, proc_filter, doc, orig_res, obj, cookie);
pdf_update_stream(ctx, doc, obj, buffer, 0);
if (own_res)
{
ref = pdf_new_ref(ctx, doc, res);
pdf_dict_put(ctx, obj, PDF_NAME_Resources, ref);
}
}
fz_always(ctx)
{
pdf_drop_processor(ctx, proc_filter);
pdf_drop_processor(ctx, proc_buffer);
fz_drop_buffer(ctx, buffer);
pdf_drop_obj(ctx, res);
pdf_drop_obj(ctx, ref);
}
fz_catch(ctx)
{
fz_rethrow_message(ctx, "Failed while cleaning xobject");
}
}
示例4: pdf_drop_pattern_imp
static void
pdf_drop_pattern_imp(fz_context *ctx, fz_storable *pat_)
{
pdf_pattern *pat = (pdf_pattern *)pat_;
if (pat->resources)
pdf_drop_obj(ctx, pat->resources);
if (pat->contents)
pdf_drop_obj(ctx, pat->contents);
fz_free(ctx, pat);
}
示例5: pdf_dev_alpha
static void
pdf_dev_alpha(fz_context *ctx, pdf_device *pdev, float alpha, int stroke)
{
int i;
pdf_document *doc = pdev->doc;
gstate *gs = CURRENT_GSTATE(pdev);
/* If the alpha is unchanged, nothing to do */
if (gs->alpha[stroke] == alpha)
return;
/* Have we sent such an alpha before? */
for (i = 0; i < pdev->num_alphas; i++)
if (pdev->alphas[i].alpha == alpha && pdev->alphas[i].stroke == stroke)
break;
if (i == pdev->num_alphas)
{
pdf_obj *o;
pdf_obj *ref = NULL;
fz_var(ref);
/* No. Need to make a new one */
if (pdev->num_alphas == pdev->max_alphas)
{
int newmax = pdev->max_alphas * 2;
if (newmax == 0)
newmax = 4;
pdev->alphas = fz_resize_array(ctx, pdev->alphas, newmax, sizeof(*pdev->alphas));
pdev->max_alphas = newmax;
}
pdev->alphas[i].alpha = alpha;
pdev->alphas[i].stroke = stroke;
o = pdf_new_dict(ctx, doc, 1);
fz_try(ctx)
{
char text[32];
pdf_dict_put_drop(ctx, o, (stroke ? PDF_NAME_CA : PDF_NAME_ca), pdf_new_real(ctx, doc, alpha));
ref = pdf_add_object(ctx, doc, o);
fz_snprintf(text, sizeof(text), "ExtGState/Alp%d", i);
pdf_dict_putp(ctx, pdev->resources, text, ref);
}
fz_always(ctx)
{
pdf_drop_obj(ctx, o);
pdf_drop_obj(ctx, ref);
}
fz_catch(ctx)
{
fz_rethrow(ctx);
}
pdev->num_alphas++;
}
示例6: page_merge
static void page_merge(int page_from, int page_to, pdf_graft_map *graft_map)
{
pdf_obj *pageref = NULL;
pdf_obj *page_dict;
pdf_obj *obj = NULL, *ref = NULL;
/* Include minimal number of objects for page. Do not include items that
* reference other pages */
pdf_obj *known_page_objs[] = { PDF_NAME_Contents, PDF_NAME_Resources,
PDF_NAME_MediaBox, PDF_NAME_CropBox, PDF_NAME_BleedBox, PDF_NAME_TrimBox,
PDF_NAME_ArtBox, PDF_NAME_Rotate, PDF_NAME_UserUnit};
int n = nelem(known_page_objs);
int i;
int num;
fz_var(obj);
fz_var(ref);
fz_try(ctx)
{
pageref = pdf_lookup_page_obj(ctx, doc_src, page_from - 1);
/* Make a new dictionary and copy over the items from the source object to
* the new dict that we want to deep copy. */
page_dict = pdf_new_dict(ctx, doc_des, 4);
pdf_dict_put_drop(ctx, page_dict, PDF_NAME_Type, PDF_NAME_Page);
for (i = 0; i < n; i++)
{
obj = pdf_dict_get(ctx, pageref, known_page_objs[i]);
if (obj != NULL)
pdf_dict_put_drop(ctx, page_dict, known_page_objs[i], pdf_graft_object(ctx, doc_des, doc_src, obj, graft_map));
}
/* Add the dictionary */
obj = pdf_add_object_drop(ctx, doc_des, page_dict);
/* Get indirect ref */
num = pdf_to_num(ctx, obj);
ref = pdf_new_indirect(ctx, doc_des, num, 0);
/* Insert */
pdf_insert_page(ctx, doc_des, page_to - 1, ref);
}
fz_always(ctx)
{
pdf_drop_obj(ctx, obj);
pdf_drop_obj(ctx, ref);
}
fz_catch(ctx)
{
fz_rethrow(ctx);
}
}
示例7: pdf_free_xobject_imp
static void
pdf_free_xobject_imp(fz_context *ctx, fz_storable *xobj_)
{
pdf_xobject *xobj = (pdf_xobject *)xobj_;
if (xobj->colorspace)
fz_drop_colorspace(ctx, xobj->colorspace);
pdf_drop_obj(xobj->resources);
pdf_drop_obj(xobj->contents);
pdf_drop_obj(xobj->me);
fz_free(ctx, xobj);
}
示例8: res_image_init
/* Image specific methods */
static void
res_image_init(fz_context *ctx, pdf_document *doc, pdf_res_table *table)
{
int len, k;
pdf_obj *obj;
pdf_obj *type;
pdf_obj *res = NULL;
fz_image *image = NULL;
unsigned char digest[16];
fz_var(obj);
fz_var(image);
fz_var(res);
fz_try(ctx)
{
table->hash = fz_new_hash_table(ctx, 4096, 16, -1);
len = pdf_count_objects(ctx, doc);
for (k = 1; k < len; k++)
{
obj = pdf_load_object(ctx, doc, k, 0);
type = pdf_dict_get(ctx, obj, PDF_NAME_Subtype);
if (pdf_name_eq(ctx, type, PDF_NAME_Image))
{
image = pdf_load_image(ctx, doc, obj);
res_image_get_md5(ctx, image, digest);
fz_drop_image(ctx, image);
image = NULL;
/* Don't allow overwrites. */
if (fz_hash_find(ctx, table->hash, digest) == NULL)
fz_hash_insert(ctx, table->hash, digest, obj);
}
else
{
pdf_drop_obj(ctx, obj);
}
obj = NULL;
}
}
fz_always(ctx)
{
fz_drop_image(ctx, image);
pdf_drop_obj(ctx, obj);
}
fz_catch(ctx)
{
res_table_free(ctx, table);
fz_rethrow(ctx);
}
}
示例9: fz_var
static pdf_obj *draw_check_button(fz_context *ctx, pdf_annot *annot, fz_rect bbox, fz_matrix matrix, float w, float h, int yes)
{
float black[3] = { 0, 0, 0 };
pdf_obj *ap, *res = NULL;
fz_buffer *buf;
float b;
fz_var(res);
buf = fz_new_buffer(ctx, 1024);
fz_try(ctx)
{
fz_append_string(ctx, buf, "q\n");
if (pdf_write_MK_BG_appearance(ctx, annot, buf))
fz_append_printf(ctx, buf, "0 0 %g %g re\nf\n", w, h);
b = pdf_write_border_appearance(ctx, annot, buf);
if (b > 0 && pdf_write_MK_BC_appearance(ctx, annot, buf))
fz_append_printf(ctx, buf, "%g %g %g %g re\nS\n", b/2, b/2, w-b, h-b);
if (yes)
write_variable_text(ctx, annot, buf, &res, "3", "ZaDb", h, black, 0, w, h, b+h/10, 0.8f, 1.2f, 0, 0, 0);
fz_append_string(ctx, buf, "Q\n");
ap = pdf_new_xobject(ctx, annot->page->doc, bbox, matrix, res, buf);
}
fz_always(ctx)
{
pdf_drop_obj(ctx, res);
fz_drop_buffer(ctx, buf);
}
fz_catch(ctx)
fz_rethrow(ctx);
return ap;
}
示例10: info_update
static void info_update(fz_context *ctx,pdf_document *xref,char *producer)
{
char moddate[64];
time_t now;
struct tm date;
pdf_obj *info;
int newinfo;
if (xref->trailer==NULL)
return;
time(&now);
date=(*localtime(&now));
sprintf(moddate,"D:%04d%02d%02d%02d%02d%02d%s",
date.tm_year+1900,date.tm_mon+1,date.tm_mday,
date.tm_hour,date.tm_min,date.tm_sec,
wsys_utc_string());
info=pdf_dict_gets(xref->trailer,"Info");
if (info==NULL)
{
newinfo=1;
info=pdf_new_dict(ctx,2);
}
else
newinfo=0;
dict_put_string(ctx,info,"Producer",producer);
dict_put_string(ctx,info,"ModDate",moddate);
if (newinfo)
{
pdf_dict_puts(xref->trailer,"Info",info);
pdf_drop_obj(info);
}
}
示例11: 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);
}
}
}
}
示例12: pdf_copy_dict
pdf_obj *
pdf_copy_dict(fz_context *ctx, pdf_obj *obj)
{
pdf_document *doc;
pdf_obj *dict;
int i, n;
RESOLVE(obj);
if (!OBJ_IS_DICT(obj))
fz_throw(ctx, FZ_ERROR_GENERIC, "not a dict (%s)", pdf_objkindstr(obj));
doc = DICT(obj)->doc;
n = pdf_dict_len(ctx, obj);
dict = pdf_new_dict(ctx, doc, n);
fz_try(ctx)
for (i = 0; i < n; i++)
pdf_dict_put(ctx, dict, pdf_dict_get_key(ctx, obj, i), pdf_dict_get_val(ctx, obj, i));
fz_catch(ctx)
{
pdf_drop_obj(ctx, dict);
fz_rethrow(ctx);
}
return dict;
}
示例13: pdf_load_raw_renumbered_stream
fz_buffer *
pdf_load_raw_renumbered_stream(pdf_document *xref, int num, int gen, int orig_num, int orig_gen)
{
fz_stream *stm;
pdf_obj *dict;
int len;
fz_buffer *buf;
if (num > 0 && num < xref->len && xref->table[num].stm_buf)
return fz_keep_buffer(xref->ctx, xref->table[num].stm_buf);
dict = pdf_load_object(xref, num, gen);
/* RJW: "cannot load stream dictionary (%d %d R)", num, gen */
len = pdf_to_int(pdf_dict_gets(dict, "Length"));
pdf_drop_obj(dict);
stm = pdf_open_raw_renumbered_stream(xref, num, gen, orig_num, orig_gen);
/* RJW: "cannot open raw stream (%d %d R)", num, gen */
buf = fz_read_all(stm, len);
/* RJW: "cannot read raw stream (%d %d R)", num, gen */
fz_close(stm);
return buf;
}
示例14: update_field_value
static void update_field_value(pdf_document *doc, pdf_obj *obj, char *text)
{
fz_context *ctx = doc->ctx;
pdf_obj *sobj = NULL;
pdf_obj *grp;
if (!text)
text = "";
/* All fields of the same name should be updated, so
* set the value at the head of the group */
grp = find_head_of_field_group(obj);
if (grp)
obj = grp;
fz_var(sobj);
fz_try(ctx)
{
sobj = pdf_new_string(doc, text, strlen(text));
pdf_dict_puts(obj, "V", sobj);
}
fz_always(ctx)
{
pdf_drop_obj(sobj);
}
fz_catch(ctx)
{
fz_rethrow(ctx);
}
pdf_field_mark_dirty(doc, obj);
}
示例15: pdf_load_raw_renumbered_stream
fz_buffer *
pdf_load_raw_renumbered_stream(fz_context *ctx, pdf_document *doc, int num, int gen, int orig_num, int orig_gen)
{
fz_stream *stm;
pdf_obj *dict;
int len;
fz_buffer *buf;
if (num > 0 && num < pdf_xref_len(ctx, doc))
{
pdf_xref_entry *entry = pdf_get_xref_entry(ctx, doc, num);
if (entry->stm_buf)
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));
pdf_drop_obj(ctx, dict);
stm = pdf_open_raw_renumbered_stream(ctx, doc, num, gen, orig_num, orig_gen);
buf = fz_read_all(ctx, stm, len);
fz_drop_stream(ctx, stm);
return buf;
}