diff options
author | Jonathan Kew <jfkthame@googlemail.com> | 2008-06-18 14:25:06 +0000 |
---|---|---|
committer | Jonathan Kew <jfkthame@googlemail.com> | 2008-06-18 14:25:06 +0000 |
commit | f7f8cd161b59236731e0d93c3accd3d57f9f879d (patch) | |
tree | 2ed0a8ae87ffe52db7bfe296f1e78309a718e166 /Build/source/texk/xdvipdfmx/src | |
parent | 2b12869a6eda47de8d80246a0cfe2a45ef04fdeb (diff) |
merged recent DVIPDFMx patches into xdvipdfmx
git-svn-id: svn://tug.org/texlive/trunk@8831 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/xdvipdfmx/src')
-rw-r--r-- | Build/source/texk/xdvipdfmx/src/dvi.c | 2 | ||||
-rw-r--r-- | Build/source/texk/xdvipdfmx/src/mpost.c | 6 | ||||
-rw-r--r-- | Build/source/texk/xdvipdfmx/src/pdfdev.c | 60 | ||||
-rw-r--r-- | Build/source/texk/xdvipdfmx/src/pdfdev.h | 7 | ||||
-rw-r--r-- | Build/source/texk/xdvipdfmx/src/pdfdoc.c | 18 | ||||
-rw-r--r-- | Build/source/texk/xdvipdfmx/src/pdfdoc.h | 10 | ||||
-rw-r--r-- | Build/source/texk/xdvipdfmx/src/pdfnames.c | 7 | ||||
-rw-r--r-- | Build/source/texk/xdvipdfmx/src/pdfobj.c | 8 | ||||
-rw-r--r-- | Build/source/texk/xdvipdfmx/src/pdfobj.h | 3 | ||||
-rw-r--r-- | Build/source/texk/xdvipdfmx/src/pdfparse.c | 4 | ||||
-rw-r--r-- | Build/source/texk/xdvipdfmx/src/pdfximage.c | 78 | ||||
-rw-r--r-- | Build/source/texk/xdvipdfmx/src/pdfximage.h | 9 | ||||
-rw-r--r-- | Build/source/texk/xdvipdfmx/src/spc_dvips.c | 8 | ||||
-rw-r--r-- | Build/source/texk/xdvipdfmx/src/spc_html.c | 4 | ||||
-rw-r--r-- | Build/source/texk/xdvipdfmx/src/spc_misc.c | 4 | ||||
-rw-r--r-- | Build/source/texk/xdvipdfmx/src/spc_pdfm.c | 202 | ||||
-rw-r--r-- | Build/source/texk/xdvipdfmx/src/spc_util.c | 21 |
17 files changed, 272 insertions, 179 deletions
diff --git a/Build/source/texk/xdvipdfmx/src/dvi.c b/Build/source/texk/xdvipdfmx/src/dvi.c index d56bbf8bbfc..217e74f404c 100644 --- a/Build/source/texk/xdvipdfmx/src/dvi.c +++ b/Build/source/texk/xdvipdfmx/src/dvi.c @@ -2048,7 +2048,7 @@ do_pic_file() transform is a 3x2 affine transform matrix expressed in fixed-point values */ - xobj_id = pdf_ximage_findresource(path, page_no/*, pdf_box*/); + xobj_id = pdf_ximage_findresource(path, page_no, NULL); if (xobj_id >= 0) { /* FIXME: this seems to work for 72dpi JPEGs, but isn't right for others; need to take the actual image resolution into account in pdf_dev_put_image, diff --git a/Build/source/texk/xdvipdfmx/src/mpost.c b/Build/source/texk/xdvipdfmx/src/mpost.c index 841a357e699..a123c5a049e 100644 --- a/Build/source/texk/xdvipdfmx/src/mpost.c +++ b/Build/source/texk/xdvipdfmx/src/mpost.c @@ -1,4 +1,4 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/mpost.c,v 1.40 2008/05/17 01:17:27 chofchof Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/mpost.c,v 1.41 2008/06/05 06:27:42 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. @@ -883,7 +883,7 @@ do_texfig_operator (int opcode, double x_user, double y_user) if (!in_tfig) ERROR("endTexFig without valid startTexFig!."); - pdf_doc_end_grabbing(); + pdf_doc_end_grabbing(NULL); pdf_dev_put_image(xobj_id, &fig_p, x_user, y_user); in_tfig = 0; break; @@ -1578,7 +1578,7 @@ mps_include_page (const char *ident, FILE *fp) mps_stack_clear_to (st_depth); pdf_dev_grestore_to(gs_depth); - pdf_doc_end_grabbing(); + pdf_doc_end_grabbing(NULL); //pdf_color_pop(); pdf_dev_set_param(PDF_DEV_PARAM_AUTOROTATE, autorotate); diff --git a/Build/source/texk/xdvipdfmx/src/pdfdev.c b/Build/source/texk/xdvipdfmx/src/pdfdev.c index 7c4fdf4b8c9..9f4fae1ea5c 100644 --- a/Build/source/texk/xdvipdfmx/src/pdfdev.c +++ b/Build/source/texk/xdvipdfmx/src/pdfdev.c @@ -1,4 +1,4 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/pdfdev.c,v 1.65 2008/05/18 08:09:09 chofchof Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/pdfdev.c,v 1.66 2008/06/05 06:27:42 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. @@ -976,6 +976,37 @@ handle_multibyte_string (struct dev_font *font, return 0; } + +static pdf_coord *dev_coords = NULL; +static int num_dev_coords = 0; +static int max_dev_coords = 0; + +void pdf_dev_get_coord(double *xpos, double *ypos) +{ + if (num_dev_coords > 0) { + *xpos = dev_coords[num_dev_coords-1].x; + *ypos = dev_coords[num_dev_coords-1].y; + } else { + *xpos = *ypos = 0.0; + } +} + +void pdf_dev_push_coord(double xpos, double ypos) +{ + if (num_dev_coords >= max_dev_coords) { + max_dev_coords += 4; + dev_coords = RENEW(dev_coords, max_dev_coords, pdf_coord); + } + dev_coords[num_dev_coords].x = xpos; + dev_coords[num_dev_coords].y = ypos; + num_dev_coords++; +} + +void pdf_dev_pop_coord(void) +{ + if (num_dev_coords > 0) num_dev_coords--; +} + /* * ctype: #ifdef XETEX @@ -1045,6 +1076,11 @@ pdf_dev_set_string (spt_t xpos, spt_t ypos, } } + if (num_dev_coords > 0) { + xpos -= bpt2spt(dev_coords[num_dev_coords-1].x); + ypos -= bpt2spt(dev_coords[num_dev_coords-1].y); + } + /* * Kern is in units of character units, i.e., 1000 = 1 em. * @@ -1161,9 +1197,10 @@ pdf_init_device (double dvi2pts, int precision, int black_and_white) pdf_color_clear_stack(); pdf_dev_init_gstates(); - num_dev_fonts = 0; - max_dev_fonts = 0; - dev_fonts = NULL; + num_dev_fonts = max_dev_fonts = 0; + dev_fonts = NULL; + num_dev_coords = max_dev_coords = 0; + dev_coords = NULL; } void @@ -1182,10 +1219,7 @@ pdf_close_device (void) } RELEASE(dev_fonts); } - dev_fonts = NULL; - num_dev_fonts = 0; - max_dev_fonts = 0; - + if (dev_coords) RELEASE(dev_coords); pdf_dev_clear_gstates(); } @@ -1607,6 +1641,11 @@ pdf_dev_set_rule (spt_t xpos, spt_t ypos, spt_t width, spt_t height) int len = 0; double width_in_bp; + if (num_dev_coords > 0) { + xpos -= bpt2spt(dev_coords[num_dev_coords-1].x); + ypos -= bpt2spt(dev_coords[num_dev_coords-1].y); + } + graphics_mode(); format_buffer[len++] = ' '; @@ -1827,6 +1866,11 @@ pdf_dev_put_image (int id, pdf_rect r; int len = 0; + if (num_dev_coords > 0) { + ref_x -= dev_coords[num_dev_coords-1].x; + ref_y -= dev_coords[num_dev_coords-1].y; + } + pdf_copymatrix(&M, &(p->matrix)); M.e += ref_x; M.f += ref_y; /* Just rotate by -90, but not tested yet. Any problem if M has scaling? */ diff --git a/Build/source/texk/xdvipdfmx/src/pdfdev.h b/Build/source/texk/xdvipdfmx/src/pdfdev.h index 5e5b7a9adfe..4934f053e5e 100644 --- a/Build/source/texk/xdvipdfmx/src/pdfdev.h +++ b/Build/source/texk/xdvipdfmx/src/pdfdev.h @@ -1,4 +1,4 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/pdfdev.h,v 1.20 2007/11/22 11:45:39 chofchof Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/pdfdev.h,v 1.23 2008/06/05 06:27:42 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. @@ -70,6 +70,7 @@ typedef struct #define INFO_HAS_WIDTH (1 << 1) #define INFO_HAS_HEIGHT (1 << 2) #define INFO_DO_CLIP (1 << 3) +#define INFO_DO_HIDE (1 << 4) extern void transform_info_clear (transform_info *info); @@ -221,4 +222,8 @@ extern void pdf_dev_eop (void); */ extern void graphics_mode (void); +extern void pdf_dev_get_coord(double *xpos, double *ypos); +extern void pdf_dev_push_coord(double xpos, double ypos); +extern void pdf_dev_pop_coord(void); + #endif /* _PDFDEV_H_ */ diff --git a/Build/source/texk/xdvipdfmx/src/pdfdoc.c b/Build/source/texk/xdvipdfmx/src/pdfdoc.c index 663d9ef3941..797f2dd820b 100644 --- a/Build/source/texk/xdvipdfmx/src/pdfdoc.c +++ b/Build/source/texk/xdvipdfmx/src/pdfdoc.c @@ -1,4 +1,4 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/pdfdoc.c,v 1.55 2008/05/22 10:08:02 matthias Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/pdfdoc.c,v 1.57 2008/06/05 06:27:42 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. @@ -100,7 +100,7 @@ read_thumbnail (const char *thumb_filename) } MFCLOSE(fp); - xobj_id = pdf_ximage_findresource(thumb_filename, 0); + xobj_id = pdf_ximage_findresource(thumb_filename, 0, NULL); if (xobj_id < 0) { WARN("Could not read thumbnail file \"%s\".", thumb_filename); image_ref = NULL; @@ -2072,11 +2072,12 @@ pdf_close_document (void) * All this routine does is give the form a name and add a unity scaling matrix. * It fills in required fields. The caller must initialize the stream. */ -void +static void pdf_doc_make_xform (pdf_obj *xform, pdf_rect *bbox, pdf_tmatrix *matrix, - pdf_obj *resources) + pdf_obj *resources, + pdf_obj *attrib) { pdf_obj *xform_dict; pdf_obj *tmp; @@ -2110,6 +2111,10 @@ pdf_doc_make_xform (pdf_obj *xform, pdf_add_dict(xform_dict, pdf_new_name("Matrix"), tmp); } + if (attrib) { + pdf_merge_dict(xform_dict, attrib); + } + pdf_add_dict(xform_dict, pdf_new_name("Resources"), resources); return; @@ -2186,7 +2191,7 @@ pdf_doc_begin_grabbing (const char *ident, } void -pdf_doc_end_grabbing (void) +pdf_doc_end_grabbing (pdf_obj *attrib) { pdf_form *form; pdf_obj *procset; @@ -2216,9 +2221,10 @@ pdf_doc_end_grabbing (void) pdf_doc_make_xform(form->contents, &form->cropbox, &form->matrix, - pdf_ref_obj(form->resources)); + pdf_ref_obj(form->resources), attrib); pdf_release_obj(form->resources); pdf_release_obj(form->contents); + if (attrib) pdf_release_obj(attrib); p->pending_forms = fnode->prev; diff --git a/Build/source/texk/xdvipdfmx/src/pdfdoc.h b/Build/source/texk/xdvipdfmx/src/pdfdoc.h index 587067a528b..2ce1054b376 100644 --- a/Build/source/texk/xdvipdfmx/src/pdfdoc.h +++ b/Build/source/texk/xdvipdfmx/src/pdfdoc.h @@ -1,4 +1,4 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/pdfdoc.h,v 1.23 2008/05/20 13:05:14 matthias Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/pdfdoc.h,v 1.24 2008/06/05 06:27:42 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. @@ -99,17 +99,11 @@ extern void pdf_doc_bookmarks_add (pdf_obj *dict, int is_open); extern int pdf_doc_bookmarks_depth (void); -/* Form XObject */ -extern void pdf_doc_make_xform (pdf_obj *xform, - pdf_rect *bbox, /* const */ - pdf_tmatrix *matrix, /* const */ - pdf_obj *resources_ref); - /* Returns xobj_id of started xform. */ extern int pdf_doc_begin_grabbing (const char *ident, double ref_x, double ref_y, const pdf_rect *cropbox); -extern void pdf_doc_end_grabbing (void); +extern void pdf_doc_end_grabbing (pdf_obj *attrib); /* Annotation */ diff --git a/Build/source/texk/xdvipdfmx/src/pdfnames.c b/Build/source/texk/xdvipdfmx/src/pdfnames.c index 5a3a0e47839..a935593af53 100644 --- a/Build/source/texk/xdvipdfmx/src/pdfnames.c +++ b/Build/source/texk/xdvipdfmx/src/pdfnames.c @@ -1,4 +1,4 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/pdfnames.c,v 1.1 2004/09/02 12:23:07 hirata Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/pdfnames.c,v 1.2 2008/06/07 09:54:38 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. @@ -174,8 +174,9 @@ pdf_names_add_object (struct ht_table *names, pdf_release_obj(object); /* PLEASE FIX THIS!!! */ } else { if (value->object || value->object_ref) { - WARN("Object reference with key \"%s\" is in use.", - printable_key(key, keylen)); + if (pdf_obj_get_verbose()) { + WARN("Object reference with key \"%s\" is in use.", printable_key(key, keylen)); + } return -1; } else { value->object = object; diff --git a/Build/source/texk/xdvipdfmx/src/pdfobj.c b/Build/source/texk/xdvipdfmx/src/pdfobj.c index c61cede1c2f..196da1d0500 100644 --- a/Build/source/texk/xdvipdfmx/src/pdfobj.c +++ b/Build/source/texk/xdvipdfmx/src/pdfobj.c @@ -1,4 +1,4 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/pdfobj.c,v 1.58 2008/05/22 10:08:02 matthias Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/pdfobj.c,v 1.59 2008/06/07 09:54:38 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. @@ -257,6 +257,12 @@ pdf_get_version (void) return pdf_version; } +int +pdf_obj_get_verbose(void) +{ + return verbose; +} + void pdf_obj_set_verbose(void) { diff --git a/Build/source/texk/xdvipdfmx/src/pdfobj.h b/Build/source/texk/xdvipdfmx/src/pdfobj.h index d68f4108015..fb0f58d5e74 100644 --- a/Build/source/texk/xdvipdfmx/src/pdfobj.h +++ b/Build/source/texk/xdvipdfmx/src/pdfobj.h @@ -1,4 +1,4 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/pdfobj.h,v 1.27 2008/05/20 13:05:14 matthias Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/pdfobj.h,v 1.28 2008/06/07 09:54:38 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. @@ -49,6 +49,7 @@ typedef struct pdf_file pdf_file; /* External interface to pdf routines */ +extern int pdf_obj_get_verbose (void); extern void pdf_obj_set_verbose (void); extern void pdf_error_cleanup (void); diff --git a/Build/source/texk/xdvipdfmx/src/pdfparse.c b/Build/source/texk/xdvipdfmx/src/pdfparse.c index b1ed56352f0..578d2b271b8 100644 --- a/Build/source/texk/xdvipdfmx/src/pdfparse.c +++ b/Build/source/texk/xdvipdfmx/src/pdfparse.c @@ -1,4 +1,4 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/pdfparse.c,v 1.42 2008/05/16 10:51:25 matthias Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/pdfparse.c,v 1.43 2008/06/07 09:54:38 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. @@ -283,7 +283,7 @@ parse_pdf_number (char **pp, char *endptr) } } else if (isdigit(p[0])) { if (has_dot) { - if (nddigits == DDIGITS_MAX) { + if (nddigits == DDIGITS_MAX && pdf_obj_get_verbose() > 1) { WARN("Number with more than %d fractional digits.", DDIGITS_MAX); } else if (nddigits < DDIGITS_MAX) { dpart = dpart * 10 + p[0] - '0'; diff --git a/Build/source/texk/xdvipdfmx/src/pdfximage.c b/Build/source/texk/xdvipdfmx/src/pdfximage.c index 75fa8863073..36a8abde918 100644 --- a/Build/source/texk/xdvipdfmx/src/pdfximage.c +++ b/Build/source/texk/xdvipdfmx/src/pdfximage.c @@ -1,4 +1,4 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/pdfximage.c,v 1.20 2008/05/17 01:16:53 chofchof Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/pdfximage.c,v 1.21 2008/05/29 13:43:51 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. @@ -80,7 +80,7 @@ struct pdf_ximage_ char *filename; pdf_obj *reference; pdf_obj *resource; - int pdf_box; + pdf_obj *attr_dict; }; @@ -109,7 +109,7 @@ static struct ic_ _ic = { }; static void -pdf_init_ximage_struct (pdf_ximage *I, const char *ident, const char *filename) +pdf_init_ximage_struct (pdf_ximage *I, const char *ident, const char *filename, pdf_obj *dict) { if (ident) { I->ident = NEW(strlen(ident)+1, char); @@ -126,7 +126,7 @@ pdf_init_ximage_struct (pdf_ximage *I, const char *ident, const char *filename) memset(I->res_name, 0, 16); I->reference = NULL; I->resource = NULL; - I->pdf_box = 0; + I->attr_dict = dict; I->attr.width = I->attr.height = 0; I->attr.xdensity = I->attr.ydensity = 1.0; @@ -145,7 +145,9 @@ pdf_clean_ximage_struct (pdf_ximage *I) pdf_release_obj(I->reference); if (I->resource) pdf_release_obj(I->resource); - pdf_init_ximage_struct(I, NULL, NULL); + if (I->attr_dict) + pdf_release_obj(I->attr_dict); + pdf_init_ximage_struct(I, NULL, NULL, NULL); } @@ -214,58 +216,9 @@ source_image_type (FILE *fp) return format; } -#if 0 -#define KEYCMP(k,s) (strcmp(pdf_name_value((k)),(s))) static int -filter_put_image_attr (pdf_obj *kp, pdf_obj *vp, void *dp) -{ - struct attr_ *attr = dp; - - if (KEYCMP(kp, "Width")) { - if (pdf_obj_typeof(vp) != PDF_NUMBER) - return -1; - attr->width = (long) pdf_number_value(vp); - } else if (KEYCMP(kp, "Height")) { - if (pdf_obj_typeof(vp) != PDF_NUMBER) - return -1; - attr->height = (long) pdf_number_value(vp); - } - - return 0; -} - -static int -filter_put_form_attr (pdf_obj *kp, pdf_obj *vp, void *dp) -{ - struct attr_ *attr = dp; - - if (KEYCMP(kp, "BBox")) { - if (pdf_array_length(vp) != 4) - return -1; - else { - int i; - double v[4]; - for (i = 0; i < 4; i++) { - pdf_obj *obj = pdf_get_array(vp, i); - if (pdf_obj_typeof(vp) != PDF_NUMBER) - return -1; - else { - v = pdf_number_value(obj); - } - } - attr->bbox.llx = v[0]; attr->bbox.lly = v[1]; - attr->bbox.urx = v[2]; attr->bbox.ury = v[3]; - } - } - - return 0; -} -#endif - - -static int -load_image (const char *ident, - const char *fullname, int format, FILE *fp, long page_no) +load_image (const char *ident, const char *fullname, int format, FILE *fp, + long page_no, pdf_obj *dict) { struct ic_ *ic = &_ic; int id = -1; /* ret */ @@ -278,7 +231,7 @@ load_image (const char *ident, } I = &ic->ximages[id]; - pdf_init_ximage_struct(I, ident, ident); + pdf_init_ximage_struct(I, ident, ident, dict); pdf_ximage_set_page(I, page_no, 0); switch (format) { @@ -352,7 +305,7 @@ load_image (const char *ident, #define dpx_fclose(f) (MFCLOSE((f))) int -pdf_ximage_findresource (const char *ident, long page_no) +pdf_ximage_findresource (const char *ident, long page_no, pdf_obj *dict) { struct ic_ *ic = &_ic; int id = -1; @@ -364,7 +317,8 @@ pdf_ximage_findresource (const char *ident, long page_no) for (id = 0; id < ic->count; id++) { I = &ic->ximages[id]; if (I->ident && !strcmp(ident, I->ident) && - I->page_no == page_no + (page_no < 0 ? I->page_count+1 : 0)) { + I->page_no == page_no + (page_no < 0 ? I->page_count+1 : 0) && + I->attr_dict == dict) { return id; } } @@ -401,7 +355,7 @@ pdf_ximage_findresource (const char *ident, long page_no) } else break; default: - id = load_image(ident, fullname, format, fp, page_no); + id = load_image(ident, fullname, format, fp, page_no, dict); break; } dpx_fclose(fp); @@ -520,6 +474,8 @@ pdf_ximage_set_image (pdf_ximage *I, void *image_info, pdf_obj *resource) pdf_add_dict(dict, pdf_new_name("Height"), pdf_new_number(info->height)); pdf_add_dict(dict, pdf_new_name("BitsPerComponent"), pdf_new_number(info->bits_per_component)); + if (I->attr_dict) + pdf_merge_dict(dict, I->attr_dict); pdf_release_obj(resource); /* Caller don't know we are using reference. */ I->resource = NULL; @@ -596,7 +552,7 @@ pdf_ximage_defineresource (const char *ident, I = &ic->ximages[id]; - pdf_init_ximage_struct(I, ident, NULL); + pdf_init_ximage_struct(I, ident, NULL, NULL); switch (subtype) { case PDF_XOBJECT_TYPE_IMAGE: diff --git a/Build/source/texk/xdvipdfmx/src/pdfximage.h b/Build/source/texk/xdvipdfmx/src/pdfximage.h index 2b16994b4de..433bd75c0e5 100644 --- a/Build/source/texk/xdvipdfmx/src/pdfximage.h +++ b/Build/source/texk/xdvipdfmx/src/pdfximage.h @@ -1,4 +1,4 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/pdfximage.h,v 1.12 2008/05/13 12:23:45 matthias Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/pdfximage.h,v 1.13 2008/05/29 13:43:51 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. @@ -62,9 +62,10 @@ extern char *pdf_ximage_get_resname (int xobj_id); extern pdf_obj *pdf_ximage_get_reference (int xobj_id); -extern int pdf_ximage_findresource (const char *ident, long page_no/*, int pdf_box*/); -extern int pdf_ximage_defineresource (const char *ident, - int subtype, void *cdata, pdf_obj *resource); +extern int pdf_ximage_findresource (const char *ident, long page_no, + pdf_obj *dict); +extern int pdf_ximage_defineresource (const char *ident, int subtype, + void *cdata, pdf_obj *resource); /* Called by pngimage, jpegimage, epdf, mpost, etc. */ extern void pdf_ximage_init_image_info (ximage_info *info); diff --git a/Build/source/texk/xdvipdfmx/src/spc_dvips.c b/Build/source/texk/xdvipdfmx/src/spc_dvips.c index 04cc3c1b2e3..435551079b3 100644 --- a/Build/source/texk/xdvipdfmx/src/spc_dvips.c +++ b/Build/source/texk/xdvipdfmx/src/spc_dvips.c @@ -1,4 +1,4 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/spc_dvips.c,v 1.10 2008/02/13 20:22:21 matthias Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/spc_dvips.c,v 1.11 2008/05/29 13:43:51 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. @@ -162,7 +162,7 @@ spc_handler_ps_file (struct spc_env *spe, struct spc_arg *args) return -1; } - form_id = pdf_ximage_findresource(filename, 1); + form_id = pdf_ximage_findresource(filename, 1, NULL); if (form_id < 0) { spc_warn(spe, "Failed to read image file: %s", filename); RELEASE(filename); @@ -195,7 +195,7 @@ spc_handler_ps_plotfile (struct spc_env *spe, struct spc_arg *args) return -1; } - form_id = pdf_ximage_findresource(filename, 1); + form_id = pdf_ximage_findresource(filename, 1, NULL); if (form_id < 0) { spc_warn(spe, "Could not open PS file: %s", filename); error = -1; @@ -643,7 +643,7 @@ spc_handler_ps_tricks_render (struct spc_env *spe, struct spc_arg *args) return error; } - form_id = pdf_ximage_findresource(gs_out, 1/*, 0*/); + form_id = pdf_ximage_findresource(gs_out, 1, NULL); if (form_id < 0) { spc_warn(spe, "Failed to read converted PSTricks image file."); RELEASE(gs_in); diff --git a/Build/source/texk/xdvipdfmx/src/spc_html.c b/Build/source/texk/xdvipdfmx/src/spc_html.c index 322c53475ce..d81f51a7e05 100644 --- a/Build/source/texk/xdvipdfmx/src/spc_html.c +++ b/Build/source/texk/xdvipdfmx/src/spc_html.c @@ -1,4 +1,4 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/spc_html.c,v 1.6 2007/01/19 11:00:48 chofchof Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/spc_html.c,v 1.8 2008/05/29 13:43:51 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. @@ -635,7 +635,7 @@ spc_html__img_empty (struct spc_env *spe, pdf_obj *attr, struct spc_html_ *sd) return error; } - id = pdf_ximage_findresource(pdf_string_value(src), 0/*, 0*/); + id = pdf_ximage_findresource(pdf_string_value(src), 0, NULL); if (id < 0) { spc_warn(spe, "Could not find/load image: %s", pdf_string_value(src)); error = -1; diff --git a/Build/source/texk/xdvipdfmx/src/spc_misc.c b/Build/source/texk/xdvipdfmx/src/spc_misc.c index 51e0ceee7d2..9d7d55257c0 100644 --- a/Build/source/texk/xdvipdfmx/src/spc_misc.c +++ b/Build/source/texk/xdvipdfmx/src/spc_misc.c @@ -1,4 +1,4 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/spc_misc.c,v 1.6 2005/08/08 18:00:11 chofchof Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/spc_misc.c,v 1.8 2008/05/29 13:43:51 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. @@ -134,7 +134,7 @@ spc_handler_postscriptbox (struct spc_env *spe, struct spc_arg *ap) } MFCLOSE(fp); - form_id = pdf_ximage_findresource(filename, 0/*, 0*/); + form_id = pdf_ximage_findresource(filename, 0, NULL); if (form_id < 0) { spc_warn(spe, "Failed to load image file: %s", filename); return -1; diff --git a/Build/source/texk/xdvipdfmx/src/spc_pdfm.c b/Build/source/texk/xdvipdfmx/src/spc_pdfm.c index 077c359f3dc..7044090b4ba 100644 --- a/Build/source/texk/xdvipdfmx/src/spc_pdfm.c +++ b/Build/source/texk/xdvipdfmx/src/spc_pdfm.c @@ -1,4 +1,4 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/spc_pdfm.c,v 1.35 2008/05/22 10:08:02 matthias Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/spc_pdfm.c,v 1.41 2008/06/16 01:47:13 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. @@ -280,21 +280,12 @@ safeputresdict (pdf_obj *kp, pdf_obj *vp, void *dp) dict = pdf_lookup_dict(dp, key); if (pdf_obj_isaref(vp)) { - if (dict) { -#if 0 - return E_INVALID_ACCESS; -#endif - WARN("Replacing whole page/form resource dict entry \"%s\"...", key); - WARN("You might be creating a broken PDF document."); - } - pdf_add_dict(dp, - pdf_new_name(key), pdf_link_obj(vp)); + pdf_add_dict(dp, pdf_new_name(key), pdf_link_obj(vp)); } else if (pdf_obj_typeof(vp) == PDF_DICT) { if (dict) pdf_foreach_dict(vp, safeputresdent, dict); else { - pdf_add_dict(dp, - pdf_new_name(key), pdf_link_obj(vp)); + pdf_add_dict(dp, pdf_new_name(key), pdf_link_obj(vp)); } } else { WARN("Invalid type (not DICT) for page/form resource dict entry: key=\"%s\"", key); @@ -683,8 +674,8 @@ spc_handler_pdfm_annot (struct spc_env *spe, struct spc_arg *args) } else { rect.llx = cp.x; rect.lly = cp.y - spe->mag * ti.depth; - rect.urx = rect.llx + spe->mag * ti.width; - rect.ury = rect.lly + spe->mag * ti.height; + rect.urx = cp.x + spe->mag * ti.width; + rect.ury = cp.y + spe->mag * ti.height; } /* Order is important... */ @@ -1064,7 +1055,7 @@ spc_handler_pdfm_image (struct spc_env *spe, struct spc_arg *args) struct spc_pdf_ *sd = &_pdf_stat; int xobj_id; char *ident = NULL; - pdf_obj *fspec; + pdf_obj *fspec, *attr = NULL; transform_info ti; long page_no; @@ -1102,7 +1093,16 @@ spc_handler_pdfm_image (struct spc_env *spe, struct spc_arg *args) return -1; } - xobj_id = pdf_ximage_findresource(pdf_string_value(fspec), page_no); + skip_white(&args->curptr, args->endptr); + if (args->curptr < args->endptr) { + attr = parse_pdf_object(&args->curptr, args->endptr, NULL); + if (!attr || !PDF_OBJ_DICTTYPE(attr)) { + spc_warn(spe, "Ignore invalid attribute dictionary."); + if (attr) pdf_release_obj(attr); + } + } + + xobj_id = pdf_ximage_findresource(pdf_string_value(fspec), page_no, attr); if (xobj_id < 0) { spc_warn(spe, "Could not find image resource..."); pdf_release_obj(fspec); @@ -1111,7 +1111,8 @@ spc_handler_pdfm_image (struct spc_env *spe, struct spc_arg *args) return -1; } - pdf_dev_put_image(xobj_id, &ti, spe->x_user, spe->y_user); + if (!(ti.flags & INFO_DO_HIDE)) + pdf_dev_put_image(xobj_id, &ti, spe->x_user, spe->y_user); if (ident) { addresource(sd, ident, xobj_id); @@ -1137,7 +1138,7 @@ spc_handler_pdfm_dest (struct spc_env *spe, struct spc_arg *args) spc_warn(spe, "PDF string expected for destination name but not found."); return -1; } else if (!PDF_OBJ_STRINGTYPE(name)) { - spc_warn(spe, "PDF string expected for destination name but not found."); + spc_warn(spe, "PDF string expected for destination name but invalid type."); pdf_release_obj(name); return -1; } @@ -1147,7 +1148,7 @@ spc_handler_pdfm_dest (struct spc_env *spe, struct spc_arg *args) spc_warn(spe, "No destination not specified for pdf:dest."); pdf_release_obj(name); return -1; - } else if (!PDF_OBJ_ARRAYTYPE(array)) { + } else if (!PDF_OBJ_ARRAYTYPE(array)) { spc_warn(spe, "Destination not specified as an array object!"); pdf_release_obj(name); pdf_release_obj(array); @@ -1158,11 +1159,9 @@ spc_handler_pdfm_dest (struct spc_env *spe, struct spc_arg *args) pdf_string_value (name), pdf_string_length(name), array); + if (error) pdf_release_obj(array); pdf_release_obj(name); - if (error) - spc_warn(spe, "Could not add Dests name tree entry..."); - return 0; } @@ -1398,8 +1397,8 @@ spc_handler_pdfm_literal (struct spc_env *spe, struct spc_arg *args) if (args->curptr < args->endptr) { pdf_tmatrix M; - M.a = M.d = 1.0; M.b = M.c = 0.0; if (!direct) { + M.a = M.d = 1.0; M.b = M.c = 0.0; M.e = spe->x_user; M.f = spe->y_user; pdf_dev_concat(&M); } @@ -1416,17 +1415,51 @@ spc_handler_pdfm_literal (struct spc_env *spe, struct spc_arg *args) return 0; } -/* - * FSTREAM: Create a PDF stream object from an existing file. - * - * pdf: fstream @objname (filename) [PDF_DICT] - */ static int -spc_handler_pdfm_fstream (struct spc_env *spe, struct spc_arg *args) +spc_handler_pdfm_bcontent (struct spc_env *spe, struct spc_arg *args) +{ + pdf_tmatrix M; + double xpos, ypos; + + pdf_dev_gsave(); + pdf_dev_get_coord(&xpos, &ypos); + pdf_setmatrix(&M, 1.0, 0.0, 0.0, 1.0, spe->x_user - xpos, spe->y_user - ypos); + pdf_dev_concat(&M); + pdf_dev_push_coord(spe->x_user, spe->y_user); + return 0; +} + +static int +spc_handler_pdfm_econtent (struct spc_env *spe, struct spc_arg *args) +{ + pdf_dev_pop_coord(); + pdf_dev_grestore(); + return 0; +} + +static int +spc_handler_pdfm_code (struct spc_env *spe, struct spc_arg *args) +{ + skip_white(&args->curptr, args->endptr); + + if (args->curptr < args->endptr) { + pdf_doc_add_page_content(" ", 1); + pdf_doc_add_page_content(args->curptr, (long) (args->endptr - args->curptr)); + args->curptr = args->endptr; + } + + return 0; +} + +#define STRING_STREAM 0 +#define FILE_STREAM 1 + +static int +spc_handler_pdfm_stream_with_type (struct spc_env *spe, struct spc_arg *args, int type) { pdf_obj *fstream; - long stream_len, nb_read; - char *ident, *filename; + long nb_read; + char *ident, *instring; pdf_obj *tmp; FILE *fp; @@ -1434,7 +1467,7 @@ spc_handler_pdfm_fstream (struct spc_env *spe, struct spc_arg *args) ident = parse_opt_ident(&args->curptr, args->endptr); if (!ident) { - spc_warn(spe, "Missing objname string for pdf:fstream."); + spc_warn(spe, "Missing objname for pdf:(f)stream."); return -1; } @@ -1442,45 +1475,51 @@ spc_handler_pdfm_fstream (struct spc_env *spe, struct spc_arg *args) tmp = parse_pdf_object(&args->curptr, args->endptr, NULL); if (!tmp) { - spc_warn(spe, "Missing filename string for pdf:fstream."); + spc_warn(spe, "Missing input string for pdf:(f)stream."); RELEASE(ident); return -1; } else if (!PDF_OBJ_STRINGTYPE(tmp)) { - spc_warn(spe, "Missing filename string for pdf:fstream."); + spc_warn(spe, "Invalid type of input string for pdf:(f)stream."); pdf_release_obj(tmp); RELEASE(ident); return -1; } - filename = pdf_string_value(tmp); - if (!filename) { - spc_warn(spe, "Missing filename string for pdf:fstream."); - pdf_release_obj(tmp); - RELEASE(ident); - return -1; - } + instring = pdf_string_value(tmp); - fstream = pdf_new_stream(STREAM_COMPRESS); - - fp = DPXFOPEN(filename, DPX_RES_TYPE_BINARY); - if (!fp) { - spc_warn(spe, "Could not open file: %s", filename); - pdf_release_obj(fstream); + switch (type) { + case FILE_STREAM: + if (!instring) { + spc_warn(spe, "Missing filename for pdf:fstream."); + pdf_release_obj(tmp); + RELEASE(ident); + return -1; + } + fp = DPXFOPEN(instring, DPX_RES_TYPE_BINARY); + if (!fp) { + spc_warn(spe, "Could not open file: %s", instring); + pdf_release_obj(tmp); + RELEASE(ident); + return -1; + } + fstream = pdf_new_stream(STREAM_COMPRESS); + while ((nb_read = + fread(work_buffer, sizeof(char), WORK_BUFFER_SIZE, fp)) > 0) + pdf_add_stream(fstream, work_buffer, nb_read); + MFCLOSE(fp); + break; + case STRING_STREAM: + fstream = pdf_new_stream(STREAM_COMPRESS); + if (instring) + pdf_add_stream(fstream, instring, strlen(instring)); + break; + default: pdf_release_obj(tmp); RELEASE(ident); return -1; } pdf_release_obj(tmp); - stream_len = 0; - while ((nb_read = - fread(work_buffer, sizeof(char), WORK_BUFFER_SIZE, fp)) > 0) { - pdf_add_stream(fstream, work_buffer, nb_read); - stream_len += nb_read; - } - - MFCLOSE(fp); - /* * Optional dict. * @@ -1516,6 +1555,28 @@ spc_handler_pdfm_fstream (struct spc_env *spe, struct spc_arg *args) return 0; } +/* + * STREAM: Create a PDF stream object from an input string. + * + * pdf: stream @objname (input_string) [PDF_DICT] + */ +static int +spc_handler_pdfm_stream (struct spc_env *spe, struct spc_arg *args) +{ + return spc_handler_pdfm_stream_with_type (spe, args, STRING_STREAM); +} + +/* + * FSTREAM: Create a PDF stream object from an existing file. + * + * pdf: fstream @objname (filename) [PDF_DICT] + */ +static int +spc_handler_pdfm_fstream (struct spc_env *spe, struct spc_arg *args) +{ + return spc_handler_pdfm_stream_with_type (spe, args, FILE_STREAM); +} + /* Grab page content as follows: * * Reference point = (x_user, y_user) @@ -1597,27 +1658,25 @@ spc_handler_pdfm_bform (struct spc_env *spe, struct spc_arg *args) return 0; } +/* An extra dictionary after exobj must be merged to the form dictionary, + * not resource dictionary. + * Please use pdf:put @resources (before pdf:exobj) instead. + */ static int spc_handler_pdfm_eform (struct spc_env *spe, struct spc_arg *args) { - pdf_obj *garbage; - pdf_obj *resource; + pdf_obj *attrib = NULL; skip_white(&args->curptr, args->endptr); if (args->curptr < args->endptr) { - /* An extra dictionary after exobj must be merged to /Resources. - * Please use pdf:put @resources (before pdf:exobj) instead. - */ - garbage = parse_pdf_dict(&args->curptr, args->endptr, NULL); - if (garbage) { - resource = pdf_doc_current_page_resources(); - pdf_merge_dict(resource, garbage); - spc_warn(spe, "Garbage after special pdf:exobj."); - pdf_release_obj(garbage); + attrib = parse_pdf_dict(&args->curptr, args->endptr, NULL); + if (attrib && !PDF_OBJ_DICTTYPE(attrib)) { + pdf_release_obj(attrib); + attrib = NULL; } } - pdf_doc_end_grabbing(); + pdf_doc_end_grabbing(attrib); return 0; } @@ -1674,7 +1733,7 @@ spc_handler_pdfm_uxobj (struct spc_env *spe, struct spc_arg *args) */ xobj_id = findresource(sd, ident); if (xobj_id < 0) { - xobj_id = pdf_ximage_findresource(ident, 0); + xobj_id = pdf_ximage_findresource(ident, 0, NULL); if (xobj_id < 0) { spc_warn(spe, "Specified (image) object doesn't exist: %s", ident); RELEASE(ident); @@ -1978,10 +2037,15 @@ static struct spc_handler pdfm_handlers[] = { {"tounicode", spc_handler_pdfm_tounicode}, #endif /* ENABLE_TOUNICODE */ {"literal", spc_handler_pdfm_literal}, + {"stream", spc_handler_pdfm_stream}, {"fstream", spc_handler_pdfm_fstream}, {"names", spc_handler_pdfm_names}, {"mapline", spc_handler_pdfm_mapline}, {"mapfile", spc_handler_pdfm_mapfile}, + + {"bcontent", spc_handler_pdfm_bcontent}, + {"econtent", spc_handler_pdfm_econtent}, + {"code", spc_handler_pdfm_code}, }; int diff --git a/Build/source/texk/xdvipdfmx/src/spc_util.c b/Build/source/texk/xdvipdfmx/src/spc_util.c index b6c34e2c144..e21338dfd86 100644 --- a/Build/source/texk/xdvipdfmx/src/spc_util.c +++ b/Build/source/texk/xdvipdfmx/src/spc_util.c @@ -1,4 +1,4 @@ -/* $Header: /home/cvsroot/dvipdfmx/src/spc_util.c,v 1.11 2008/03/01 09:00:31 matthias Exp $ +/* $Header: /home/cvsroot/dvipdfmx/src/spc_util.c,v 1.14 2008/06/01 01:38:32 chofchof Exp $ This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. @@ -181,6 +181,7 @@ spc_read_color_pdf (struct spc_env *spe, pdf_color *colorspec, struct spc_arg *a double cv[4]; /* at most four */ int nc, isarry = 0; int error = 0; + char *q; skip_blank(&ap->curptr, ap->endptr); @@ -201,8 +202,16 @@ spc_read_color_pdf (struct spc_env *spe, pdf_color *colorspec, struct spc_arg *a pdf_color_cmykcolor(colorspec, cv[0], cv[1], cv[2], cv[3]); break; default: - spc_warn(spe, "Expecting either gray level or RGB/CMYK color array: %d", nc); - error = -1; + /* Try to read the color names defined in dvipsname.def */ + q = parse_c_ident(&ap->curptr, ap->endptr); + if (!q) { + spc_warn(spe, "No valid color specified?"); + return -1; + } + error = pdf_color_namedcolor(colorspec, q); + if (error) + spc_warn(spe, "Unrecognized color name: %s", q); + RELEASE(q); break; } @@ -497,6 +506,8 @@ spc_read_dimtrns_pdfm (struct spc_env *spe, transform_info *p, struct spc_arg *a "clip", #define K__PAGE 10 "page", +#define K__HIDE 11 + "hide", NULL }; double xscale, yscale, rotate; @@ -505,6 +516,7 @@ spc_read_dimtrns_pdfm (struct spc_env *spe, transform_info *p, struct spc_arg *a has_xscale = has_yscale = has_scale = has_rotate = has_matrix = 0; xscale = yscale = 1.0; rotate = 0.0; p->flags |= INFO_DO_CLIP; /* default: do clipping */ + p->flags &= ~INFO_DO_HIDE; /* default: do clipping */ skip_blank(&ap->curptr, ap->endptr); @@ -617,6 +629,9 @@ spc_read_dimtrns_pdfm (struct spc_env *spe, transform_info *p, struct spc_arg *a error = -1; } break; + case K__HIDE: + p->flags |= INFO_DO_HIDE; + break; default: error = -1; break; |