summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/pdf/pdf-annot-edit.c44
-rw-r--r--source/pdf/pdf-annot.c16
-rw-r--r--source/pdf/pdf-clean-file.c2
-rw-r--r--source/pdf/pdf-clean.c2
-rw-r--r--source/pdf/pdf-colorspace.c10
-rw-r--r--source/pdf/pdf-field.c2
-rw-r--r--source/pdf/pdf-font.c65
-rw-r--r--source/pdf/pdf-form.c26
-rw-r--r--source/pdf/pdf-function.c26
-rw-r--r--source/pdf/pdf-image.c8
-rw-r--r--source/pdf/pdf-interpret.c4
-rw-r--r--source/pdf/pdf-layer.c8
-rw-r--r--source/pdf/pdf-op-run.c6
-rw-r--r--source/pdf/pdf-page.c12
-rw-r--r--source/pdf/pdf-parse.c20
-rw-r--r--source/pdf/pdf-pattern.c6
-rw-r--r--source/pdf/pdf-portfolio.c2
-rw-r--r--source/pdf/pdf-repair.c2
-rw-r--r--source/pdf/pdf-shade.c66
-rw-r--r--source/pdf/pdf-signature.c4
-rw-r--r--source/pdf/pdf-stream.c12
-rw-r--r--source/pdf/pdf-type3.c6
-rw-r--r--source/pdf/pdf-xobject.c4
-rw-r--r--source/pdf/pdf-xref.c28
-rw-r--r--source/tools/pdfposter.c8
25 files changed, 186 insertions, 203 deletions
diff --git a/source/pdf/pdf-annot-edit.c b/source/pdf/pdf-annot-edit.c
index c76b2446..c06fa05a 100644
--- a/source/pdf/pdf-annot-edit.c
+++ b/source/pdf/pdf-annot-edit.c
@@ -227,7 +227,7 @@ pdf_annot_type(fz_context *ctx, pdf_annot *annot)
int
pdf_annot_flags(fz_context *ctx, pdf_annot *annot)
{
- return pdf_to_int(ctx, pdf_dict_get(ctx, annot->obj, PDF_NAME(F)));
+ return pdf_dict_get_int(ctx, annot->obj, PDF_NAME(F));
}
void
@@ -289,7 +289,7 @@ int
pdf_annot_is_open(fz_context *ctx, pdf_annot *annot)
{
check_allowed_subtypes(ctx, annot, PDF_NAME(Open), open_subtypes);
- return pdf_to_bool(ctx, pdf_dict_get(ctx, annot->obj, PDF_NAME(Open)));
+ return pdf_dict_get_bool(ctx, annot->obj, PDF_NAME(Open));
}
void
@@ -502,7 +502,7 @@ pdf_set_annot_border(fz_context *ctx, pdf_annot *annot, float w)
int
pdf_annot_quadding(fz_context *ctx, pdf_annot *annot)
{
- int q = pdf_to_int(ctx, pdf_dict_get(ctx, annot->obj, PDF_NAME(Q)));
+ int q = pdf_dict_get_int(ctx, annot->obj, PDF_NAME(Q));
return (q < 0 || q > 2) ? 0 : q;
}
@@ -553,16 +553,16 @@ static void pdf_annot_color_imp(fz_context *ctx, pdf_annot *annot, pdf_obj *key,
if (n)
*n = 1;
if (color)
- color[0] = pdf_to_real(ctx, pdf_array_get(ctx, arr, 0));
+ color[0] = pdf_array_get_real(ctx, arr, 0);
break;
case 3:
if (n)
*n = 3;
if (color)
{
- color[0] = pdf_to_real(ctx, pdf_array_get(ctx, arr, 0));
- color[1] = pdf_to_real(ctx, pdf_array_get(ctx, arr, 1));
- color[2] = pdf_to_real(ctx, pdf_array_get(ctx, arr, 2));
+ color[0] = pdf_array_get_real(ctx, arr, 0);
+ color[1] = pdf_array_get_real(ctx, arr, 1);
+ color[2] = pdf_array_get_real(ctx, arr, 2);
}
break;
case 4:
@@ -571,10 +571,10 @@ static void pdf_annot_color_imp(fz_context *ctx, pdf_annot *annot, pdf_obj *key,
*n = 4;
if (color)
{
- color[0] = pdf_to_real(ctx, pdf_array_get(ctx, arr, 0));
- color[1] = pdf_to_real(ctx, pdf_array_get(ctx, arr, 1));
- color[2] = pdf_to_real(ctx, pdf_array_get(ctx, arr, 2));
- color[3] = pdf_to_real(ctx, pdf_array_get(ctx, arr, 3));
+ color[0] = pdf_array_get_real(ctx, arr, 0);
+ color[1] = pdf_array_get_real(ctx, arr, 1);
+ color[2] = pdf_array_get_real(ctx, arr, 2);
+ color[3] = pdf_array_get_real(ctx, arr, 3);
}
break;
}
@@ -684,10 +684,10 @@ pdf_annot_line(fz_context *ctx, pdf_annot *annot, fz_point *a, fz_point *b)
pdf_page_transform(ctx, annot->page, NULL, &page_ctm);
line = pdf_dict_get(ctx, annot->obj, PDF_NAME(L));
- a->x = pdf_to_real(ctx, pdf_array_get(ctx, line, 0));
- a->y = pdf_to_real(ctx, pdf_array_get(ctx, line, 1));
- b->x = pdf_to_real(ctx, pdf_array_get(ctx, line, 2));
- b->y = pdf_to_real(ctx, pdf_array_get(ctx, line, 3));
+ a->x = pdf_array_get_real(ctx, line, 0);
+ a->y = pdf_array_get_real(ctx, line, 1);
+ b->x = pdf_array_get_real(ctx, line, 2);
+ b->y = pdf_array_get_real(ctx, line, 3);
fz_transform_point(a, &page_ctm);
fz_transform_point(b, &page_ctm);
}
@@ -750,8 +750,8 @@ pdf_annot_vertex(fz_context *ctx, pdf_annot *annot, int i)
pdf_page_transform(ctx, annot->page, NULL, &page_ctm);
- point.x = pdf_to_real(ctx, pdf_array_get(ctx, vertices, i * 2));
- point.y = pdf_to_real(ctx, pdf_array_get(ctx, vertices, i * 2 + 1));
+ point.x = pdf_array_get_real(ctx, vertices, i * 2);
+ point.y = pdf_array_get_real(ctx, vertices, i * 2 + 1);
fz_transform_point(&point, &page_ctm);
return point;
@@ -872,8 +872,8 @@ pdf_annot_quad_point(fz_context *ctx, pdf_annot *annot, int idx, float v[8])
for (i = 0; i < 8; i += 2)
{
fz_point point;
- point.x = pdf_to_real(ctx, pdf_array_get(ctx, quad_points, idx * 8 + i + 0));
- point.y = pdf_to_real(ctx, pdf_array_get(ctx, quad_points, idx * 8 + i + 1));
+ point.x = pdf_array_get_real(ctx, quad_points, idx * 8 + i + 0);
+ point.y = pdf_array_get_real(ctx, quad_points, idx * 8 + i + 1);
fz_transform_point(&point, &page_ctm);
v[i+0] = point.x;
v[i+1] = point.y;
@@ -1002,8 +1002,8 @@ pdf_annot_ink_list_stroke_vertex(fz_context *ctx, pdf_annot *annot, int i, int k
pdf_page_transform(ctx, annot->page, NULL, &page_ctm);
- point.x = pdf_to_real(ctx, pdf_array_get(ctx, stroke, k * 2 + 0));
- point.y = pdf_to_real(ctx, pdf_array_get(ctx, stroke, k * 2 + 1));
+ point.x = pdf_array_get_real(ctx, stroke, k * 2 + 0);
+ point.y = pdf_array_get_real(ctx, stroke, k * 2 + 1);
fz_transform_point(&point, &page_ctm);
return point;
@@ -1110,7 +1110,7 @@ pdf_set_text_annot_position(fz_context *ctx, pdf_annot *annot, fz_point pt)
pdf_dict_put_rect(ctx, annot->obj, PDF_NAME(Rect), &rect);
- flags = pdf_to_int(ctx, pdf_dict_get(ctx, annot->obj, PDF_NAME(F)));
+ flags = pdf_dict_get_int(ctx, annot->obj, PDF_NAME(F));
flags |= (PDF_ANNOT_IS_NO_ZOOM|PDF_ANNOT_IS_NO_ROTATE);
pdf_dict_put_int(ctx, annot->obj, PDF_NAME(F), flags);
}
diff --git a/source/pdf/pdf-annot.c b/source/pdf/pdf-annot.c
index b1bddf5c..d142d454 100644
--- a/source/pdf/pdf-annot.c
+++ b/source/pdf/pdf-annot.c
@@ -81,18 +81,18 @@ pdf_parse_link_dest(fz_context *ctx, pdf_document *doc, pdf_obj *dest)
obj = pdf_array_get(ctx, dest, 1);
if (pdf_name_eq(ctx, obj, PDF_NAME(XYZ)))
{
- x = pdf_to_int(ctx, pdf_array_get(ctx, dest, 2));
- y = pdf_to_int(ctx, pdf_array_get(ctx, dest, 3));
+ x = pdf_array_get_int(ctx, dest, 2);
+ y = pdf_array_get_int(ctx, dest, 3);
}
else if (pdf_name_eq(ctx, obj, PDF_NAME(FitR)))
{
- x = pdf_to_int(ctx, pdf_array_get(ctx, dest, 2));
- y = pdf_to_int(ctx, pdf_array_get(ctx, dest, 5));
+ x = pdf_array_get_int(ctx, dest, 2);
+ y = pdf_array_get_int(ctx, dest, 5);
}
else if (pdf_name_eq(ctx, obj, PDF_NAME(FitH)) || pdf_name_eq(ctx, obj, PDF_NAME(FitBH)))
- y = pdf_to_int(ctx, pdf_array_get(ctx, dest, 2));
+ y = pdf_array_get_int(ctx, dest, 2);
else if (pdf_name_eq(ctx, obj, PDF_NAME(FitV)) || pdf_name_eq(ctx, obj, PDF_NAME(FitBV)))
- x = pdf_to_int(ctx, pdf_array_get(ctx, dest, 2));
+ x = pdf_array_get_int(ctx, dest, 2);
if (page >= 0)
{
@@ -154,7 +154,7 @@ pdf_parse_file_spec(fz_context *ctx, pdf_document *doc, pdf_obj *file_spec, pdf_
#endif
if (pdf_is_array(ctx, dest))
- fz_snprintf(buf, sizeof buf, "#page=%d", pdf_to_int(ctx, pdf_array_get(ctx, dest, 0)) + 1);
+ fz_snprintf(buf, sizeof buf, "#page=%d", pdf_array_get_int(ctx, dest, 0) + 1);
else if (pdf_is_name(ctx, dest))
fz_snprintf(buf, sizeof buf, "#%s", pdf_to_name(ctx, dest));
else if (pdf_is_string(ctx, dest))
@@ -188,7 +188,7 @@ pdf_parse_link_action(fz_context *ctx, pdf_document *doc, pdf_obj *action, int p
else if (pdf_name_eq(ctx, PDF_NAME(URI), obj))
{
/* URI entries are ASCII strings */
- const char *uri = pdf_to_str_buf(ctx, pdf_dict_get(ctx, action, PDF_NAME(URI)));
+ const char *uri = pdf_dict_get_string(ctx, action, PDF_NAME(URI), NULL);
if (!fz_is_external_link(ctx, uri))
{
pdf_obj *uri_base_obj = pdf_dict_getp(ctx, pdf_trailer(ctx, doc), "Root/URI/Base");
diff --git a/source/pdf/pdf-clean-file.c b/source/pdf/pdf-clean-file.c
index 86199f22..2a2fd7bc 100644
--- a/source/pdf/pdf-clean-file.c
+++ b/source/pdf/pdf-clean-file.c
@@ -164,7 +164,7 @@ static int strip_outlines(fz_context *ctx, pdf_document *doc, pdf_obj *outlines,
}
else
{
- int old_count = pdf_to_int(ctx, pdf_dict_get(ctx, outlines, PDF_NAME(Count)));
+ int old_count = pdf_dict_get_int(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_int(ctx, outlines, PDF_NAME(Count), old_count > 0 ? nc : -nc);
diff --git a/source/pdf/pdf-clean.c b/source/pdf/pdf-clean.c
index 4e8dd3f4..3a97a8fb 100644
--- a/source/pdf/pdf-clean.c
+++ b/source/pdf/pdf-clean.c
@@ -243,7 +243,7 @@ void pdf_filter_page_contents(fz_context *ctx, pdf_document *doc, pdf_page *page
pat_res = pdf_dict_get(ctx, pat, PDF_NAME(Resources));
if (pat_res == NULL)
pat_res = resources;
- if (pdf_to_int(ctx, pdf_dict_get(ctx, pat, PDF_NAME(PatternType))) == 1)
+ if (pdf_dict_get_int(ctx, pat, PDF_NAME(PatternType)) == 1)
pdf_clean_stream_object(ctx, doc, pat, pat_res, cookie, 0, text_filter, after_text, proc_arg, sanitize, ascii);
}
}
diff --git a/source/pdf/pdf-colorspace.c b/source/pdf/pdf-colorspace.c
index ec4da7b0..a1d7d77c 100644
--- a/source/pdf/pdf-colorspace.c
+++ b/source/pdf/pdf-colorspace.c
@@ -52,7 +52,7 @@ load_icc_based(fz_context *ctx, pdf_obj *dict, int alt)
cs_alt = NULL;
}
- n = pdf_to_int(ctx, pdf_dict_get(ctx, dict, PDF_NAME(N)));
+ n = pdf_dict_get_int(ctx, dict, PDF_NAME(N));
fz_try(ctx)
{
@@ -320,7 +320,7 @@ pdf_load_cal_common(fz_context *ctx, pdf_obj *dict, float *wp, float *bp, float
for (i = 0; i < 3; i++)
{
- wp[i] = pdf_to_real(ctx, pdf_array_get(ctx, obj, i));
+ wp[i] = pdf_array_get_real(ctx, obj, i);
if (wp[i] < 0)
fz_throw(ctx, FZ_ERROR_SYNTAX, "WhitePoint numbers must be positive");
}
@@ -332,7 +332,7 @@ pdf_load_cal_common(fz_context *ctx, pdf_obj *dict, float *wp, float *bp, float
{
for (i = 0; i < 3; i++)
{
- bp[i] = pdf_to_real(ctx, pdf_array_get(ctx, obj, i));
+ bp[i] = pdf_array_get_real(ctx, obj, i);
if (bp[i] < 0)
fz_throw(ctx, FZ_ERROR_SYNTAX, "BlackPoint numbers must be positive");
}
@@ -350,7 +350,7 @@ pdf_load_cal_common(fz_context *ctx, pdf_obj *dict, float *wp, float *bp, float
{
for (i = 0; i < 3; i++)
{
- gamma[i] = pdf_to_real(ctx, pdf_array_get(ctx, obj, i));
+ gamma[i] = pdf_array_get_real(ctx, obj, i);
if (gamma[i] <= 0)
fz_throw(ctx, FZ_ERROR_SYNTAX, "Gamma must be greater than zero");
}
@@ -398,7 +398,7 @@ pdf_load_cal_rgb(fz_context *ctx, pdf_obj *dict)
if (pdf_array_len(ctx, obj) == 9)
{
for (i = 0; i < 9; i++)
- matrix[i] = pdf_to_real(ctx, pdf_array_get(ctx, obj, i));
+ matrix[i] = pdf_array_get_real(ctx, obj, i);
}
}
fz_catch(ctx)
diff --git a/source/pdf/pdf-field.c b/source/pdf/pdf-field.c
index 7989db8d..07a6e770 100644
--- a/source/pdf/pdf-field.c
+++ b/source/pdf/pdf-field.c
@@ -146,7 +146,7 @@ void pdf_set_field_type(fz_context *ctx, pdf_document *doc, pdf_obj *obj, int ty
if (setbits != 0 || clearbits != 0)
{
- int bits = pdf_to_int(ctx, pdf_dict_get(ctx, obj, PDF_NAME(Ff)));
+ int bits = pdf_dict_get_int(ctx, obj, PDF_NAME(Ff));
bits &= ~clearbits;
bits |= setbits;
pdf_dict_put_int(ctx, obj, PDF_NAME(Ff), bits);
diff --git a/source/pdf/pdf-font.c b/source/pdf/pdf-font.c
index 106a6657..82739ccb 100644
--- a/source/pdf/pdf-font.c
+++ b/source/pdf/pdf-font.c
@@ -661,7 +661,7 @@ pdf_load_simple_font_by_name(fz_context *ctx, pdf_document *doc, pdf_obj *dict,
if (descriptor && pdf_is_string(ctx, pdf_dict_get(ctx, descriptor, PDF_NAME(FontName))) &&
!pdf_dict_get(ctx, dict, PDF_NAME(ToUnicode)) &&
pdf_name_eq(ctx, pdf_dict_get(ctx, dict, PDF_NAME(Encoding)), PDF_NAME(WinAnsiEncoding)) &&
- pdf_to_int(ctx, pdf_dict_get(ctx, descriptor, PDF_NAME(Flags))) == 4)
+ pdf_dict_get_int(ctx, descriptor, PDF_NAME(Flags)) == 4)
{
char *cp936fonts[] = {
"\xCB\xCE\xCC\xE5", "SimSun,Regular",
@@ -900,15 +900,15 @@ pdf_load_simple_font_by_name(fz_context *ctx, pdf_document *doc, pdf_obj *dict,
{
int first, last;
- first = pdf_to_int(ctx, pdf_dict_get(ctx, dict, PDF_NAME(FirstChar)));
- last = pdf_to_int(ctx, pdf_dict_get(ctx, dict, PDF_NAME(LastChar)));
+ first = pdf_dict_get_int(ctx, dict, PDF_NAME(FirstChar));
+ last = pdf_dict_get_int(ctx, dict, PDF_NAME(LastChar));
if (first < 0 || last > 255 || first > last)
first = last = 0;
for (i = 0; i < last - first + 1; i++)
{
- int wid = pdf_to_int(ctx, pdf_array_get(ctx, widths, i));
+ int wid = pdf_array_get_int(ctx, widths, i);
pdf_add_hmtx(ctx, fontdesc, i + first, i + first, wid);
}
}
@@ -1032,26 +1032,15 @@ load_cid_font(fz_context *ctx, pdf_document *doc, pdf_obj *dict, pdf_obj *encodi
{
pdf_obj *cidinfo;
- char tmpstr[64];
- int tmplen;
+ const char *reg, *ord;
cidinfo = pdf_dict_get(ctx, dict, PDF_NAME(CIDSystemInfo));
if (!cidinfo)
fz_throw(ctx, FZ_ERROR_SYNTAX, "cid font is missing info");
- obj = pdf_dict_get(ctx, cidinfo, PDF_NAME(Registry));
- tmplen = fz_mini(sizeof tmpstr - 1, pdf_to_str_len(ctx, obj));
- memcpy(tmpstr, pdf_to_str_buf(ctx, obj), tmplen);
- tmpstr[tmplen] = '\0';
- fz_strlcpy(collection, tmpstr, sizeof collection);
-
- fz_strlcat(collection, "-", sizeof collection);
-
- obj = pdf_dict_get(ctx, cidinfo, PDF_NAME(Ordering));
- tmplen = fz_mini(sizeof tmpstr - 1, pdf_to_str_len(ctx, obj));
- memcpy(tmpstr, pdf_to_str_buf(ctx, obj), tmplen);
- tmpstr[tmplen] = '\0';
- fz_strlcat(collection, tmpstr, sizeof collection);
+ reg = pdf_dict_get_string(ctx, cidinfo, PDF_NAME(Registry), NULL);
+ ord = pdf_dict_get_string(ctx, cidinfo, PDF_NAME(Ordering), NULL);
+ fz_snprintf(collection, sizeof collection, "%s-%s", reg, ord);
}
/* Encoding */
@@ -1156,14 +1145,14 @@ load_cid_font(fz_context *ctx, pdf_document *doc, pdf_obj *dict, pdf_obj *encodi
n = pdf_array_len(ctx, widths);
for (i = 0; i < n; )
{
- c0 = pdf_to_int(ctx, pdf_array_get(ctx, widths, i));
+ c0 = pdf_array_get_int(ctx, widths, i);
obj = pdf_array_get(ctx, widths, i + 1);
if (pdf_is_array(ctx, obj))
{
m = pdf_array_len(ctx, obj);
for (k = 0; k < m; k++)
{
- w = pdf_to_int(ctx, pdf_array_get(ctx, obj, k));
+ w = pdf_array_get_int(ctx, obj, k);
pdf_add_hmtx(ctx, fontdesc, c0 + k, c0 + k, w);
}
i += 2;
@@ -1171,7 +1160,7 @@ load_cid_font(fz_context *ctx, pdf_document *doc, pdf_obj *dict, pdf_obj *encodi
else
{
c1 = pdf_to_int(ctx, obj);
- w = pdf_to_int(ctx, pdf_array_get(ctx, widths, i + 2));
+ w = pdf_array_get_int(ctx, widths, i + 2);
pdf_add_hmtx(ctx, fontdesc, c0, c1, w);
i += 3;
}
@@ -1190,8 +1179,8 @@ load_cid_font(fz_context *ctx, pdf_document *doc, pdf_obj *dict, pdf_obj *encodi
obj = pdf_dict_get(ctx, dict, PDF_NAME(DW2));
if (obj)
{
- dw2y = pdf_to_int(ctx, pdf_array_get(ctx, obj, 0));
- dw2w = pdf_to_int(ctx, pdf_array_get(ctx, obj, 1));
+ dw2y = pdf_array_get_int(ctx, obj, 0);
+ dw2w = pdf_array_get_int(ctx, obj, 1);
}
pdf_set_default_vmtx(ctx, fontdesc, dw2y, dw2w);
@@ -1204,16 +1193,16 @@ load_cid_font(fz_context *ctx, pdf_document *doc, pdf_obj *dict, pdf_obj *encodi
n = pdf_array_len(ctx, widths);
for (i = 0; i < n; )
{
- c0 = pdf_to_int(ctx, pdf_array_get(ctx, widths, i));
+ c0 = pdf_array_get_int(ctx, widths, i);
obj = pdf_array_get(ctx, widths, i + 1);
if (pdf_is_array(ctx, obj))
{
int m = pdf_array_len(ctx, obj);
for (k = 0; k * 3 < m; k ++)
{
- w = pdf_to_int(ctx, pdf_array_get(ctx, obj, k * 3 + 0));
- x = pdf_to_int(ctx, pdf_array_get(ctx, obj, k * 3 + 1));
- y = pdf_to_int(ctx, pdf_array_get(ctx, obj, k * 3 + 2));
+ w = pdf_array_get_int(ctx, obj, k * 3 + 0);
+ x = pdf_array_get_int(ctx, obj, k * 3 + 1);
+ y = pdf_array_get_int(ctx, obj, k * 3 + 2);
pdf_add_vmtx(ctx, fontdesc, c0 + k, c0 + k, x, y, w);
}
i += 2;
@@ -1221,9 +1210,9 @@ load_cid_font(fz_context *ctx, pdf_document *doc, pdf_obj *dict, pdf_obj *encodi
else
{
c1 = pdf_to_int(ctx, obj);
- w = pdf_to_int(ctx, pdf_array_get(ctx, widths, i + 2));
- x = pdf_to_int(ctx, pdf_array_get(ctx, widths, i + 3));
- y = pdf_to_int(ctx, pdf_array_get(ctx, widths, i + 4));
+ w = pdf_array_get_int(ctx, widths, i + 2);
+ x = pdf_array_get_int(ctx, widths, i + 3);
+ y = pdf_array_get_int(ctx, widths, i + 4);
pdf_add_vmtx(ctx, fontdesc, c0, c1, x, y, w);
i += 5;
}
@@ -1283,13 +1272,13 @@ pdf_load_font_descriptor(fz_context *ctx, pdf_document *doc, pdf_font_desc *font
/* Prefer BaseFont; don't bother with FontName */
fontname = basefont;
- fontdesc->flags = pdf_to_int(ctx, pdf_dict_get(ctx, dict, PDF_NAME(Flags)));
- fontdesc->italic_angle = pdf_to_real(ctx, pdf_dict_get(ctx, dict, PDF_NAME(ItalicAngle)));
- fontdesc->ascent = pdf_to_real(ctx, pdf_dict_get(ctx, dict, PDF_NAME(Ascent)));
- fontdesc->descent = pdf_to_real(ctx, pdf_dict_get(ctx, dict, PDF_NAME(Descent)));
- fontdesc->cap_height = pdf_to_real(ctx, pdf_dict_get(ctx, dict, PDF_NAME(CapHeight)));
- fontdesc->x_height = pdf_to_real(ctx, pdf_dict_get(ctx, dict, PDF_NAME(XHeight)));
- fontdesc->missing_width = pdf_to_real(ctx, pdf_dict_get(ctx, dict, PDF_NAME(MissingWidth)));
+ fontdesc->flags = pdf_dict_get_int(ctx, dict, PDF_NAME(Flags));
+ fontdesc->italic_angle = pdf_dict_get_real(ctx, dict, PDF_NAME(ItalicAngle));
+ fontdesc->ascent = pdf_dict_get_real(ctx, dict, PDF_NAME(Ascent));
+ fontdesc->descent = pdf_dict_get_real(ctx, dict, PDF_NAME(Descent));
+ fontdesc->cap_height = pdf_dict_get_real(ctx, dict, PDF_NAME(CapHeight));
+ fontdesc->x_height = pdf_dict_get_real(ctx, dict, PDF_NAME(XHeight));
+ fontdesc->missing_width = pdf_dict_get_real(ctx, dict, PDF_NAME(MissingWidth));
obj1 = pdf_dict_get(ctx, dict, PDF_NAME(FontFile));
obj2 = pdf_dict_get(ctx, dict, PDF_NAME(FontFile2));
diff --git a/source/pdf/pdf-form.c b/source/pdf/pdf-form.c
index 85c0cda7..a8dc4062 100644
--- a/source/pdf/pdf-form.c
+++ b/source/pdf/pdf-form.c
@@ -72,20 +72,14 @@ static void update_field_value(fz_context *ctx, pdf_document *doc, pdf_obj *obj,
static pdf_obj *find_field(fz_context *ctx, pdf_obj *dict, char *name, int len)
{
- pdf_obj *field;
-
int i, n = pdf_array_len(ctx, dict);
-
for (i = 0; i < n; i++)
{
- char *part;
-
- field = pdf_array_get(ctx, dict, i);
- part = pdf_to_str_buf(ctx, pdf_dict_get(ctx, field, PDF_NAME(T)));
+ pdf_obj *field = pdf_array_get(ctx, dict, i);
+ const char *part = pdf_dict_get_string(ctx, field, PDF_NAME(T), NULL);
if (strlen(part) == (size_t)len && !memcmp(part, name, len))
return field;
}
-
return NULL;
}
@@ -326,7 +320,7 @@ static void execute_action(fz_context *ctx, pdf_document *doc, pdf_obj *obj, pdf
}
else if (pdf_name_eq(ctx, type, PDF_NAME(ResetForm)))
{
- reset_form(ctx, doc, pdf_dict_get(ctx, a, PDF_NAME(Fields)), pdf_to_int(ctx, pdf_dict_get(ctx, a, PDF_NAME(Flags))) & 1);
+ reset_form(ctx, doc, pdf_dict_get(ctx, a, PDF_NAME(Fields)), pdf_dict_get_int(ctx, a, PDF_NAME(Flags)) & 1);
}
else if (pdf_name_eq(ctx, type, PDF_NAME(Named)))
{
@@ -553,7 +547,7 @@ int pdf_pass_event(fz_context *ctx, pdf_document *doc, pdf_page *page, pdf_ui_ev
/* Skip hidden annotations. */
if (annot)
{
- int f = pdf_to_int(ctx, pdf_dict_get(ctx, annot->obj, PDF_NAME(F)));
+ int f = pdf_dict_get_int(ctx, annot->obj, PDF_NAME(F));
if (f & (PDF_ANNOT_IS_HIDDEN|PDF_ANNOT_IS_NO_VIEW))
annot = NULL;
}
@@ -859,7 +853,7 @@ int pdf_field_display(fz_context *ctx, pdf_document *doc, pdf_obj *field)
while ((kids = pdf_dict_get(ctx, field, PDF_NAME(Kids))) != NULL)
field = pdf_array_get(ctx, kids, 0);
- f = pdf_to_int(ctx, pdf_dict_get(ctx, field, PDF_NAME(F)));
+ f = pdf_dict_get_int(ctx, field, PDF_NAME(F));
if (f & PDF_ANNOT_IS_HIDDEN)
{
@@ -889,7 +883,7 @@ static char *get_field_name(fz_context *ctx, pdf_document *doc, pdf_obj *field,
{
char *res = NULL;
pdf_obj *parent = pdf_dict_get(ctx, field, PDF_NAME(Parent));
- char *lname = pdf_to_str_buf(ctx, pdf_dict_get(ctx, field, PDF_NAME(T)));
+ const char *lname = pdf_dict_get_string(ctx, field, PDF_NAME(T), NULL);
int llen = (int)strlen(lname);
/*
@@ -932,7 +926,7 @@ void pdf_field_set_display(fz_context *ctx, pdf_document *doc, pdf_obj *field, i
if (!kids)
{
int mask = (PDF_ANNOT_IS_HIDDEN|PDF_ANNOT_IS_PRINT|PDF_ANNOT_IS_NO_VIEW);
- int f = pdf_to_int(ctx, pdf_dict_get(ctx, field, PDF_NAME(F))) & ~mask;
+ int f = pdf_dict_get_int(ctx, field, PDF_NAME(F)) & ~mask;
pdf_obj *fo;
switch (d)
@@ -994,7 +988,7 @@ void pdf_field_set_text_color(fz_context *ctx, pdf_document *doc, pdf_obj *field
ilen = fz_mini(di.col_size, (int)nelem(di.col));
for (i = 0; i < ilen; i++)
- di.col[i] = pdf_to_real(ctx, pdf_array_get(ctx, col, i));
+ di.col[i] = pdf_array_get_real(ctx, col, i);
fzbuf = fz_new_buffer(ctx, 0);
pdf_fzbuf_print_da(ctx, fzbuf, &di);
@@ -1259,8 +1253,8 @@ int pdf_signature_widget_byte_range(fz_context *ctx, pdf_document *doc, pdf_widg
{
for (i = 0; i < n; i++)
{
- byte_range[i].offset = pdf_to_int(ctx, pdf_array_get(ctx, br, 2*i));
- byte_range[i].len = pdf_to_int(ctx, pdf_array_get(ctx, br, 2*i+1));
+ byte_range[i].offset = pdf_array_get_int(ctx, br, 2*i);
+ byte_range[i].len = pdf_array_get_int(ctx, br, 2*i+1);
}
}
diff --git a/source/pdf/pdf-function.c b/source/pdf/pdf-function.c
index 76173196..84560596 100644
--- a/source/pdf/pdf-function.c
+++ b/source/pdf/pdf-function.c
@@ -956,7 +956,7 @@ load_sample_func(fz_context *ctx, pdf_function *func, pdf_obj *dict)
fz_warn(ctx, "too many sample function dimension sizes");
for (i = 0; i < func->m; i++)
{
- func->u.sa.size[i] = pdf_to_int(ctx, pdf_array_get(ctx, obj, i));
+ func->u.sa.size[i] = pdf_array_get_int(ctx, obj, i);
if (func->u.sa.size[i] <= 0)
{
fz_warn(ctx, "non-positive sample function dimension size");
@@ -981,8 +981,8 @@ load_sample_func(fz_context *ctx, pdf_function *func, pdf_obj *dict)
for (i = 0; i < ranges; i++)
{
- func->u.sa.encode[i][0] = pdf_to_real(ctx, pdf_array_get(ctx, obj, i * 2 + 0));
- func->u.sa.encode[i][1] = pdf_to_real(ctx, pdf_array_get(ctx, obj, i * 2 + 1));
+ func->u.sa.encode[i][0] = pdf_array_get_real(ctx, obj, i * 2 + 0);
+ func->u.sa.encode[i][1] = pdf_array_get_real(ctx, obj, i * 2 + 1);
}
}
@@ -1001,8 +1001,8 @@ load_sample_func(fz_context *ctx, pdf_function *func, pdf_obj *dict)
for (i = 0; i < ranges; i++)
{
- func->u.sa.decode[i][0] = pdf_to_real(ctx, pdf_array_get(ctx, obj, i * 2 + 0));
- func->u.sa.decode[i][1] = pdf_to_real(ctx, pdf_array_get(ctx, obj, i * 2 + 1));
+ func->u.sa.decode[i][0] = pdf_array_get_real(ctx, obj, i * 2 + 0);
+ func->u.sa.decode[i][1] = pdf_array_get_real(ctx, obj, i * 2 + 1);
}
}
@@ -1188,7 +1188,7 @@ load_exponential_func(fz_context *ctx, pdf_function *func, pdf_obj *dict)
fz_warn(ctx, "wrong number of C0 constants for exponential function");
for (i = 0; i < ranges; i++)
- func->u.e.c0[i] = pdf_to_real(ctx, pdf_array_get(ctx, obj, i));
+ func->u.e.c0[i] = pdf_array_get_real(ctx, obj, i);
}
obj = pdf_dict_get(ctx, dict, PDF_NAME(C1));
@@ -1199,7 +1199,7 @@ load_exponential_func(fz_context *ctx, pdf_function *func, pdf_obj *dict)
fz_warn(ctx, "wrong number of C1 constants for exponential function");
for (i = 0; i < ranges; i++)
- func->u.e.c1[i] = pdf_to_real(ctx, pdf_array_get(ctx, obj, i));
+ func->u.e.c1[i] = pdf_array_get_real(ctx, obj, i);
}
}
@@ -1320,8 +1320,8 @@ load_stitching_func(fz_context *ctx, pdf_function *func, pdf_obj *dict)
for (i = 0; i < ranges; i++)
{
- func->u.st.encode[i * 2 + 0] = pdf_to_real(ctx, pdf_array_get(ctx, obj, i * 2 + 0));
- func->u.st.encode[i * 2 + 1] = pdf_to_real(ctx, pdf_array_get(ctx, obj, i * 2 + 1));
+ func->u.st.encode[i * 2 + 0] = pdf_array_get_real(ctx, obj, i * 2 + 0);
+ func->u.st.encode[i * 2 + 1] = pdf_array_get_real(ctx, obj, i * 2 + 1);
}
}
}
@@ -1466,8 +1466,8 @@ pdf_load_function(fz_context *ctx, pdf_obj *dict, int in, int out)
func->m = fz_clampi(pdf_array_len(ctx, obj) / 2, 1, MAX_M);
for (i = 0; i < func->m; i++)
{
- func->domain[i][0] = pdf_to_real(ctx, pdf_array_get(ctx, obj, i * 2 + 0));
- func->domain[i][1] = pdf_to_real(ctx, pdf_array_get(ctx, obj, i * 2 + 1));
+ func->domain[i][0] = pdf_array_get_real(ctx, obj, i * 2 + 0);
+ func->domain[i][1] = pdf_array_get_real(ctx, obj, i * 2 + 1);
}
/* required for type0 and type4, optional otherwise */
@@ -1478,8 +1478,8 @@ pdf_load_function(fz_context *ctx, pdf_obj *dict, int in, int out)
func->n = fz_clampi(pdf_array_len(ctx, obj) / 2, 1, MAX_N);
for (i = 0; i < func->n; i++)
{
- func->range[i][0] = pdf_to_real(ctx, pdf_array_get(ctx, obj, i * 2 + 0));
- func->range[i][1] = pdf_to_real(ctx, pdf_array_get(ctx, obj, i * 2 + 1));
+ func->range[i][0] = pdf_array_get_real(ctx, obj, i * 2 + 0);
+ func->range[i][1] = pdf_array_get_real(ctx, obj, i * 2 + 1);
}
}
else
diff --git a/source/pdf/pdf-image.c b/source/pdf/pdf-image.c
index f1ef4f43..28e02db8 100644
--- a/source/pdf/pdf-image.c
+++ b/source/pdf/pdf-image.c
@@ -113,7 +113,7 @@ pdf_load_image_imp(fz_context *ctx, pdf_document *doc, pdf_obj *rdb, pdf_obj *di
if (obj)
{
for (i = 0; i < n * 2; i++)
- decode[i] = pdf_to_real(ctx, pdf_array_get(ctx, obj, i));
+ decode[i] = pdf_array_get_real(ctx, obj, i);
}
else if (fz_colorspace_is_lab(ctx, colorspace) || fz_colorspace_is_lab_icc(ctx, colorspace))
{
@@ -147,7 +147,7 @@ pdf_load_image_imp(fz_context *ctx, pdf_document *doc, pdf_obj *rdb, pdf_obj *di
{
use_colorkey = 1;
for (i = 0; i < n; i++)
- colorkey[i] = pdf_to_real(ctx, pdf_array_get(ctx, obj, i)) * 255;
+ colorkey[i] = pdf_array_get_real(ctx, obj, i) * 255;
}
}
}
@@ -161,7 +161,7 @@ pdf_load_image_imp(fz_context *ctx, pdf_document *doc, pdf_obj *rdb, pdf_obj *di
fz_warn(ctx, "invalid value in color key mask");
use_colorkey = 0;
}
- colorkey[i] = pdf_to_int(ctx, pdf_array_get(ctx, obj, i));
+ colorkey[i] = pdf_array_get_int(ctx, obj, i);
}
}
@@ -263,7 +263,7 @@ pdf_load_jpx(fz_context *ctx, pdf_document *doc, pdf_obj *dict, int forcemask)
int i;
for (i = 0; i < pix->n * 2; i++)
- decode[i] = pdf_to_real(ctx, pdf_array_get(ctx, obj, i));
+ decode[i] = pdf_array_get_real(ctx, obj, i);
fz_decode_tile(ctx, pix, decode);
}
diff --git a/source/pdf/pdf-interpret.c b/source/pdf/pdf-interpret.c
index 88b98bb5..fe874807 100644
--- a/source/pdf/pdf-interpret.c
+++ b/source/pdf/pdf-interpret.c
@@ -280,7 +280,7 @@ pdf_process_extgstate(fz_context *ctx, pdf_processor *proc, pdf_csi *csi, pdf_ob
if (pdf_is_array(ctx, bc))
{
for (k = 0; k < colorspace_n; k++)
- softmask_bc[k] = pdf_to_real(ctx, pdf_array_get(ctx, bc, k));
+ softmask_bc[k] = pdf_array_get_real(ctx, bc, k);
}
s = pdf_dict_get(ctx, obj, PDF_NAME(S));
@@ -1047,7 +1047,7 @@ pdf_process_contents(fz_context *ctx, pdf_processor *proc, pdf_document *doc, pd
void
pdf_process_annot(fz_context *ctx, pdf_processor *proc, pdf_document *doc, pdf_page *page, pdf_annot *annot, fz_cookie *cookie)
{
- int flags = pdf_to_int(ctx, pdf_dict_get(ctx, annot->obj, PDF_NAME(F)));
+ int flags = pdf_dict_get_int(ctx, annot->obj, PDF_NAME(F));
if (flags & (PDF_ANNOT_IS_INVISIBLE | PDF_ANNOT_IS_HIDDEN))
return;
diff --git a/source/pdf/pdf-layer.c b/source/pdf/pdf-layer.c
index 821e9c4c..189b823b 100644
--- a/source/pdf/pdf-layer.c
+++ b/source/pdf/pdf-layer.c
@@ -67,7 +67,7 @@ struct pdf_ocg_descriptor_s
pdf_ocg_entry *ocgs;
pdf_obj *intent;
- char *usage;
+ const char *usage;
int num_ui_entries;
pdf_ocg_ui *ui;
@@ -146,7 +146,7 @@ populate_ui(fz_context *ctx, pdf_ocg_descriptor *desc, pdf_ocg_ui *ui, pdf_obj *
if (j == desc->len)
continue; /* OCG not found in main list! Just ignore it */
ui->ocg = j;
- ui->name = pdf_to_str_buf(ctx, pdf_dict_get(ctx, o, PDF_NAME(Name)));
+ ui->name = pdf_dict_get_string(ctx, o, PDF_NAME(Name), NULL);
ui->button_flags = pdf_array_contains(ctx, o, rbgroups) ? PDF_LAYER_UI_RADIOBOX : PDF_LAYER_UI_CHECKBOX;
ui->locked = pdf_array_contains(ctx, o, locked);
ui++;
@@ -311,8 +311,8 @@ pdf_layer_config_info(fz_context *ctx, pdf_document *doc, int config_num, pdf_la
else
fz_throw(ctx, FZ_ERROR_GENERIC, "Invalid layer config number");
- info->creator = pdf_to_str_buf(ctx, pdf_dict_get(ctx, obj, PDF_NAME(Creator)));
- info->name = pdf_to_str_buf(ctx, pdf_dict_get(ctx, obj, PDF_NAME(Name)));
+ info->creator = pdf_dict_get_string(ctx, obj, PDF_NAME(Creator), NULL);
+ info->name = pdf_dict_get_string(ctx, obj, PDF_NAME(Name), NULL);
}
void
diff --git a/source/pdf/pdf-op-run.c b/source/pdf/pdf-op-run.c
index 9b52ce17..080452a8 100644
--- a/source/pdf/pdf-op-run.c
+++ b/source/pdf/pdf-op-run.c
@@ -1444,7 +1444,7 @@ static void pdf_run_d(fz_context *ctx, pdf_processor *proc, pdf_obj *array, floa
gstate->stroke_state = fz_unshare_stroke_state_with_dash_len(ctx, gstate->stroke_state, len);
gstate->stroke_state->dash_len = len;
for (i = 0; i < len; i++)
- gstate->stroke_state->dash_list[i] = pdf_to_real(ctx, pdf_array_get(ctx, array, i));
+ gstate->stroke_state->dash_list[i] = pdf_array_get_real(ctx, array, i);
gstate->stroke_state->dash_phase = phase;
}
@@ -2033,8 +2033,8 @@ static void pdf_run_BDC(fz_context *ctx, pdf_processor *proc, const char *tag, p
if (!tag || strcmp(tag, "OC"))
return;
- str = pdf_to_str_buf(ctx, pdf_dict_get(ctx, cooked, PDF_NAME(Name)));
- if (str == NULL)
+ str = pdf_dict_get_string(ctx, cooked, PDF_NAME(Name), NULL);
+ if (strlen(str) == 0)
str = "UnnamedLayer";
fz_begin_layer(ctx, pr->dev, str);
diff --git a/source/pdf/pdf-page.c b/source/pdf/pdf-page.c
index b1e286ee..8300fdb3 100644
--- a/source/pdf/pdf-page.c
+++ b/source/pdf/pdf-page.c
@@ -18,7 +18,7 @@ pdf_load_page_tree_imp(fz_context *ctx, pdf_document *doc, pdf_obj *node, int id
if (pdf_name_eq(ctx, type, PDF_NAME(Pages)))
{
pdf_obj *kids = pdf_dict_get(ctx, node, PDF_NAME(Kids));
- int count = pdf_to_int(ctx, pdf_dict_get(ctx, node, PDF_NAME(Count)));
+ int count = pdf_dict_get_int(ctx, node, PDF_NAME(Count));
int i, n = pdf_array_len(ctx, kids);
/* if Kids length is same as Count, all children must be page objects */
@@ -145,7 +145,7 @@ pdf_lookup_page_loc_imp(fz_context *ctx, pdf_document *doc, pdf_obj *node, int *
pdf_obj *type = pdf_dict_get(ctx, kid, PDF_NAME(Type));
if (type ? pdf_name_eq(ctx, type, PDF_NAME(Pages)) : pdf_dict_get(ctx, kid, PDF_NAME(Kids)) && !pdf_dict_get(ctx, kid, PDF_NAME(MediaBox)))
{
- int count = pdf_to_int(ctx, pdf_dict_get(ctx, kid, PDF_NAME(Count)));
+ int count = pdf_dict_get_int(ctx, kid, PDF_NAME(Count));
if (*skip < count)
{
node = kid;
@@ -576,7 +576,7 @@ pdf_page_presentation(fz_context *ctx, pdf_page *page, fz_transition *transition
{
pdf_obj *obj, *transdict;
- *duration = pdf_to_real(ctx, pdf_dict_get(ctx, page->obj, PDF_NAME(Dur)));
+ *duration = pdf_dict_get_real(ctx, page->obj, PDF_NAME(Dur));
transdict = pdf_dict_get(ctx, page->obj, PDF_NAME(Trans));
if (!transdict)
@@ -590,7 +590,7 @@ pdf_page_presentation(fz_context *ctx, pdf_page *page, fz_transition *transition
transition->outwards = !pdf_name_eq(ctx, pdf_dict_get(ctx, transdict, PDF_NAME(M)), PDF_NAME(I));
/* FIXME: If 'Di' is None, it should be handled differently, but
* this only affects Fly, and we don't implement that currently. */
- transition->direction = (pdf_to_int(ctx, pdf_dict_get(ctx, transdict, PDF_NAME(Di))));
+ transition->direction = (pdf_dict_get_int(ctx, transdict, PDF_NAME(Di)));
/* FIXME: Read SS for Fly when we implement it */
/* FIXME: Read B for Fly when we implement it */
@@ -1143,7 +1143,7 @@ pdf_delete_page(fz_context *ctx, pdf_document *doc, int at)
while (parent)
{
- int count = pdf_to_int(ctx, pdf_dict_get(ctx, parent, PDF_NAME(Count)));
+ int count = pdf_dict_get_int(ctx, parent, PDF_NAME(Count));
pdf_dict_put_int(ctx, parent, PDF_NAME(Count), count - 1);
parent = pdf_dict_get(ctx, parent, PDF_NAME(Parent));
}
@@ -1238,7 +1238,7 @@ pdf_insert_page(fz_context *ctx, pdf_document *doc, int at, pdf_obj *page_ref)
/* Adjust page counts */
while (parent)
{
- count = pdf_to_int(ctx, pdf_dict_get(ctx, parent, PDF_NAME(Count)));
+ count = pdf_dict_get_int(ctx, parent, PDF_NAME(Count));
pdf_dict_put_int(ctx, parent, PDF_NAME(Count), count + 1);
parent = pdf_dict_get(ctx, parent, PDF_NAME(Parent));
}
diff --git a/source/pdf/pdf-parse.c b/source/pdf/pdf-parse.c
index 87b326ae..104b117d 100644
--- a/source/pdf/pdf-parse.c
+++ b/source/pdf/pdf-parse.c
@@ -10,10 +10,10 @@ pdf_to_rect(fz_context *ctx, pdf_obj *array, fz_rect *r)
*r = fz_empty_rect;
else
{
- float a = pdf_to_real(ctx, pdf_array_get(ctx, array, 0));
- float b = pdf_to_real(ctx, pdf_array_get(ctx, array, 1));
- float c = pdf_to_real(ctx, pdf_array_get(ctx, array, 2));
- float d = pdf_to_real(ctx, pdf_array_get(ctx, array, 3));
+ float a = pdf_array_get_real(ctx, array, 0);
+ float b = pdf_array_get_real(ctx, array, 1);
+ float c = pdf_array_get_real(ctx, array, 2);
+ float d = pdf_array_get_real(ctx, array, 3);
r->x0 = fz_min(a, c);
r->y0 = fz_min(b, d);
r->x1 = fz_max(a, c);
@@ -29,12 +29,12 @@ pdf_to_matrix(fz_context *ctx, pdf_obj *array, fz_matrix *m)
*m = fz_identity;
else
{
- m->a = pdf_to_real(ctx, pdf_array_get(ctx, array, 0));
- m->b = pdf_to_real(ctx, pdf_array_get(ctx, array, 1));
- m->c = pdf_to_real(ctx, pdf_array_get(ctx, array, 2));
- m->d = pdf_to_real(ctx, pdf_array_get(ctx, array, 3));
- m->e = pdf_to_real(ctx, pdf_array_get(ctx, array, 4));
- m->f = pdf_to_real(ctx, pdf_array_get(ctx, array, 5));
+ m->a = pdf_array_get_real(ctx, array, 0);
+ m->b = pdf_array_get_real(ctx, array, 1);
+ m->c = pdf_array_get_real(ctx, array, 2);
+ m->d = pdf_array_get_real(ctx, array, 3);
+ m->e = pdf_array_get_real(ctx, array, 4);
+ m->f = pdf_array_get_real(ctx, array, 5);
}
return m;
}
diff --git a/source/pdf/pdf-pattern.c b/source/pdf/pdf-pattern.c
index e1e6f08f..f1f94352 100644
--- a/source/pdf/pdf-pattern.c
+++ b/source/pdf/pdf-pattern.c
@@ -53,9 +53,9 @@ pdf_load_pattern(fz_context *ctx, pdf_document *doc, pdf_obj *dict)
/* Store pattern now, to avoid possible recursion if objects refer back to this one */
pdf_store_item(ctx, dict, pat, pdf_pattern_size(pat));
- pat->ismask = pdf_to_int(ctx, pdf_dict_get(ctx, dict, PDF_NAME(PaintType))) == 2;
- pat->xstep = pdf_to_real(ctx, pdf_dict_get(ctx, dict, PDF_NAME(XStep)));
- pat->ystep = pdf_to_real(ctx, pdf_dict_get(ctx, dict, PDF_NAME(YStep)));
+ pat->ismask = pdf_dict_get_int(ctx, dict, PDF_NAME(PaintType)) == 2;
+ pat->xstep = pdf_dict_get_real(ctx, dict, PDF_NAME(XStep));
+ pat->ystep = pdf_dict_get_real(ctx, dict, PDF_NAME(YStep));
obj = pdf_dict_get(ctx, dict, PDF_NAME(BBox));
pdf_to_rect(ctx, obj, &pat->bbox);
diff --git a/source/pdf/pdf-portfolio.c b/source/pdf/pdf-portfolio.c
index 10dbc412..afc23c03 100644
--- a/source/pdf/pdf-portfolio.c
+++ b/source/pdf/pdf-portfolio.c
@@ -30,7 +30,7 @@ load_portfolio(fz_context *ctx, pdf_document *doc)
{
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)));
+ int sort = pdf_dict_get_int(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));
diff --git a/source/pdf/pdf-repair.c b/source/pdf/pdf-repair.c
index 3b4eceea..2aca42fd 100644
--- a/source/pdf/pdf-repair.c
+++ b/source/pdf/pdf-repair.c
@@ -210,7 +210,7 @@ pdf_repair_obj_stm(fz_context *ctx, pdf_document *doc, int stm_num)
{
obj = pdf_load_object(ctx, doc, stm_num);
- count = pdf_to_int(ctx, pdf_dict_get(ctx, obj, PDF_NAME(N)));
+ count = pdf_dict_get_int(ctx, obj, PDF_NAME(N));
pdf_drop_obj(ctx, obj);
diff --git a/source/pdf/pdf-shade.c b/source/pdf/pdf-shade.c
index f0124913..5476c8b8 100644
--- a/source/pdf/pdf-shade.c
+++ b/source/pdf/pdf-shade.c
@@ -64,10 +64,10 @@ pdf_load_function_based_shading(fz_context *ctx, pdf_document *doc, fz_shade *sh
obj = pdf_dict_get(ctx, dict, PDF_NAME(Domain));
if (obj)
{
- x0 = pdf_to_real(ctx, pdf_array_get(ctx, obj, 0));
- x1 = pdf_to_real(ctx, pdf_array_get(ctx, obj, 1));
- y0 = pdf_to_real(ctx, pdf_array_get(ctx, obj, 2));
- y1 = pdf_to_real(ctx, pdf_array_get(ctx, obj, 3));
+ 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));
@@ -107,26 +107,26 @@ pdf_load_linear_shading(fz_context *ctx, pdf_document *doc, fz_shade *shade, pdf
int e0, e1;
obj = pdf_dict_get(ctx, dict, PDF_NAME(Coords));
- shade->u.l_or_r.coords[0][0] = pdf_to_real(ctx, pdf_array_get(ctx, obj, 0));
- shade->u.l_or_r.coords[0][1] = pdf_to_real(ctx, pdf_array_get(ctx, obj, 1));
- shade->u.l_or_r.coords[1][0] = pdf_to_real(ctx, pdf_array_get(ctx, obj, 2));
- shade->u.l_or_r.coords[1][1] = pdf_to_real(ctx, pdf_array_get(ctx, obj, 3));
+ 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_to_real(ctx, pdf_array_get(ctx, obj, 0));
- d1 = pdf_to_real(ctx, pdf_array_get(ctx, obj, 1));
+ 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_to_bool(ctx, pdf_array_get(ctx, obj, 0));
- e1 = pdf_to_bool(ctx, pdf_array_get(ctx, obj, 1));
+ 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);
@@ -143,28 +143,28 @@ pdf_load_radial_shading(fz_context *ctx, pdf_document *doc, fz_shade *shade, pdf
int e0, e1;
obj = pdf_dict_get(ctx, dict, PDF_NAME(Coords));
- shade->u.l_or_r.coords[0][0] = pdf_to_real(ctx, pdf_array_get(ctx, obj, 0));
- shade->u.l_or_r.coords[0][1] = pdf_to_real(ctx, pdf_array_get(ctx, obj, 1));
- shade->u.l_or_r.coords[0][2] = pdf_to_real(ctx, pdf_array_get(ctx, obj, 2));
- shade->u.l_or_r.coords[1][0] = pdf_to_real(ctx, pdf_array_get(ctx, obj, 3));
- shade->u.l_or_r.coords[1][1] = pdf_to_real(ctx, pdf_array_get(ctx, obj, 4));
- shade->u.l_or_r.coords[1][2] = pdf_to_real(ctx, pdf_array_get(ctx, obj, 5));
+ 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[0][2] = pdf_array_get_real(ctx, obj, 2);
+ shade->u.l_or_r.coords[1][0] = pdf_array_get_real(ctx, obj, 3);
+ shade->u.l_or_r.coords[1][1] = pdf_array_get_real(ctx, obj, 4);
+ shade->u.l_or_r.coords[1][2] = pdf_array_get_real(ctx, obj, 5);
d0 = 0;
d1 = 1;
obj = pdf_dict_get(ctx, dict, PDF_NAME(Domain));
if (obj)
{
- d0 = pdf_to_real(ctx, pdf_array_get(ctx, obj, 0));
- d1 = pdf_to_real(ctx, pdf_array_get(ctx, obj, 1));
+ 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_to_bool(ctx, pdf_array_get(ctx, obj, 0));
- e1 = pdf_to_bool(ctx, pdf_array_get(ctx, obj, 1));
+ 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);
@@ -201,23 +201,23 @@ pdf_load_mesh_params(fz_context *ctx, pdf_document *doc, fz_shade *shade, pdf_ob
shade->u.m.c1[i] = 1;
}
- shade->u.m.vprow = pdf_to_int(ctx, pdf_dict_get(ctx, dict, PDF_NAME(VerticesPerRow)));
- shade->u.m.bpflag = pdf_to_int(ctx, pdf_dict_get(ctx, dict, PDF_NAME(BitsPerFlag)));
- shade->u.m.bpcoord = pdf_to_int(ctx, pdf_dict_get(ctx, dict, PDF_NAME(BitsPerCoordinate)));
- shade->u.m.bpcomp = pdf_to_int(ctx, pdf_dict_get(ctx, dict, PDF_NAME(BitsPerComponent)));
+ shade->u.m.vprow = pdf_dict_get_int(ctx, dict, PDF_NAME(VerticesPerRow));
+ shade->u.m.bpflag = pdf_dict_get_int(ctx, dict, PDF_NAME(BitsPerFlag));
+ shade->u.m.bpcoord = pdf_dict_get_int(ctx, dict, PDF_NAME(BitsPerCoordinate));
+ shade->u.m.bpcomp = pdf_dict_get_int(ctx, dict, PDF_NAME(BitsPerComponent));
obj = pdf_dict_get(ctx, dict, PDF_NAME(Decode));
if (pdf_array_len(ctx, obj) >= 6)
{
n = fz_mini(FZ_MAX_COLORS, (pdf_array_len(ctx, obj) - 4) / 2);
- shade->u.m.x0 = pdf_to_real(ctx, pdf_array_get(ctx, obj, 0));
- shade->u.m.x1 = pdf_to_real(ctx, pdf_array_get(ctx, obj, 1));
- shade->u.m.y0 = pdf_to_real(ctx, pdf_array_get(ctx, obj, 2));
- shade->u.m.y1 = pdf_to_real(ctx, pdf_array_get(ctx, obj, 3));
+ shade->u.m.x0 = pdf_array_get_real(ctx, obj, 0);
+ shade->u.m.x1 = pdf_array_get_real(ctx, obj, 1);
+ shade->u.m.y0 = pdf_array_get_real(ctx, obj, 2);
+ shade->u.m.y1 = pdf_array_get_real(ctx, obj, 3);
for (i = 0; i < n; i++)
{
- shade->u.m.c0[i] = pdf_to_real(ctx, pdf_array_get(ctx, obj, 4 + i * 2));
- shade->u.m.c1[i] = pdf_to_real(ctx, pdf_array_get(ctx, obj, 5 + i * 2));
+ shade->u.m.c0[i] = pdf_array_get_real(ctx, obj, 4 + i * 2);
+ shade->u.m.c1[i] = pdf_array_get_real(ctx, obj, 5 + i * 2);
}
}
@@ -341,7 +341,7 @@ pdf_load_shading_dict(fz_context *ctx, pdf_document *doc, pdf_obj *dict, const f
{
shade->use_background = 1;
for (i = 0; i < n; i++)
- shade->background[i] = pdf_to_real(ctx, pdf_array_get(ctx, obj, i));
+ shade->background[i] = pdf_array_get_real(ctx, obj, i);
}
obj = pdf_dict_get(ctx, dict, PDF_NAME(BBox));
diff --git a/source/pdf/pdf-signature.c b/source/pdf/pdf-signature.c
index ef39a50e..ca06fa56 100644
--- a/source/pdf/pdf-signature.c
+++ b/source/pdf/pdf-signature.c
@@ -26,8 +26,8 @@ void pdf_write_digest(fz_context *ctx, fz_output *out, pdf_obj *byte_range, int
brange = fz_calloc(ctx, brange_len, sizeof(*brange));
for (i = 0; i < brange_len; i++)
{
- brange[i].offset = pdf_to_int(ctx, pdf_array_get(ctx, byte_range, 2*i));
- brange[i].len = pdf_to_int(ctx, pdf_array_get(ctx, byte_range, 2*i+1));
+ brange[i].offset = pdf_array_get_int(ctx, byte_range, 2*i);
+ brange[i].len = pdf_array_get_int(ctx, byte_range, 2*i+1);
}
in = fz_open_null_n(ctx, fz_stream_from_output(ctx, out), brange, brange_len);
diff --git a/source/pdf/pdf-stream.c b/source/pdf/pdf-stream.c
index 2cb10d12..839f9b5e 100644
--- a/source/pdf/pdf-stream.c
+++ b/source/pdf/pdf-stream.c
@@ -93,11 +93,11 @@ pdf_load_jbig2_globals(fz_context *ctx, pdf_document *doc, pdf_obj *dict)
static void
build_compression_params(fz_context *ctx, pdf_obj *f, pdf_obj *p, fz_compression_params *params)
{
- int predictor = pdf_to_int(ctx, pdf_dict_get(ctx, p, PDF_NAME(Predictor)));
+ int predictor = pdf_dict_get_int(ctx, p, PDF_NAME(Predictor));
pdf_obj *columns_obj = pdf_dict_get(ctx, p, PDF_NAME(Columns));
int columns = pdf_to_int(ctx, columns_obj);
- int colors = pdf_to_int(ctx, pdf_dict_get(ctx, p, PDF_NAME(Colors)));
- int bpc = pdf_to_int(ctx, pdf_dict_get(ctx, p, PDF_NAME(BitsPerComponent)));
+ int colors = pdf_dict_get_int(ctx, p, PDF_NAME(Colors));
+ int bpc = pdf_dict_get_int(ctx, p, PDF_NAME(BitsPerComponent));
params->type = FZ_IMAGE_RAW;
@@ -294,7 +294,7 @@ pdf_open_raw_filter(fz_context *ctx, fz_stream *file_stm, pdf_document *doc, pdf
}
hascrypt = pdf_stream_has_crypt(ctx, stmobj);
- len = pdf_to_int(ctx, pdf_dict_get(ctx, stmobj, PDF_NAME(Length)));
+ len = pdf_dict_get_int(ctx, stmobj, PDF_NAME(Length));
null_stm = fz_open_null(ctx, file_stm, len, offset);
if (doc->crypt && !hascrypt)
{
@@ -471,7 +471,7 @@ pdf_load_raw_stream_number(fz_context *ctx, pdf_document *doc, int num)
dict = pdf_load_object(ctx, doc, num);
- len = pdf_to_int(ctx, pdf_dict_get(ctx, dict, PDF_NAME(Length)));
+ len = pdf_dict_get_int(ctx, dict, PDF_NAME(Length));
pdf_drop_obj(ctx, dict);
@@ -576,7 +576,7 @@ pdf_load_image_stream(fz_context *ctx, pdf_document *doc, int num, fz_compressio
dict = pdf_load_object(ctx, doc, num);
- len = pdf_to_int(ctx, pdf_dict_get(ctx, dict, PDF_NAME(Length)));
+ len = pdf_dict_get_int(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);
diff --git a/source/pdf/pdf-type3.c b/source/pdf/pdf-type3.c
index ad222fbe..cd7693cf 100644
--- a/source/pdf/pdf-type3.c
+++ b/source/pdf/pdf-type3.c
@@ -122,8 +122,8 @@ pdf_load_type3_font(fz_context *ctx, pdf_document *doc, pdf_obj *rdb, pdf_obj *d
pdf_set_default_hmtx(ctx, fontdesc, 0);
- first = pdf_to_int(ctx, pdf_dict_get(ctx, dict, PDF_NAME(FirstChar)));
- last = pdf_to_int(ctx, pdf_dict_get(ctx, dict, PDF_NAME(LastChar)));
+ first = pdf_dict_get_int(ctx, dict, PDF_NAME(FirstChar));
+ last = pdf_dict_get_int(ctx, dict, PDF_NAME(LastChar));
if (first < 0 || last > 255 || first > last)
first = last = 0;
@@ -136,7 +136,7 @@ pdf_load_type3_font(fz_context *ctx, pdf_document *doc, pdf_obj *rdb, pdf_obj *d
for (i = first; i <= last; i++)
{
- float w = pdf_to_real(ctx, pdf_array_get(ctx, widths, i - first));
+ float w = pdf_array_get_real(ctx, widths, i - first);
w = font->t3matrix.a * w * 1000;
font->t3widths[i] = w * 0.001f;
pdf_add_hmtx(ctx, fontdesc, i, i, w);
diff --git a/source/pdf/pdf-xobject.c b/source/pdf/pdf-xobject.c
index 87221737..9ee8f12c 100644
--- a/source/pdf/pdf-xobject.c
+++ b/source/pdf/pdf-xobject.c
@@ -23,7 +23,7 @@ int pdf_xobject_isolated(fz_context *ctx, pdf_obj *xobj)
{
pdf_obj *group = pdf_dict_get(ctx, xobj, PDF_NAME(Group));
if (group)
- return pdf_to_bool(ctx, pdf_dict_get(ctx, group, PDF_NAME(I)));
+ return pdf_dict_get_bool(ctx, group, PDF_NAME(I));
return 0;
}
@@ -31,7 +31,7 @@ int pdf_xobject_knockout(fz_context *ctx, pdf_obj *xobj)
{
pdf_obj *group = pdf_dict_get(ctx, xobj, PDF_NAME(Group));
if (group)
- return pdf_to_bool(ctx, pdf_dict_get(ctx, group, PDF_NAME(K)));
+ return pdf_dict_get_bool(ctx, group, PDF_NAME(K));
return 0;
}
diff --git a/source/pdf/pdf-xref.c b/source/pdf/pdf-xref.c
index 7aaec51e..0c72e0a7 100644
--- a/source/pdf/pdf-xref.c
+++ b/source/pdf/pdf-xref.c
@@ -749,7 +749,7 @@ pdf_xref_size_from_old_trailer(fz_context *ctx, pdf_document *doc, pdf_lexbuf *b
trailer = pdf_parse_dict(ctx, doc, doc->file, buf);
- size = pdf_to_int(ctx, pdf_dict_get(ctx, trailer, PDF_NAME(Size)));
+ size = pdf_dict_get_int(ctx, trailer, PDF_NAME(Size));
if (size < 0 || size > PDF_MAX_OBJECT_NUMBER + 1)
fz_throw(ctx, FZ_ERROR_GENERIC, "trailer Size entry out of range");
}
@@ -1016,9 +1016,9 @@ pdf_read_new_xref(fz_context *ctx, pdf_document *doc, pdf_lexbuf *buf)
obj = pdf_dict_get(ctx, trailer, PDF_NAME(W));
if (!obj)
fz_throw(ctx, FZ_ERROR_GENERIC, "xref stream missing W entry (%d R)", num);
- w0 = pdf_to_int(ctx, pdf_array_get(ctx, obj, 0));
- w1 = pdf_to_int(ctx, pdf_array_get(ctx, obj, 1));
- w2 = pdf_to_int(ctx, pdf_array_get(ctx, obj, 2));
+ w0 = pdf_array_get_int(ctx, obj, 0);
+ w1 = pdf_array_get_int(ctx, obj, 1);
+ w2 = pdf_array_get_int(ctx, obj, 2);
if (w0 < 0)
fz_warn(ctx, "xref stream objects have corrupt type");
@@ -1044,8 +1044,8 @@ pdf_read_new_xref(fz_context *ctx, pdf_document *doc, pdf_lexbuf *buf)
int n = pdf_array_len(ctx, index);
for (t = 0; t < n; t += 2)
{
- int i0 = pdf_to_int(ctx, pdf_array_get(ctx, index, t + 0));
- int i1 = pdf_to_int(ctx, pdf_array_get(ctx, index, t + 1));
+ int i0 = pdf_array_get_int(ctx, index, t + 0);
+ int i1 = pdf_array_get_int(ctx, index, t + 1);
pdf_read_new_xref_section(ctx, doc, stm, i0, i1, w0, w1, w2);
}
}
@@ -1298,23 +1298,23 @@ pdf_load_linear(fz_context *ctx, pdf_document *doc)
lin = pdf_to_int(ctx, o);
if (lin != 1)
fz_throw(ctx, FZ_ERROR_GENERIC, "Unexpected version of Linearized tag (%d)", lin);
- len = pdf_to_int(ctx, pdf_dict_get(ctx, dict, PDF_NAME(L)));
+ len = pdf_dict_get_int(ctx, dict, PDF_NAME(L));
if (len != doc->file_length)
fz_throw(ctx, FZ_ERROR_GENERIC, "File has been updated since linearization");
pdf_read_xref_sections(ctx, doc, fz_tell(ctx, doc->file), &doc->lexbuf.base, 0);
- doc->linear_page_count = pdf_to_int(ctx, pdf_dict_get(ctx, dict, PDF_NAME(N)));
+ doc->linear_page_count = pdf_dict_get_int(ctx, dict, PDF_NAME(N));
doc->linear_page_refs = fz_resize_array(ctx, doc->linear_page_refs, doc->linear_page_count, sizeof(pdf_obj *));
memset(doc->linear_page_refs, 0, doc->linear_page_count * sizeof(pdf_obj*));
doc->linear_obj = dict;
doc->linear_pos = fz_tell(ctx, doc->file);
- doc->linear_page1_obj_num = pdf_to_int(ctx, pdf_dict_get(ctx, dict, PDF_NAME(O)));
+ doc->linear_page1_obj_num = pdf_dict_get_int(ctx, dict, PDF_NAME(O));
doc->linear_page_refs[0] = pdf_new_indirect(ctx, doc, doc->linear_page1_obj_num, 0);
doc->linear_page_num = 0;
hint = pdf_dict_get(ctx, dict, PDF_NAME(H));
- doc->hint_object_offset = pdf_to_int(ctx, pdf_array_get(ctx, hint, 0));
- doc->hint_object_length = pdf_to_int(ctx, pdf_array_get(ctx, hint, 1));
+ doc->hint_object_offset = pdf_array_get_int(ctx, hint, 0);
+ doc->hint_object_length = pdf_array_get_int(ctx, hint, 1);
entry = pdf_get_populating_xref_entry(ctx, doc, 0);
entry->type = 'f';
@@ -1609,8 +1609,8 @@ pdf_load_obj_stm(fz_context *ctx, pdf_document *doc, int num, pdf_lexbuf *buf, i
{
pdf_mark_obj(ctx, objstm);
- count = pdf_to_int(ctx, pdf_dict_get(ctx, objstm, PDF_NAME(N)));
- first = pdf_to_int(ctx, pdf_dict_get(ctx, objstm, PDF_NAME(First)));
+ count = pdf_dict_get_int(ctx, objstm, PDF_NAME(N));
+ first = pdf_dict_get_int(ctx, objstm, PDF_NAME(First));
if (count < 0 || count > PDF_MAX_OBJECT_NUMBER)
fz_throw(ctx, FZ_ERROR_GENERIC, "number of objects in object stream out of range");
@@ -2344,7 +2344,7 @@ pdf_load_hints(fz_context *ctx, pdf_document *doc, int objnum)
if (dict == NULL || !pdf_is_dict(ctx, dict))
fz_throw(ctx, FZ_ERROR_GENERIC, "malformed hint object");
- shared_hint_offset = pdf_to_int(ctx, pdf_dict_get(ctx, dict, PDF_NAME(S)));
+ shared_hint_offset = pdf_dict_get_int(ctx, dict, PDF_NAME(S));
/* Malloc the structures (use realloc to cope with the fact we
* may try this several times before enough data is loaded) */
diff --git a/source/tools/pdfposter.c b/source/tools/pdfposter.c
index dc51d113..387d8cae 100644
--- a/source/tools/pdfposter.c
+++ b/source/tools/pdfposter.c
@@ -32,10 +32,10 @@ intersect_box(fz_context *ctx, pdf_document *doc, pdf_obj *page, pdf_obj *box_na
if (box == NULL)
return;
- old_rect.x0 = pdf_to_real(ctx, pdf_array_get(ctx, box, 0));
- old_rect.y0 = pdf_to_real(ctx, pdf_array_get(ctx, box, 1));
- old_rect.x1 = pdf_to_real(ctx, pdf_array_get(ctx, box, 2));
- old_rect.y1 = pdf_to_real(ctx, pdf_array_get(ctx, box, 3));
+ old_rect.x0 = pdf_array_get_real(ctx, box, 0);
+ old_rect.y0 = pdf_array_get_real(ctx, box, 1);
+ old_rect.x1 = pdf_array_get_real(ctx, box, 2);
+ old_rect.y1 = pdf_array_get_real(ctx, box, 3);
if (old_rect.x0 < mb->x0)
old_rect.x0 = mb->x0;