本文整理汇总了C++中pdf_is_array函数的典型用法代码示例。如果您正苦于以下问题:C++ pdf_is_array函数的具体用法?C++ pdf_is_array怎么用?C++ pdf_is_array使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pdf_is_array函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: wmupdf_dict_merge_keyval
/*
** If key doesn't exist, puts key,value pair.
** If key does exist, converts by merging (if dict) or adding (if array)
*/
static void wmupdf_dict_merge_keyval(fz_context *ctx,pdf_obj *dstdict,pdf_obj *key,pdf_obj *value)
{
pdf_obj *dstval;
dstval=pdf_dict_get(dstdict,key);
if (!dstval)
{
pdf_dict_put(dstdict,key,value);
return;
}
/* Values are same--no action required */
if (!pdf_objcmp(dstval,value))
return;
if (pdf_is_dict(dstval) && pdf_is_dict(value))
{
static char *okay_to_merge[] = {"Resources","XObject",""};
int i;
for (i=0;okay_to_merge[i][0]!='\0';i++)
if (!stricmp(okay_to_merge[i],pdf_to_name(key)))
break;
if (okay_to_merge[i][0]!='\0')
{
/* Merge source dict into dest dict */
wmupdf_dict_merge(ctx,pdf_to_name(key),dstval,value);
pdf_dict_put(dstdict,key,dstval);
}
else
/* Just overwrite dest dict with source dict */
pdf_dict_put(dstdict,key,value);
return;
}
/* This works for ProcSet array, but maybe not for any array (e.g. rectangle) */
if (pdf_is_array(dstval) && pdf_is_array(value))
{
wmupdf_array_merge(ctx,pdf_to_name(key),dstval,value);
return;
}
/* Last resort: overwrite with new value */
pdf_dict_put(dstdict,key,value);
/* This does NOT work--you can't just convert the value into an array of values */
/* PDF will become non-conformant. */
/*
array=pdf_new_array(ctx,2);
pdf_array_push(array,dstval);
pdf_array_push(array,value);
pdf_dict_put(dstdict,key,array);
pdf_drop_obj(array);
*/
}
示例2: pdf_stream_has_crypt
/*
* Scan stream dictionary for an explicit /Crypt filter
*/
static int
pdf_stream_has_crypt(fz_context *ctx, pdf_obj *stm)
{
pdf_obj *filters;
pdf_obj *obj;
int i;
filters = pdf_dict_getsa(stm, "Filter", "F");
if (filters)
{
if (!strcmp(pdf_to_name(filters), "Crypt"))
return 1;
if (pdf_is_array(filters))
{
int n = pdf_array_len(filters);
for (i = 0; i < n; i++)
{
obj = pdf_array_get(filters, i);
if (!strcmp(pdf_to_name(obj), "Crypt"))
return 1;
}
}
}
return 0;
}
示例3: pdf_stream_has_crypt
/*
* Scan stream dictionary for an explicit /Crypt filter
*/
static int
pdf_stream_has_crypt(fz_context *ctx, pdf_obj *stm)
{
pdf_obj *filters;
pdf_obj *obj;
int i;
filters = pdf_dict_geta(ctx, stm, PDF_NAME_Filter, PDF_NAME_F);
if (filters)
{
if (pdf_name_eq(ctx, filters, PDF_NAME_Crypt))
return 1;
if (pdf_is_array(ctx, filters))
{
int n = pdf_array_len(ctx, filters);
for (i = 0; i < n; i++)
{
obj = pdf_array_get(ctx, filters, i);
if (pdf_name_eq(ctx, obj, PDF_NAME_Crypt))
return 1;
}
}
}
return 0;
}
示例4: pdf_annot_color_imp
static void
pdf_annot_color_imp(fz_context *ctx, pdf_annot *annot, pdf_obj *key, int *n, float color[4])
{
pdf_obj *obj = pdf_dict_get(ctx, annot->obj, key);
*n = 0;
if (pdf_is_array(ctx, obj))
{
switch (pdf_array_len(ctx, obj))
{
case 1:
*n = 1;
color[0] = pdf_to_real(ctx, pdf_array_get(ctx, obj, 0));
break;
case 3:
*n = 3;
color[0] = pdf_to_real(ctx, pdf_array_get(ctx, obj, 0));
color[1] = pdf_to_real(ctx, pdf_array_get(ctx, obj, 1));
color[2] = pdf_to_real(ctx, pdf_array_get(ctx, obj, 2));
break;
case 4:
*n = 4;
color[0] = pdf_to_real(ctx, pdf_array_get(ctx, obj, 0));
color[1] = pdf_to_real(ctx, pdf_array_get(ctx, obj, 1));
color[2] = pdf_to_real(ctx, pdf_array_get(ctx, obj, 2));
color[3] = pdf_to_real(ctx, pdf_array_get(ctx, obj, 3));
break;
}
}
}
示例5: adjust_bleed_clipping
int adjust_bleed_clipping(fz_context *ctx, pdf_document *doc, pdf_page *page, struct pos_info *pos)
{
/* We clip each page two times... The first clipping rectangle just
prevents the page from drawing outside of its area on the sheet.
The second clipping is done here and clips out all those things that
are located outside the bleed-box (e. g. printer's marks). */
pdf_obj *bleed_box =
juggler_lookup_inherited_page_item(ctx, doc, page->me, "BleedBox");
/* if no bleeding-box exists, there is no need for the second clipping */
if(bleed_box == NULL) {
pos->bleed_clip_x = pos->bleed_clip_y =
pos->bleed_clip_width = pos->bleed_clip_height = 0.0;
return(0);
}
if(!pdf_is_array(ctx, bleed_box) || pdf_array_len(ctx, bleed_box) != 4)
return(-1);
fz_rect bleed_rect;
pdf_to_rect(ctx, bleed_box, &bleed_rect);
pos->bleed_clip_x = bleed_rect.x0;
pos->bleed_clip_y = bleed_rect.y0;
pos->bleed_clip_width = bleed_rect.x1 - bleed_rect.x0;
pos->bleed_clip_height = bleed_rect.y1 - bleed_rect.y0;
return(0);
}
示例6: gatherdimensions
static void
gatherdimensions(int page, pdf_obj *pageref, pdf_obj *pageobj)
{
fz_rect bbox;
pdf_obj *obj;
int j;
obj = pdf_dict_gets(pageobj, "MediaBox");
if (!pdf_is_array(obj))
return;
bbox = pdf_to_rect(ctx, obj);
for (j = 0; j < dims; j++)
if (!memcmp(dim[j].u.dim.bbox, &bbox, sizeof (fz_rect)))
break;
if (j < dims)
return;
dims++;
dim = fz_resize_array(ctx, dim, dims, sizeof(struct info));
dim[dims - 1].page = page;
dim[dims - 1].pageref = pageref;
dim[dims - 1].pageobj = pageobj;
dim[dims - 1].u.dim.bbox = fz_malloc(ctx, sizeof(fz_rect));
memcpy(dim[dims - 1].u.dim.bbox, &bbox, sizeof (fz_rect));
return;
}
示例7: resolve_dest_rec
static pdf_obj *
resolve_dest_rec(fz_context *ctx, pdf_document *doc, pdf_obj *dest, int depth)
{
if (depth > 10) /* Arbitrary to avoid infinite recursion */
return NULL;
if (pdf_is_name(ctx, dest) || pdf_is_string(ctx, dest))
{
dest = pdf_lookup_dest(ctx, doc, dest);
dest = resolve_dest_rec(ctx, doc, dest, depth+1);
return dest;
}
else if (pdf_is_array(ctx, dest))
{
return dest;
}
else if (pdf_is_dict(ctx, dest))
{
dest = pdf_dict_get(ctx, dest, PDF_NAME_D);
return resolve_dest_rec(ctx, doc, dest, depth+1);
}
else if (pdf_is_indirect(ctx, dest))
return dest;
return NULL;
}
示例8: resolve_dest_rec
static pdf_obj *
resolve_dest_rec(pdf_document *xref, pdf_obj *dest, int depth)
{
if (depth > 10) /* Arbitrary to avoid infinite recursion */
return NULL;
if (pdf_is_name(dest) || pdf_is_string(dest))
{
dest = pdf_lookup_dest(xref, dest);
return resolve_dest_rec(xref, dest, depth+1);
}
else if (pdf_is_array(dest))
{
return dest;
}
else if (pdf_is_dict(dest))
{
dest = pdf_dict_gets(dest, "D");
return resolve_dest_rec(xref, dest, depth+1);
}
else if (pdf_is_indirect(dest))
return dest;
return NULL;
}
示例9: 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);
}
示例10: pdf_add_annot_quad_point
void
pdf_add_annot_quad_point(fz_context *ctx, pdf_annot *annot, fz_rect bbox)
{
pdf_document *doc = annot->page->doc;
fz_matrix page_ctm, inv_page_ctm;
pdf_obj *quad_points;
check_allowed_subtypes(ctx, annot, PDF_NAME(QuadPoints), quad_point_subtypes);
pdf_page_transform(ctx, annot->page, NULL, &page_ctm);
fz_invert_matrix(&inv_page_ctm, &page_ctm);
quad_points = pdf_dict_get(ctx, annot->obj, PDF_NAME(QuadPoints));
if (!pdf_is_array(ctx, quad_points))
{
quad_points = pdf_new_array(ctx, doc, 8);
pdf_dict_put_drop(ctx, annot->obj, PDF_NAME(QuadPoints), quad_points);
}
/* Contrary to the specification, the points within a QuadPoint are NOT ordered
* in a counterclockwise fashion. Experiments with Adobe's implementation
* indicates a cross-wise ordering is intended: ul, ur, ll, lr.
*/
fz_transform_rect(&bbox, &inv_page_ctm);
pdf_array_push_real(ctx, quad_points, bbox.x0); /* ul */
pdf_array_push_real(ctx, quad_points, bbox.y1);
pdf_array_push_real(ctx, quad_points, bbox.x1); /* ur */
pdf_array_push_real(ctx, quad_points, bbox.y1);
pdf_array_push_real(ctx, quad_points, bbox.x0); /* ll */
pdf_array_push_real(ctx, quad_points, bbox.y0);
pdf_array_push_real(ctx, quad_points, bbox.x1); /* lr */
pdf_array_push_real(ctx, quad_points, bbox.y0);
pdf_dirty_annot(ctx, annot);
}
示例11: adjust_page_position
int adjust_page_position(fz_context *ctx, pdf_document *doc, pdf_page *page, struct pos_info *pos)
{
/* if page is rotated we must add this to the desired rotation of the page */
pos->rotate = (pos->rotate + page->rotate) % 360;
fz_matrix rotation_mtx; /* tranformation of the user-space due to the rotation */
fz_rotate(&rotation_mtx, page->rotate);
/* get the media-box (with rotation applied) */
pdf_obj *media_box = juggler_lookup_inherited_page_item(ctx, doc, page->me, "MediaBox");
if(!pdf_is_array(ctx, media_box) || pdf_array_len(ctx, media_box) != 4)
return(-1); /* the specification forces a valid media-box... */
fz_rect media_rect;
pdf_to_rect(ctx, media_box, &media_rect);
fz_transform_rect(&media_rect, &rotation_mtx);
/* get trim-box */
pdf_obj *trim_box = juggler_lookup_inherited_page_item(ctx, doc, page->me, "TrimBox");
if(trim_box == NULL)
trim_box = media_box;
if(!pdf_is_array(ctx, trim_box) || pdf_array_len(ctx, trim_box) != 4)
return(-2);
fz_rect trim_rect;
pdf_to_rect(ctx, trim_box, &trim_rect);
fz_transform_rect(&trim_rect, &rotation_mtx);
// TODO: Take scale into account
double available_width = pos->width;
double available_height = pos->height;
double page_width = trim_rect.x1 - trim_rect.x0;
double page_height = trim_rect.y1 - trim_rect.y0;
/* position the page in the middle of the destination area */
pos->content_translate_x =
media_rect.x0 - trim_rect.x0 + (available_width - page_width) / 2;
pos->content_translate_y =
media_rect.y0 - trim_rect.y0 + (available_height - page_height) / 2;
/* if needed, clip the contents to the bleed-box */
if(adjust_bleed_clipping(ctx, doc, page, pos) < 0)
return(-2);
return(0);
}
示例12: pdf_annot_border
float
pdf_annot_border(fz_context *ctx, pdf_annot *annot)
{
pdf_obj *border = pdf_dict_get(ctx, annot->obj, PDF_NAME_Border);
if (pdf_is_array(ctx, border))
return pdf_to_real(ctx, pdf_array_get(ctx, border, 2));
return 1;
}
示例13: 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);
}
示例14: load_separation
static fz_colorspace *
load_separation(pdf_document *xref, pdf_obj *array)
{
fz_colorspace *cs;
struct separation *sep = NULL;
fz_context *ctx = xref->ctx;
pdf_obj *nameobj = pdf_array_get(array, 1);
pdf_obj *baseobj = pdf_array_get(array, 2);
pdf_obj *tintobj = pdf_array_get(array, 3);
fz_colorspace *base;
pdf_function *tint = NULL;
int n;
fz_var(tint);
fz_var(sep);
if (pdf_is_array(nameobj))
n = pdf_array_len(nameobj);
else
n = 1;
if (n > FZ_MAX_COLORS)
fz_throw(ctx, "too many components in colorspace");
base = pdf_load_colorspace(xref, baseobj);
/* RJW: "cannot load base colorspace (%d %d R)", pdf_to_num(baseobj), pdf_to_gen(baseobj) */
fz_try(ctx)
{
tint = pdf_load_function(xref, tintobj);
/* RJW: fz_drop_colorspace(ctx, base);
* "cannot load tint function (%d %d R)", pdf_to_num(tintobj), pdf_to_gen(tintobj) */
sep = fz_malloc_struct(ctx, struct separation);
sep->base = base;
sep->tint = tint;
cs = fz_new_colorspace(ctx, n == 1 ? "Separation" : "DeviceN", n);
cs->to_rgb = separation_to_rgb;
cs->free_data = free_separation;
cs->data = sep;
cs->size += sizeof(struct separation) + (base ? base->size : 0) + pdf_function_size(tint);
}
fz_catch(ctx)
{
fz_drop_colorspace(ctx, base);
pdf_drop_function(ctx, tint);
fz_free(ctx, sep);
fz_rethrow(ctx);
}
return cs;
}
示例15: 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;
}