summaryrefslogtreecommitdiff
path: root/Build
diff options
context:
space:
mode:
authorAkira Kakuto <kakuto@fuk.kindai.ac.jp>2015-12-30 05:25:52 +0000
committerAkira Kakuto <kakuto@fuk.kindai.ac.jp>2015-12-30 05:25:52 +0000
commit632abcdde570001e5f8e7509d630749e73cf2732 (patch)
tree4aea8023ed33dcfa7fe49a4b1705a2b5fb009bba /Build
parent4b54d57009fe18e922c56ba0e404a23d443f6ddc (diff)
texk/dvipdfm-x: patches by S. Hirata
git-svn-id: svn://tug.org/texlive/trunk@39238 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build')
-rw-r--r--Build/source/texk/dvipdfm-x/ChangeLog6
-rw-r--r--Build/source/texk/dvipdfm-x/epdf.c184
-rw-r--r--Build/source/texk/dvipdfm-x/epdf.h7
-rw-r--r--Build/source/texk/dvipdfm-x/pdfdoc.c60
-rw-r--r--Build/source/texk/dvipdfm-x/pdfdoc.h3
-rw-r--r--Build/source/texk/dvipdfm-x/pdfximage.c113
-rw-r--r--Build/source/texk/dvipdfm-x/pdfximage.h24
-rw-r--r--Build/source/texk/dvipdfm-x/spc_dvips.c13
-rw-r--r--Build/source/texk/dvipdfm-x/spc_html.c4
-rw-r--r--Build/source/texk/dvipdfm-x/spc_misc.c3
-rw-r--r--Build/source/texk/dvipdfm-x/spc_pdfm.c40
-rw-r--r--Build/source/texk/dvipdfm-x/spc_util.c238
-rw-r--r--Build/source/texk/dvipdfm-x/spc_util.h25
-rw-r--r--Build/source/texk/dvipdfm-x/xbb.c4
14 files changed, 433 insertions, 291 deletions
diff --git a/Build/source/texk/dvipdfm-x/ChangeLog b/Build/source/texk/dvipdfm-x/ChangeLog
index 78ceb3384b8..4c901a06862 100644
--- a/Build/source/texk/dvipdfm-x/ChangeLog
+++ b/Build/source/texk/dvipdfm-x/ChangeLog
@@ -1,3 +1,9 @@
+2015-12-30 Shunsaku Hirata <shunsaku.hirata74@gmail.com>
+
+ * epdf.[ch], pdfdoc.[ch], pdfximage.[ch],
+ spc_{dvips,html,misc,pdfm,util}.c, spc_util.h: Don't use global variables
+ for selecting boundary box. Cleanups.
+
2015-12-29 Shunsaku Hirata <shunsaku.hirata74@gmail.com>
* dvipdfmx.c, dvi.c: Allow empty password in pdf:encrypt special.
diff --git a/Build/source/texk/dvipdfm-x/epdf.c b/Build/source/texk/dvipdfm-x/epdf.c
index 2f2eb972a78..411534ca5f7 100644
--- a/Build/source/texk/dvipdfm-x/epdf.c
+++ b/Build/source/texk/dvipdfm-x/epdf.c
@@ -164,7 +164,7 @@ pdf_get_page_obj (pdf_file *pf, int page_no,
if (markinfo) {
tmp = pdf_lookup_dict(markinfo, "Marked");
if (PDF_OBJ_BOOLEANTYPE(tmp) && pdf_boolean_value(tmp))
- WARN("File contains tagged PDF. Ignoring tags.");
+ WARN("PDF file is tagged... Ignoring tags.");
pdf_release_obj(markinfo);
}
@@ -215,25 +215,28 @@ pdf_get_page_obj (pdf_file *pf, int page_no,
if (bbox)
pdf_release_obj(bbox);
bbox = tmp;
- } else
+ } else {
pdf_release_obj(tmp);
}
+ }
if ((tmp = pdf_deref_obj(pdf_lookup_dict(page_tree, "TrimBox")))) {
if (!rect_equal(tmp, bbox)) {
if (bbox)
pdf_release_obj(bbox);
bbox = tmp;
- } else
+ } else {
pdf_release_obj(tmp);
}
+ }
if ((tmp = pdf_deref_obj(pdf_lookup_dict(page_tree, "ArtBox")))) {
if (!rect_equal(tmp, bbox)) {
if (bbox)
pdf_release_obj(bbox);
bbox = tmp;
- } else
+ } else {
pdf_release_obj(tmp);
}
+ }
if ((tmp = pdf_deref_obj(pdf_lookup_dict(page_tree, "CropBox")))) {
if (crop_box)
pdf_release_obj(crop_box);
@@ -270,10 +273,10 @@ pdf_get_page_obj (pdf_file *pf, int page_no,
/* Pages object */
count = pdf_number_value(tmp);
pdf_release_obj(tmp);
- } else
+ } else {
/* Page object */
count = 1;
-
+ }
if (page_idx < count)
break;
@@ -312,7 +315,8 @@ pdf_get_page_obj (pdf_file *pf, int page_no,
if (rotate) {
if (pdf_number_value(rotate) != 0.0)
- WARN("<< /Rotate %d >> found. (Not supported yet)", (int)pdf_number_value(rotate));
+ WARN("<< /Rotate %d >> found. (Not supported yet)",
+ (int)pdf_number_value(rotate));
pdf_release_obj(rotate);
rotate = NULL;
}
@@ -391,41 +395,32 @@ pdf_get_page_content (pdf_obj* page)
return contents;
}
+/* ximage here is the result. DONT USE IT FOR PASSING OPTIONS! */
int
-pdf_include_page (pdf_ximage *ximage, FILE *image_file, const char *filename)
+pdf_include_page (pdf_ximage *ximage,
+ FILE *image_file,
+ const char *ident,
+ load_options options)
{
pdf_file *pf;
xform_info info;
pdf_obj *contents = NULL, *catalog;
pdf_obj *page = NULL, *resources = NULL, *markinfo = NULL;
- int page_no;
- pf = pdf_open(filename, image_file);
+ pf = pdf_open(ident, image_file);
if (!pf)
return -1;
- /*
- * Try to embed the PDF, even if the PDF version is newer than the setting.
- */
-#if 0
- if (pdf_file_get_version(pf) > pdf_get_version())
- goto too_recent;
-#endif
+ if (pdf_file_get_version(pf) > pdf_get_version()) {
+ WARN("Trying to include PDF file which has newer version number " \
+ "than output PDF: %d.", pdf_get_version());
+ }
pdf_ximage_init_form_info(&info);
- /*
- * Get Page.
- */
- page_no = pdf_ximage_get_page(ximage);
- if (page_no == 0)
- page_no = 1;
-
- page = pdf_doc_get_page(pf, page_no, NULL, &info.bbox, &resources);
-/*
- Recover the default value of PageBox
-*/
- PageBox = 0;
+ page = pdf_doc_get_page(pf,
+ options.page_no, options.bbox_type,
+ &info.bbox, &resources);
if(!page)
goto error_silent;
@@ -439,8 +434,9 @@ pdf_include_page (pdf_ximage *ximage, FILE *image_file, const char *filename)
if (tmp)
pdf_release_obj(tmp);
goto error;
- } else if (pdf_boolean_value(tmp))
- WARN("File contains tagged PDF. Ignoring tags.");
+ } else if (pdf_boolean_value(tmp)) {
+ WARN("PDF file is tagged... Ignoring tags.");
+ }
pdf_release_obj(tmp);
}
@@ -482,8 +478,9 @@ pdf_include_page (pdf_ximage *ximage, FILE *image_file, const char *filename)
}
pdf_release_obj(content_seg);
}
- } else
+ } else {
goto error;
+ }
if (contents)
pdf_release_obj(contents);
@@ -498,14 +495,11 @@ pdf_include_page (pdf_ximage *ximage, FILE *image_file, const char *filename)
contents_dict = pdf_stream_dict(contents);
pdf_add_dict(contents_dict,
- pdf_new_name("Type"),
- pdf_new_name("XObject"));
+ pdf_new_name("Type"), pdf_new_name("XObject"));
pdf_add_dict(contents_dict,
- pdf_new_name("Subtype"),
- pdf_new_name("Form"));
+ pdf_new_name("Subtype"), pdf_new_name("Form"));
pdf_add_dict(contents_dict,
- pdf_new_name("FormType"),
- pdf_new_number(1.0));
+ pdf_new_name("FormType"), pdf_new_number(1.0));
bbox = pdf_new_array();
pdf_add_array(bbox, pdf_new_number(info.bbox.llx));
@@ -551,19 +545,6 @@ pdf_include_page (pdf_ximage *ximage, FILE *image_file, const char *filename)
pdf_close(pf);
return -1;
-
-#if 0
- too_recent:
- pdf_close(pf);
- WARN("PDF version of input file more recent than in output file.");
- if (compat_mode) {
- WARN("Converting. Use \"-V\" switch to change output PDF version.");
- return 1;
- } else {
- WARN("Use \"-V\" switch to change output PDF version.");
- return -1;
- }
-#endif
}
typedef enum {
@@ -877,104 +858,3 @@ pdf_copy_clip (FILE *image_file, int pageNo, double x_user, double y_user)
return 0;
}
-
-#if 0
-#define WBUF_SIZE 4096
-#if HAVE_ZLIB
-static int
-add_stream_flate (pdf_obj *dst, const void *data, int len)
-{
- z_stream z;
- Bytef wbuf[WBUF_SIZE];
-
- z.zalloc = Z_NULL; z.zfree = Z_NULL; z.opaque = Z_NULL;
-
- z.next_in = (z_const Bytef *) data; z.avail_in = len;
- z.next_out = (Bytef *) wbuf; z.avail_out = WBUF_SIZE;
-
- if (inflateInit(&z) != Z_OK) {
- WARN("inflateInit() failed.");
- return -1;
- }
-
- for (;;) {
- int status;
- status = inflate(&z, Z_NO_FLUSH);
- if (status == Z_STREAM_END)
- break;
- else if (status != Z_OK) {
- WARN("inflate() failed. Broken PDF file?");
- inflateEnd(&z);
- return -1;
- }
-
- if (z.avail_out == 0) {
- pdf_add_stream(dst, wbuf, WBUF_SIZE);
- z.next_out = wbuf;
- z.avail_out = WBUF_SIZE;
- }
- }
-
- if (WBUF_SIZE - z.avail_out > 0)
- pdf_add_stream(dst, wbuf, WBUF_SIZE - z.avail_out);
-
- return (inflateEnd(&z) == Z_OK ? 0 : -1);
-}
-#endif
-
-static int
-concat_stream (pdf_obj *dst, pdf_obj *src)
-{
- const char *stream_data;
- int stream_length;
- pdf_obj *stream_dict;
- pdf_obj *filter;
-
- if (!PDF_OBJ_STREAMTYPE(dst) || !PDF_OBJ_STREAMTYPE(src))
- ERROR("Invalid type.");
-
- stream_data = pdf_stream_dataptr(src);
- stream_length = pdf_stream_length (src);
- stream_dict = pdf_stream_dict (src);
-
- if (pdf_lookup_dict(stream_dict, "DecodeParms")) {
- WARN("DecodeParams not supported.");
- return -1;
- }
-
- filter = pdf_lookup_dict(stream_dict, "Filter");
- if (!filter) {
- pdf_add_stream(dst, stream_data, stream_length);
- return 0;
-#if HAVE_ZLIB
- } else {
- char *filter_name;
- if (PDF_OBJ_NAMETYPE(filter)) {
- filter_name = pdf_name_value(filter);
- if (filter_name && !strcmp(filter_name, "FlateDecode"))
- return add_stream_flate(dst, stream_data, stream_length);
- else {
- WARN("DecodeFilter \"%s\" not supported.", filter_name);
- return -1;
- }
- } else if (PDF_OBJ_ARRAYTYPE(filter)) {
- if (pdf_array_length(filter) > 1) {
- WARN("Multiple DecodeFilter not supported.");
- return -1;
- } else {
- filter_name = pdf_name_value(pdf_get_array(filter, 0));
- if (filter_name && !strcmp(filter_name, "FlateDecode"))
- return add_stream_flate(dst, stream_data, stream_length);
- else {
- WARN("DecodeFilter \"%s\" not supported.", filter_name);
- return -1;
- }
- }
- } else
- ERROR("Broken PDF file?");
-#endif /* HAVE_ZLIB */
- }
-
- return -1;
-}
-#endif
diff --git a/Build/source/texk/dvipdfm-x/epdf.h b/Build/source/texk/dvipdfm-x/epdf.h
index c51f15f084c..19571b22caf 100644
--- a/Build/source/texk/dvipdfm-x/epdf.h
+++ b/Build/source/texk/dvipdfm-x/epdf.h
@@ -32,9 +32,10 @@
#define pdfbox_trim 4
#define pdfbox_art 5
-extern int pdf_copy_clip (FILE *image_file, int page_index, double x_user, double y_user);
+extern int pdf_copy_clip (FILE *image_file, int page_index,
+ double x_user, double y_user);
-extern int pdf_include_page (pdf_ximage *ximage, FILE *file,
- const char *filename);
+extern int pdf_include_page (pdf_ximage * ximage, FILE *file,
+ const char *ident, load_options options);
#endif /* _EPDF_H_ */
diff --git a/Build/source/texk/dvipdfm-x/pdfdoc.c b/Build/source/texk/dvipdfm-x/pdfdoc.c
index ecda8351ff3..95e464804cf 100644
--- a/Build/source/texk/dvipdfm-x/pdfdoc.c
+++ b/Build/source/texk/dvipdfm-x/pdfdoc.c
@@ -88,6 +88,7 @@ read_thumbnail (const char *thumb_filename)
pdf_obj *image_ref;
int xobj_id;
FILE *fp;
+ load_options options = {1, 0, NULL};
fp = MFOPEN(thumb_filename, FOPEN_RBIN_MODE);
if (!fp) {
@@ -101,7 +102,7 @@ read_thumbnail (const char *thumb_filename)
}
MFCLOSE(fp);
- xobj_id = pdf_ximage_findresource(thumb_filename, 0, NULL);
+ xobj_id = pdf_ximage_findresource(thumb_filename, options);
if (xobj_id < 0) {
WARN("Could not read thumbnail file \"%s\".", thumb_filename);
image_ref = NULL;
@@ -880,6 +881,35 @@ pdf_doc_close_page_tree (pdf_doc *p)
return;
}
+int
+pdf_doc_get_page_count (pdf_file *pf)
+{
+ int count = 0;
+ pdf_obj *page_tree = NULL;
+ pdf_obj *catalog;
+
+ catalog = pdf_file_get_catalog(pf);
+
+ page_tree = pdf_deref_obj(pdf_lookup_dict(catalog, "Pages"));
+
+ if (!PDF_OBJ_DICTTYPE(page_tree)) {
+ return 0;
+ }
+
+ {
+ pdf_obj *tmp = pdf_deref_obj(pdf_lookup_dict(page_tree, "Count"));
+ if (!PDF_OBJ_NUMBERTYPE(tmp)) {
+ if (tmp)
+ pdf_release_obj(tmp);
+ return 0;
+ }
+ count = pdf_number_value(tmp);
+ pdf_release_obj(tmp);
+ }
+
+ return count;
+}
+
/*
* From PDFReference15_v6.pdf (p.119 and p.834)
*
@@ -932,9 +962,14 @@ pdf_doc_close_page_tree (pdf_doc *p)
* displayed or printed. The value must be a multiple of 90. Default value: 0.
*/
+/* count_p removed: Please use different interface if you want to get total page
+ * number. pdf_doc_get_page() is obviously not an interface to do such.
+ */
pdf_obj *
-pdf_doc_get_page (pdf_file *pf, int page_no, int *count_p,
- pdf_rect *bbox, pdf_obj **resources_p) {
+pdf_doc_get_page (pdf_file *pf,
+ int page_no, int options, /* load options */
+ pdf_rect *bbox, pdf_obj **resources_p /* returned values */
+ ) {
pdf_obj *page_tree = NULL;
pdf_obj *resources = NULL, *box = NULL, *rotate = NULL, *medbox = NULL;
pdf_obj *catalog;
@@ -956,9 +991,7 @@ pdf_doc_get_page (pdf_file *pf, int page_no, int *count_p,
}
count = pdf_number_value(tmp);
pdf_release_obj(tmp);
- if (count_p)
- *count_p = count;
- if (page_no <= 0 || page_no > count) {
+ if (page_no < 0 || page_no > count) {
WARN("Page %ld does not exist.", page_no);
goto error_silent;
}
@@ -1064,7 +1097,8 @@ pdf_doc_get_page (pdf_file *pf, int page_no, int *count_p,
goto error;
}
- if (PageBox == 0) {
+ /* Nasty BBox selection... */
+ if (options == 0) {
if (crop_box)
box = crop_box;
else {
@@ -1086,7 +1120,7 @@ pdf_doc_get_page (pdf_file *pf, int page_no, int *count_p,
}
}
}
- } else if (PageBox == 1) {
+ } else if (options == 1) {
if (crop_box)
box = crop_box;
else
@@ -1096,7 +1130,7 @@ pdf_doc_get_page (pdf_file *pf, int page_no, int *count_p,
art_box) {
box = art_box;
}
- } else if (PageBox == 2) {
+ } else if (options == 2) {
if (media_box)
box = media_box;
else
@@ -1106,7 +1140,7 @@ pdf_doc_get_page (pdf_file *pf, int page_no, int *count_p,
art_box) {
box = art_box;
}
- } else if (PageBox == 3) {
+ } else if (options == 3) {
if (art_box)
box = art_box;
else
@@ -1116,7 +1150,7 @@ pdf_doc_get_page (pdf_file *pf, int page_no, int *count_p,
trim_box) {
box = trim_box;
}
- } else if (PageBox == 4) {
+ } else if (options == 4) {
if (trim_box)
box = trim_box;
else
@@ -1126,7 +1160,7 @@ pdf_doc_get_page (pdf_file *pf, int page_no, int *count_p,
art_box) {
box = art_box;
}
- } else if (PageBox == 5) {
+ } else if (options == 5) {
if (bleed_box)
box = bleed_box;
else
@@ -1174,7 +1208,7 @@ pdf_doc_get_page (pdf_file *pf, int page_no, int *count_p,
}
/* New scheme only for XDV files */
- if (medbox && (is_xdv || PageBox)) {
+ if (medbox && (is_xdv || options)) {
for (i = 4; i--; ) {
double x;
pdf_obj *tmp = pdf_deref_obj(pdf_get_array(medbox, i));
diff --git a/Build/source/texk/dvipdfm-x/pdfdoc.h b/Build/source/texk/dvipdfm-x/pdfdoc.h
index 61a806e9c8d..20b58807bd4 100644
--- a/Build/source/texk/dvipdfm-x/pdfdoc.h
+++ b/Build/source/texk/dvipdfm-x/pdfdoc.h
@@ -56,7 +56,8 @@ extern pdf_obj *pdf_doc_get_reference (const char *category);
#define pdf_doc_names() pdf_doc_get_dictionary("Names")
#define pdf_doc_this_page() pdf_doc_get_dictionary("@THISPAGE")
-extern pdf_obj *pdf_doc_get_page (pdf_file *pf, int page_no, int *count_p,
+extern int pdf_doc_get_page_count (pdf_file *pf);
+extern pdf_obj *pdf_doc_get_page (pdf_file *pf, int page_no, int options,
pdf_rect *bbox, pdf_obj **resources_p);
extern int pdf_doc_current_page_number (void);
diff --git a/Build/source/texk/dvipdfm-x/pdfximage.c b/Build/source/texk/dvipdfm-x/pdfximage.c
index b96dbc5ced2..3cda219d1b9 100644
--- a/Build/source/texk/dvipdfm-x/pdfximage.c
+++ b/Build/source/texk/dvipdfm-x/pdfximage.c
@@ -47,7 +47,8 @@
static int check_for_ps (FILE *image_file);
static int check_for_mp (FILE *image_file);
-static int ps_include_page (pdf_ximage *ximage, const char *file_name);
+static int ps_include_page (pdf_ximage *ximage,
+ const char *ident, load_options options);
#define IMAGE_TYPE_UNKNOWN -1
@@ -65,13 +66,19 @@ struct attr_
int width, height;
double xdensity, ydensity;
pdf_rect bbox;
+
+ /* Not appropriate place but... someone need them. */
+ int page_no;
+ int page_count;
+ int bbox_type; /* Ugh */
+ pdf_obj *dict;
+ char tempfile;
};
struct pdf_ximage_
{
char *ident;
char res_name[16];
- int page_no, page_count;
int subtype;
@@ -80,9 +87,7 @@ struct pdf_ximage_
char *filename;
pdf_obj *reference;
pdf_obj *resource;
- pdf_obj *attr_dict;
- char tempfile;
};
@@ -111,34 +116,27 @@ static struct ic_ _ic = {
};
static void
-pdf_init_ximage_struct (pdf_ximage *I,
- const char *ident, const char *filename,
- int page_no, pdf_obj *dict)
+pdf_init_ximage_struct (pdf_ximage *I)
{
- if (ident) {
- I->ident = NEW(strlen(ident)+1, char);
- strcpy(I->ident, ident);
- } else
- I ->ident = NULL;
- I->page_no = page_no;
- I->page_count = 0;
- if (filename) {
- I->filename = NEW(strlen(filename)+1, char);
- strcpy(I->filename, filename);
- } else
+ I->ident = NULL;
I->filename = NULL;
+
I->subtype = -1;
memset(I->res_name, 0, 16);
I->reference = NULL;
I->resource = NULL;
- I->attr_dict = dict;
I->attr.width = I->attr.height = 0;
I->attr.xdensity = I->attr.ydensity = 1.0;
I->attr.bbox.llx = I->attr.bbox.lly = 0;
I->attr.bbox.urx = I->attr.bbox.ury = 0;
- I->tempfile = 0;
+ I->attr.page_no = 1;
+ I->attr.page_count = 1;
+ I->attr.bbox_type = 0;
+
+ I->attr.dict = NULL;
+ I->attr.tempfile = 0;
}
static void
@@ -148,7 +146,7 @@ pdf_set_ximage_tempfile (pdf_ximage *I, const char *filename)
RELEASE(I->filename);
I->filename = NEW(strlen(filename)+1, char);
strcpy(I->filename, filename);
- I->tempfile = 1;
+ I->attr.tempfile = 1;
}
static void
@@ -162,9 +160,9 @@ pdf_clean_ximage_struct (pdf_ximage *I)
pdf_release_obj(I->reference);
if (I->resource)
pdf_release_obj(I->resource);
- if (I->attr_dict)
- pdf_release_obj(I->attr_dict);
- pdf_init_ximage_struct(I, NULL, NULL, 0, NULL);
+ if (I->attr.dict) /* unsafe? */
+ pdf_release_obj(I->attr.dict);
+ pdf_init_ximage_struct(I);
}
@@ -185,7 +183,7 @@ pdf_close_images (void)
int i;
for (i = 0; i < ic->count; i++) {
pdf_ximage *I = ic->ximages+i;
- if (I->tempfile) {
+ if (I->attr.tempfile) {
/*
* It is important to remove temporary files at the end because
* we cache file names. Since we use mkstemp to create them, we
@@ -254,7 +252,7 @@ source_image_type (FILE *fp)
static int
load_image (const char *ident, const char *fullname, int format, FILE *fp,
- int page_no, pdf_obj *dict)
+ load_options options)
{
struct ic_ *ic = &_ic;
int id = -1; /* ret */
@@ -267,7 +265,19 @@ load_image (const char *ident, const char *fullname, int format, FILE *fp,
}
I = &ic->ximages[id];
- pdf_init_ximage_struct(I, ident, fullname, page_no, dict);
+ pdf_init_ximage_struct(I);
+ if (ident) {
+ I->ident = NEW(strlen(ident)+1, char);
+ strcpy(I->ident, ident);
+ }
+ if (fullname) {
+ I->filename = NEW(strlen(fullname)+1, char);
+ strcpy(I->filename, fullname);
+ }
+
+ I->attr.page_no = options.page_no;
+ I->attr.bbox_type = options.bbox_type;
+ I->attr.dict = options.dict; /* unsafe? */
switch (format) {
case IMAGE_TYPE_JPEG:
@@ -304,15 +314,15 @@ load_image (const char *ident, const char *fullname, int format, FILE *fp,
if (_opts.verbose)
MESG("[PDF]");
{
- int result = pdf_include_page(I, fp, fullname);
+ int result = pdf_include_page(I, fp, fullname, options);
if (result > 0)
/* PDF version too recent */
- result = ps_include_page(I, fullname);
+ result = ps_include_page(I, fullname, options);
if (result < 0)
goto error;
}
if (_opts.verbose)
- MESG(",Page:%ld", I->page_no);
+ MESG(",Page:%ld", I->attr.page_no);
I->subtype = PDF_XOBJECT_TYPE_FORM;
break;
/*
@@ -321,10 +331,10 @@ load_image (const char *ident, const char *fullname, int format, FILE *fp,
default:
if (_opts.verbose)
MESG(format == IMAGE_TYPE_EPS ? "[PS]" : "[UNKNOWN]");
- if (ps_include_page(I, fullname) < 0)
+ if (ps_include_page(I, fullname, options) < 0)
goto error;
if (_opts.verbose)
- MESG(",Page:%ld", I->page_no);
+ MESG(",Page:%ld", I->attr.page_no);
I->subtype = PDF_XOBJECT_TYPE_FORM;
}
@@ -354,10 +364,8 @@ load_image (const char *ident, const char *fullname, int format, FILE *fp,
#define dpx_fopen(n,m) (MFOPEN((n),(m)))
#define dpx_fclose(f) (MFCLOSE((f)))
-uint8_t PageBox_of_id[MAX_IMAGES];
-
int
-pdf_ximage_findresource (const char *ident, int page_no, pdf_obj *dict)
+pdf_ximage_findresource (const char *ident, load_options options)
{
struct ic_ *ic = &_ic;
int id = -1;
@@ -366,21 +374,20 @@ pdf_ximage_findresource (const char *ident, int page_no, pdf_obj *dict)
int format;
FILE *fp;
+ /* I don't understand why there is comparision against I->attr.dict here...
+ * I->attr.dict and options.dict are simply pointers to PDF dictionaries.
+ */
for (id = 0; id < ic->count; id++) {
I = &ic->ximages[id];
if (I->ident && !strcmp(ident, I->ident)) {
f = I->filename;
- if (I->page_no == page_no + (page_no < 0 ? I->page_count+1 : 0) &&
- I->attr_dict == dict) {
- if (ImageSpecial) {
- if ((int)PageBox_of_id[id] == PageBox)
- return id;
- } else {
+ if (I->attr.page_no == options.page_no /* Not sure */
+ && I->attr.dict == options.dict /* ????? */
+ && I->attr.bbox_type == options.bbox_type) {
return id;
}
}
}
- }
if (f) {
/* we already have converted this file; f is the temporary file name */
@@ -420,7 +427,7 @@ pdf_ximage_findresource (const char *ident, int page_no, pdf_obj *dict)
} else
break;
default:
- id = load_image(ident, fullname, format, fp, page_no, dict);
+ id = load_image(ident, fullname, format, fp, options);
break;
}
dpx_fclose(fp);
@@ -534,8 +541,8 @@ pdf_ximage_set_image (pdf_ximage *I, void *image_info, pdf_obj *resource)
if (info->bits_per_component > 0) /* Ignored for JPXDecode filter. FIXME */
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);
+ 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;
@@ -562,7 +569,7 @@ pdf_ximage_set_form (pdf_ximage *I, void *form_info, pdf_obj *resource)
int
pdf_ximage_get_page (pdf_ximage *I)
{
- return I->page_no;
+ return I->attr.page_no;
}
#define CHECK_ID(c,n) do {\
@@ -604,7 +611,12 @@ pdf_ximage_defineresource (const char *ident,
I = &ic->ximages[id];
- pdf_init_ximage_struct(I, ident, NULL, 0, NULL);
+ pdf_init_ximage_struct(I);
+
+ if (ident) {
+ I->ident = NEW(strlen(ident)+1, char);
+ strcpy(I->ident, ident);
+ }
switch (subtype) {
case PDF_XOBJECT_TYPE_IMAGE:
@@ -889,7 +901,7 @@ char *get_distiller_template (void)
}
static int
-ps_include_page (pdf_ximage *ximage, const char *filename)
+ps_include_page (pdf_ximage *ximage, const char *filename, load_options options)
{
char *distiller_template = _opts.cmdtmpl;
char *temp;
@@ -950,10 +962,7 @@ ps_include_page (pdf_ximage *ximage, const char *filename)
return -1;
}
pdf_set_ximage_tempfile(ximage, temp);
-#if 0
- error = pdf_include_page(ximage, fp, 0, pdfbox_crop);
-#endif
- error = pdf_include_page(ximage, fp, temp);
+ error = pdf_include_page(ximage, fp, temp, options);
MFCLOSE(fp);
/* See pdf_close_images for why we cannot delete temporary files here. */
diff --git a/Build/source/texk/dvipdfm-x/pdfximage.h b/Build/source/texk/dvipdfm-x/pdfximage.h
index e3507a5d199..dab463e890e 100644
--- a/Build/source/texk/dvipdfm-x/pdfximage.h
+++ b/Build/source/texk/dvipdfm-x/pdfximage.h
@@ -49,6 +49,12 @@ typedef struct {
pdf_tmatrix matrix;
} xform_info;
+typedef struct {
+ int page_no;
+ int bbox_type;
+ pdf_obj *dict;
+} load_options;
+
typedef struct pdf_ximage_ pdf_ximage;
extern void pdf_ximage_set_verbose (void);
@@ -59,17 +65,22 @@ extern void pdf_close_images (void);
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, int page_no,
- pdf_obj *dict);
+/* Please use different interface than findresource...
+ * This is not intended to be used for specifying page number and others.
+ * Only pdf:image special in spc_pdfm.c want optinal dict!
+ */
+extern int pdf_ximage_findresource (const char *ident,
+ load_options options);
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);
extern void pdf_ximage_init_form_info (xform_info *info);
-extern void pdf_ximage_set_image (pdf_ximage *ximage, void *info, pdf_obj *resource);
-extern void pdf_ximage_set_form (pdf_ximage *ximage, void *info, pdf_obj *resource);
+extern void pdf_ximage_set_image (pdf_ximage *ximage,
+ void *info, pdf_obj *resource);
+extern void pdf_ximage_set_form (pdf_ximage *ximage,
+ void *info, pdf_obj *resource);
extern int pdf_ximage_get_page (pdf_ximage *I);
/* from pdfximage.c */
@@ -90,4 +101,7 @@ pdf_ximage_set_attr (int xobj_id,
int width, int height, double xdensity, double ydensity,
double llx, double lly, double urx, double ury);
+/* Migrated from pdfobj.h. Those are not PDF object related... */
+#define MAX_IMAGES 5000 /* This may be enough */
+
#endif /* _PDFXIMAGE_H_ */
diff --git a/Build/source/texk/dvipdfm-x/spc_dvips.c b/Build/source/texk/dvipdfm-x/spc_dvips.c
index 3fbae93436d..2da287fda50 100644
--- a/Build/source/texk/dvipdfm-x/spc_dvips.c
+++ b/Build/source/texk/dvipdfm-x/spc_dvips.c
@@ -140,6 +140,7 @@ spc_handler_ps_file (struct spc_env *spe, struct spc_arg *args)
int form_id;
char *filename;
transform_info ti;
+ load_options options = {1, 0, NULL};
ASSERT(spe && args);
@@ -158,12 +159,12 @@ spc_handler_ps_file (struct spc_env *spe, struct spc_arg *args)
}
transform_info_clear(&ti);
- if (spc_util_read_dimtrns(spe, &ti, args, NULL, 1) < 0) {
+ if (spc_util_read_dimtrns(spe, &ti, args, 1) < 0) {
RELEASE(filename);
return -1;
}
- form_id = pdf_ximage_findresource(filename, 1, NULL);
+ form_id = pdf_ximage_findresource(filename, options);
if (form_id < 0) {
spc_warn(spe, "Failed to read image file: %s", filename);
RELEASE(filename);
@@ -184,6 +185,7 @@ spc_handler_ps_plotfile (struct spc_env *spe, struct spc_arg *args)
int form_id;
char *filename;
transform_info p;
+ load_options options = {1, 0, NULL};
ASSERT(spe && args);
@@ -196,7 +198,7 @@ spc_handler_ps_plotfile (struct spc_env *spe, struct spc_arg *args)
return -1;
}
- form_id = pdf_ximage_findresource(filename, 1, NULL);
+ form_id = pdf_ximage_findresource(filename, options);
if (form_id < 0) {
spc_warn(spe, "Could not open PS file: %s", filename);
error = -1;
@@ -632,9 +634,10 @@ spc_handler_ps_tricks_parse_path (struct spc_env *spe, struct spc_arg *args)
static int
spc_handler_ps_tricks_render (struct spc_env *spe, struct spc_arg *args)
{
- FILE* fp;
+ FILE *fp;
int k;
pdf_tmatrix M;
+ load_options options = {1, 0, NULL};
if (!distiller_template)
distiller_template = get_distiller_template();
@@ -706,7 +709,7 @@ spc_handler_ps_tricks_render (struct spc_env *spe, struct spc_arg *args)
return error;
}
- form_id = pdf_ximage_findresource(gs_out, 1, NULL);
+ form_id = pdf_ximage_findresource(gs_out, options);
if (form_id < 0) {
spc_warn(spe, "Failed to read converted PSTricks image file.");
RELEASE(gs_in);
diff --git a/Build/source/texk/dvipdfm-x/spc_html.c b/Build/source/texk/dvipdfm-x/spc_html.c
index d5fc656ae58..a49c06bc47c 100644
--- a/Build/source/texk/dvipdfm-x/spc_html.c
+++ b/Build/source/texk/dvipdfm-x/spc_html.c
@@ -570,6 +570,7 @@ spc_html__img_empty (struct spc_env *spe, pdf_obj *attr)
{
pdf_obj *src, *obj;
transform_info ti;
+ load_options options = {1, 0, NULL};
int id, error = 0;
#ifdef ENABLE_HTML_SVG_OPACITY
double alpha = 1.0; /* meaning fully opaque */
@@ -636,7 +637,7 @@ spc_html__img_empty (struct spc_env *spe, pdf_obj *attr)
return error;
}
- id = pdf_ximage_findresource(pdf_string_value(src), 0, NULL);
+ id = pdf_ximage_findresource(pdf_string_value(src), options);
if (id < 0) {
spc_warn(spe, "Could not find/load image: %s", pdf_string_value(src));
error = -1;
@@ -939,4 +940,3 @@ spc_html_setup_handler (struct spc_handler *sph,
return 0;
}
-
diff --git a/Build/source/texk/dvipdfm-x/spc_misc.c b/Build/source/texk/dvipdfm-x/spc_misc.c
index 0b5355145f3..7bdf80ec4e6 100644
--- a/Build/source/texk/dvipdfm-x/spc_misc.c
+++ b/Build/source/texk/dvipdfm-x/spc_misc.c
@@ -52,6 +52,7 @@ spc_handler_postscriptbox (struct spc_env *spe, struct spc_arg *ap)
{
int form_id, len;
transform_info ti;
+ load_options options = {1, 0, NULL};
char filename[256], *fullname;
char buf[512];
FILE *fp;
@@ -109,7 +110,7 @@ spc_handler_postscriptbox (struct spc_env *spe, struct spc_arg *ap)
}
MFCLOSE(fp);
- form_id = pdf_ximage_findresource(filename, 0, NULL);
+ form_id = pdf_ximage_findresource(filename, options);
if (form_id < 0) {
spc_warn(spe, "Failed to load image file: %s", filename);
return -1;
diff --git a/Build/source/texk/dvipdfm-x/spc_pdfm.c b/Build/source/texk/dvipdfm-x/spc_pdfm.c
index 1b12dd966eb..c8d2bef7c56 100644
--- a/Build/source/texk/dvipdfm-x/spc_pdfm.c
+++ b/Build/source/texk/dvipdfm-x/spc_pdfm.c
@@ -567,7 +567,7 @@ spc_handler_pdfm_annot (struct spc_env *spe, struct spc_arg *args)
}
transform_info_clear(&ti);
- if (spc_util_read_dimtrns(spe, &ti, args, NULL, 0) < 0) {
+ if (spc_util_read_dimtrns(spe, &ti, args, 0) < 0) {
if (ident)
RELEASE(ident);
return -1;
@@ -745,7 +745,7 @@ spc_handler_pdfm_btrans (struct spc_env *spe, struct spc_arg *args)
transform_info ti;
transform_info_clear(&ti);
- if (spc_util_read_dimtrns(spe, &ti, args, NULL, 0) < 0) {
+ if (spc_util_read_dimtrns(spe, &ti, args, 0) < 0) {
return -1;
}
@@ -908,7 +908,7 @@ spc_handler_pdfm_bead (struct spc_env *spe, struct spc_arg *args)
/* If okay so far, try to get a bounding box */
transform_info_clear(&ti);
- if (spc_util_read_dimtrns(spe, &ti, args, NULL, 0) < 0) {
+ if (spc_util_read_dimtrns(spe, &ti, args, 0) < 0) {
RELEASE(article_name);
return -1;
}
@@ -962,8 +962,6 @@ spc_handler_pdfm_bead (struct spc_env *spe, struct spc_arg *args)
return 0;
}
-int ImageSpecial = 0; /* default value */
-
static int
spc_handler_pdfm_image (struct spc_env *spe, struct spc_arg *args)
{
@@ -972,12 +970,7 @@ spc_handler_pdfm_image (struct spc_env *spe, struct spc_arg *args)
char *ident = NULL;
pdf_obj *fspec, *attr = NULL;
transform_info ti;
- int page_no;
-
-/*
- Initialize the PageBox as the default value
-*/
- PageBox = 0;
+ load_options options = {1, 0, NULL};
skip_white(&args->curptr, args->endptr);
if (args->curptr[0] == '@') {
@@ -990,9 +983,15 @@ spc_handler_pdfm_image (struct spc_env *spe, struct spc_arg *args)
}
}
+ /* 2015/12/29
+ * There should not be "page" and "pagebox" in read_dimtrns().
+ * It is for reading "dimensions" and "transformations" and "page" is
+ * completely unrelated.
+ */
transform_info_clear(&ti);
- page_no = 1;
- if (spc_util_read_dimtrns(spe, &ti, args, &page_no, 0) < 0) {
+ if (spc_util_read_blahblah(spe, &ti,
+ &options.page_no, &options.bbox_type, args) < 0) {
+ spc_warn(spe, "Reading option field in pdf:image failed.");
if (ident)
RELEASE(ident);
return -1;
@@ -1015,16 +1014,14 @@ spc_handler_pdfm_image (struct spc_env *spe, struct spc_arg *args)
skip_white(&args->curptr, args->endptr);
if (args->curptr < args->endptr) {
- attr = parse_pdf_object(&args->curptr, args->endptr, NULL);
+ options.dict = 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);
}
}
- ImageSpecial = 1;
- xobj_id = pdf_ximage_findresource(pdf_string_value(fspec), page_no, attr);
- ImageSpecial = 0;
+ xobj_id = pdf_ximage_findresource(pdf_string_value(fspec), options);
if (xobj_id < 0) {
spc_warn(spe, "Could not find image resource...");
@@ -1042,8 +1039,6 @@ spc_handler_pdfm_image (struct spc_env *spe, struct spc_arg *args)
return -1;
}
- PageBox_of_id[xobj_id] = (uint8_t)PageBox;
-
if (!(ti.flags & INFO_DO_HIDE))
pdf_dev_put_image(xobj_id, &ti, spe->x_user, spe->y_user);
@@ -1553,7 +1548,7 @@ spc_handler_pdfm_bform (struct spc_env *spe, struct spc_arg *args)
}
transform_info_clear(&ti);
- if (spc_util_read_dimtrns(spe, &ti, args, NULL, 0) < 0) {
+ if (spc_util_read_dimtrns(spe, &ti, args, 0) < 0) {
RELEASE(ident);
return -1;
}
@@ -1653,6 +1648,7 @@ spc_handler_pdfm_uxobj (struct spc_env *spe, struct spc_arg *args)
int xobj_id;
char *ident;
transform_info ti;
+ load_options options = {1, 0, NULL};
skip_white(&args->curptr, args->endptr);
@@ -1664,7 +1660,7 @@ spc_handler_pdfm_uxobj (struct spc_env *spe, struct spc_arg *args)
transform_info_clear(&ti);
if (args->curptr < args->endptr) {
- if (spc_util_read_dimtrns(spe, &ti, args, NULL, 0) < 0) {
+ if (spc_util_read_dimtrns(spe, &ti, args, 0) < 0) {
RELEASE(ident);
return -1;
}
@@ -1676,7 +1672,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, NULL);
+ xobj_id = pdf_ximage_findresource(ident, options);
if (xobj_id < 0) {
spc_warn(spe, "Specified (image) object doesn't exist: %s", ident);
RELEASE(ident);
diff --git a/Build/source/texk/dvipdfm-x/spc_util.c b/Build/source/texk/dvipdfm-x/spc_util.c
index 0c84a9c79b2..3f4b0a139e9 100644
--- a/Build/source/texk/dvipdfm-x/spc_util.c
+++ b/Build/source/texk/dvipdfm-x/spc_util.c
@@ -365,7 +365,8 @@ make_transmatrix (pdf_tmatrix *M,
}
static int
-spc_read_dimtrns_dvips (struct spc_env *spe, transform_info *t, struct spc_arg *ap)
+spc_read_dimtrns_dvips (struct spc_env *spe,
+ transform_info *t, struct spc_arg *ap)
{
static const char *_dtkeys[] = {
#define K_TRN__HOFFSET 0
@@ -507,9 +508,13 @@ spc_read_dimtrns_dvips (struct spc_env *spe, transform_info *t, struct spc_arg *
return error;
}
-
+/* "page" and "pagebox" are not dimension nor transformation nor
+ * something acceptable to put into here.
+ * PLEASE DONT ADD HERE!
+ */
static int
-spc_read_dimtrns_pdfm (struct spc_env *spe, transform_info *p, struct spc_arg *ap, int *page_no)
+spc_read_dimtrns_pdfm (struct spc_env *spe,
+ transform_info *p, struct spc_arg *ap)
{
int has_scale, has_xscale, has_yscale, has_rotate, has_matrix;
const char *_dtkeys[] = {
@@ -529,10 +534,195 @@ spc_read_dimtrns_pdfm (struct spc_env *spe, transform_info *p, struct spc_arg *a
#undef K__CLIP
#define K__CLIP 9
"clip",
-#define K__PAGE 10
- "page",
-#define K__HIDE 11
+#define K__HIDE 10
+ "hide",
+ NULL
+ };
+ double xscale, yscale, rotate;
+ int error = 0;
+
+ 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);
+
+ while (!error && ap->curptr < ap->endptr) {
+ char *kp, *vp;
+ int k;
+
+ kp = parse_c_ident(&ap->curptr, ap->endptr);
+ if (!kp)
+ break;
+
+ skip_blank(&ap->curptr, ap->endptr);
+ for (k = 0; _dtkeys[k] && strcmp(_dtkeys[k], kp); k++);
+ switch (k) {
+ case K_DIM__WIDTH:
+ error = spc_util_read_length(spe, &p->width , ap);
+ p->flags |= INFO_HAS_WIDTH;
+ break;
+ case K_DIM__HEIGHT:
+ error = spc_util_read_length(spe, &p->height, ap);
+ p->flags |= INFO_HAS_HEIGHT;
+ break;
+ case K_DIM__DEPTH:
+ error = spc_util_read_length(spe, &p->depth , ap);
+ p->flags |= INFO_HAS_HEIGHT;
+ break;
+ case K_TRN__SCALE:
+ vp = parse_float_decimal(&ap->curptr, ap->endptr);
+ if (!vp)
+ error = -1;
+ else {
+ xscale = yscale = atof(vp);
+ has_scale = 1;
+ RELEASE(vp);
+ }
+ break;
+ case K_TRN__XSCALE:
+ vp = parse_float_decimal(&ap->curptr, ap->endptr);
+ if (!vp)
+ error = -1;
+ else {
+ xscale = atof(vp);
+ has_xscale = 1;
+ RELEASE(vp);
+ }
+ break;
+ case K_TRN__YSCALE:
+ vp = parse_float_decimal(&ap->curptr, ap->endptr);
+ if (!vp)
+ error = -1;
+ else {
+ yscale = atof(vp);
+ has_yscale = 1;
+ RELEASE(vp);
+ }
+ break;
+ case K_TRN__ROTATE:
+ vp = parse_float_decimal(&ap->curptr, ap->endptr);
+ if (!vp)
+ error = -1;
+ else {
+ rotate = M_PI * atof(vp) / 180.0;
+ has_rotate = 1;
+ RELEASE(vp);
+ }
+ break;
+ case K_TRN__BBOX:
+ {
+ double v[4];
+ if (spc_util_read_numbers(v, 4, ap) != 4)
+ error = -1;
+ else {
+ p->bbox.llx = v[0];
+ p->bbox.lly = v[1];
+ p->bbox.urx = v[2];
+ p->bbox.ury = v[3];
+ p->flags |= INFO_HAS_USER_BBOX;
+ }
+ }
+ break;
+ case K_TRN__MATRIX:
+ {
+ double v[6];
+ if (spc_util_read_numbers(v, 6, ap) != 6)
+ error = -1;
+ else {
+ pdf_setmatrix(&(p->matrix), v[0], v[1], v[2], v[3], v[4], v[5]);
+ has_matrix = 1;
+ }
+ }
+ break;
+ case K__CLIP:
+ vp = parse_float_decimal(&ap->curptr, ap->endptr);
+ if (!vp)
+ error = -1;
+ else {
+ if (atof(vp))
+ p->flags |= INFO_DO_CLIP;
+ else
+ p->flags &= ~INFO_DO_CLIP;
+ RELEASE(vp);
+ }
+ break;
+ case K__HIDE:
+ p->flags |= INFO_DO_HIDE;
+ break;
+
+ default:
+ error = -1;
+ break;
+ }
+ if (error)
+ spc_warn(spe, "Unrecognized key or invalid value for " \
+ "dimension/transformation: %s", kp);
+ else
+ skip_blank(&ap->curptr, ap->endptr);
+ RELEASE(kp);
+ }
+
+ if (!error) {
+ /* Check consistency */
+ if (has_xscale && (p->flags & INFO_HAS_WIDTH)) {
+ spc_warn(spe, "Can't supply both width and xscale. Ignore xscale.");
+ xscale = 1.0;
+ } else if (has_yscale &&
+ (p->flags & INFO_HAS_HEIGHT)) {
+ spc_warn(spe, "Can't supply both height/depth and yscale. Ignore yscale.");
+ yscale = 1.0;
+ } else if (has_scale &&
+ (has_xscale || has_yscale)) {
+ spc_warn(spe, "Can't supply overall scale along with axis scales.");
+ error = -1;
+ } else if (has_matrix &&
+ (has_scale || has_xscale || has_yscale || has_rotate)) {
+ spc_warn(spe, "Can't supply transform matrix along with scales or rotate. Ignore scales and rotate.");
+ }
+ }
+
+ if (!has_matrix) {
+ make_transmatrix(&(p->matrix), 0.0, 0.0, xscale, yscale, rotate);
+ }
+
+ if (!(p->flags & INFO_HAS_USER_BBOX)) {
+ p->flags &= ~INFO_DO_CLIP; /* no clipping needed */
+ }
+
+ return error;
+}
+
+int
+spc_util_read_dimtrns (struct spc_env *spe,
+ transform_info *ti, struct spc_arg *args, int syntax)
+{
+ if (!ti || !spe || !args)
+ return -1;
+
+ if (syntax) {
+ return spc_read_dimtrns_dvips(spe, ti, args);
+ } else {
+ return spc_read_dimtrns_pdfm (spe, ti, args);
+ }
+}
+
+int
+spc_util_read_blahblah (struct spc_env *spe,
+ transform_info *p, int *page_no, int *bbox_type,
+ struct spc_arg *ap)
+{
+ int has_scale, has_xscale, has_yscale, has_rotate, has_matrix;
+ const char *_dtkeys[] = {
+ "width", "height", "depth",
+ "scale", "xscale", "yscale", "rotate",
+ "bbox",
+ "matrix",
+ "clip",
"hide",
+#define K__PAGE 11
+ "page",
#define K__PAGEBOX 12
"pagebox",
NULL
@@ -647,6 +837,7 @@ spc_read_dimtrns_pdfm (struct spc_env *spe, transform_info *p, struct spc_arg *a
RELEASE(vp);
}
break;
+
case K__PAGE:
{
double page;
@@ -664,22 +855,27 @@ spc_read_dimtrns_pdfm (struct spc_env *spe, transform_info *p, struct spc_arg *a
char *q;
q = parse_c_ident (&ap->curptr, ap->endptr);
if (q) {
- if (strcasecmp(q, "cropbox") == 0) PageBox = 1;
- else if (strcasecmp(q, "mediabox") == 0) PageBox = 2;
- else if (strcasecmp(q, "artbox") == 0) PageBox = 3;
- else if (strcasecmp(q, "trimbox") == 0) PageBox = 4;
- else if (strcasecmp(q, "bleedbox") == 0) PageBox = 5;
- } else {
- PageBox = 0;
+ if (bbox_type) {
+ if (strcasecmp(q, "cropbox") == 0) *bbox_type = 1;
+ else if (strcasecmp(q, "mediabox") == 0) *bbox_type = 2;
+ else if (strcasecmp(q, "artbox") == 0) *bbox_type = 3;
+ else if (strcasecmp(q, "trimbox") == 0) *bbox_type = 4;
+ else if (strcasecmp(q, "bleedbox") == 0) *bbox_type = 5;
+ }
+ RELEASE(q);
+ } else if (bbox_type) {
+ *bbox_type = 0;
}
}
break;
+
default:
error = -1;
break;
}
if (error)
- spc_warn(spe, "Unrecognized key or invalid value for dimension/transformation: %s", kp);
+ spc_warn(spe, "Unrecognized key or invalid value for " \
+ "dimension/transformation: %s", kp);
else
skip_blank(&ap->curptr, ap->endptr);
RELEASE(kp);
@@ -715,20 +911,6 @@ spc_read_dimtrns_pdfm (struct spc_env *spe, transform_info *p, struct spc_arg *a
return error;
}
-int
-spc_util_read_dimtrns (struct spc_env *spe, transform_info *ti, struct spc_arg *args, int *page_no, int syntax)
-{
- ASSERT(ti && spe && args);
-
- if (syntax) {
- ASSERT(!page_no);
- return spc_read_dimtrns_dvips(spe, ti, args);
- } else {
- return spc_read_dimtrns_pdfm (spe, ti, args, page_no);
- }
-}
-
-
/* Color names */
#ifdef rgb
#undef rgb
diff --git a/Build/source/texk/dvipdfm-x/spc_util.h b/Build/source/texk/dvipdfm-x/spc_util.h
index 5e71aa3508f..fbc4bb77ff4 100644
--- a/Build/source/texk/dvipdfm-x/spc_util.h
+++ b/Build/source/texk/dvipdfm-x/spc_util.h
@@ -33,10 +33,25 @@
*
* This is for reading *single* color specification.
*/
-extern int spc_util_read_colorspec (struct spc_env *spe, pdf_color *colorspec, struct spc_arg *args, int syntax);
-extern int spc_util_read_dimtrns (struct spc_env *spe, transform_info *dimtrns, struct spc_arg *args, int *page, int syntax);
-
-extern int spc_util_read_numbers (double *values, int num_values, struct spc_arg *args);
-extern int spc_util_read_pdfcolor (struct spc_env *spe, pdf_color *colorspec, struct spc_arg *args, pdf_color *defaultcolor);
+extern int spc_util_read_colorspec (struct spc_env *spe,
+ pdf_color *colorspec,
+ struct spc_arg *args, int syntax);
+extern int spc_util_read_dimtrns (struct spc_env *spe,
+ transform_info *dimtrns,
+ struct spc_arg *args, int syntax);
+
+extern int spc_util_read_blahblah (struct spc_env *spe,
+ transform_info *dimtrns,
+ int *page_no,
+ int *bbox_type,
+ struct spc_arg *args);
+
+
+extern int spc_util_read_numbers (double *values, int num_values,
+ struct spc_arg *args);
+extern int spc_util_read_pdfcolor (struct spc_env *spe,
+ pdf_color *colorspec,
+ struct spc_arg *args,
+ pdf_color *defaultcolor);
#endif /* _SPC_UTIL_H_ */
diff --git a/Build/source/texk/dvipdfm-x/xbb.c b/Build/source/texk/dvipdfm-x/xbb.c
index 742892d4770..b4e03908913 100644
--- a/Build/source/texk/dvipdfm-x/xbb.c
+++ b/Build/source/texk/dvipdfm-x/xbb.c
@@ -256,8 +256,8 @@ static void do_pdf (FILE *fp, char *filename)
WARN("%s does not look like a PDF file...\n", filename);
return;
}
-
- page = pdf_doc_get_page(pf, page_no, &count, &bbox, NULL);
+ count = pdf_doc_get_page_count(pf);
+ page = pdf_doc_get_page(pf, page_no, PageBox, &bbox, NULL);
pdf_close(pf);