diff options
author | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2015-07-22 13:53:38 +0000 |
---|---|---|
committer | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2015-07-22 13:53:38 +0000 |
commit | 1c88be7db4ee3152c958e92aff73398d65dd3273 (patch) | |
tree | b3e60b6a296cb979ffcdb28ea9672837abc3a14f /Build/source/texk | |
parent | 082de82ce7450ffc50aceeab9f44d6b1469e5f3d (diff) |
dvipdfm-x: Improve obtaining boundingbox.
git-svn-id: svn://tug.org/texlive/trunk@37923 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk')
-rw-r--r-- | Build/source/texk/dvipdfm-x/ChangeLog | 4 | ||||
-rw-r--r-- | Build/source/texk/dvipdfm-x/pdfdoc.c | 83 | ||||
-rw-r--r-- | Build/source/texk/dvipdfm-x/spc_pdfm.c | 2 | ||||
-rw-r--r-- | Build/source/texk/dvipdfm-x/spc_util.c | 2 | ||||
-rw-r--r-- | Build/source/texk/dvipdfm-x/xbb.c | 3 |
5 files changed, 63 insertions, 31 deletions
diff --git a/Build/source/texk/dvipdfm-x/ChangeLog b/Build/source/texk/dvipdfm-x/ChangeLog index e6c8225acf6..94feb578cf1 100644 --- a/Build/source/texk/dvipdfm-x/ChangeLog +++ b/Build/source/texk/dvipdfm-x/ChangeLog @@ -1,5 +1,9 @@ 2015-07-22 Akira Kakuto <kakuto@fuk.kindai.ac.jp> + * pdfdoc.c, spc_pdfm.c, spc_util.c, xbb.c: Improve obtaining BoundingBox. + +2015-07-22 Akira Kakuto <kakuto@fuk.kindai.ac.jp> + * spc_pdfm.c: Fix a bug. Forgot to initialize PageBox. Thanks Y. Terada. 2015-07-21 Akira Kakuto <kakuto@fuk.kindai.ac.jp> diff --git a/Build/source/texk/dvipdfm-x/pdfdoc.c b/Build/source/texk/dvipdfm-x/pdfdoc.c index 262ce8a82ff..1c99c6f3958 100644 --- a/Build/source/texk/dvipdfm-x/pdfdoc.c +++ b/Build/source/texk/dvipdfm-x/pdfdoc.c @@ -936,7 +936,7 @@ pdf_obj * pdf_doc_get_page (pdf_file *pf, long page_no, long *count_p, pdf_rect *bbox, pdf_obj **resources_p) { pdf_obj *page_tree = NULL; - pdf_obj *resources = NULL, *box = NULL, *rotate = NULL; + pdf_obj *resources = NULL, *box = NULL, *rotate = NULL, *medbox = NULL; pdf_obj *catalog; catalog = pdf_file_get_catalog(pf); @@ -1063,7 +1063,8 @@ pdf_doc_get_page (pdf_file *pf, long page_no, long *count_p, pdf_release_obj(crop_box); goto error; } - if (PageBox == 1) { + + if (PageBox == 0) { if (crop_box) box = crop_box; else @@ -1076,56 +1077,58 @@ pdf_doc_get_page (pdf_file *pf, long page_no, long *count_p, } if (media_box) pdf_release_obj(media_box); + } else if (PageBox == 1) { + if (crop_box) + box = crop_box; + else + if (!(box = media_box) && + !(box = art_box) && + !(box = trim_box) && + bleed_box) { + box = bleed_box; + } } else if (PageBox == 2) { if (media_box) box = media_box; else - if (!(box = art_box) && + if (!(box = crop_box) && + !(box = art_box) && !(box = trim_box) && - !(box = bleed_box) && - crop_box) { - box = crop_box; + bleed_box) { + box = bleed_box; } } else if (PageBox == 3) { if (art_box) box = art_box; else if (!(box = crop_box) && + !(box = media_box) && !(box = trim_box) && - !(box = bleed_box) && - media_box) { - box = media_box; - media_box = NULL; + bleed_box) { + box = bleed_box; } - if (media_box) - pdf_release_obj(media_box); } else if (PageBox == 4) { if (trim_box) box = trim_box; else - if (!(box = art_box) && - !(box = crop_box) && - !(box = bleed_box) && - media_box) { - box = media_box; - media_box = NULL; + if (!(box = crop_box) && + !(box = media_box) && + !(box = art_box) && + bleed_box) { + box = bleed_box; } - if (media_box) - pdf_release_obj(media_box); } else if (PageBox == 5) { if (bleed_box) box = bleed_box; else - if (!(box = art_box) && - !(box = trim_box) && - !(box = crop_box) && - media_box) { - box = media_box; - media_box = NULL; + if (!(box = crop_box) && + !(box = media_box) && + !(box = art_box) && + trim_box) { + box = trim_box; } - if (media_box) - pdf_release_obj(media_box); } + medbox = media_box; } if (!PDF_OBJ_ARRAYTYPE(box) || pdf_array_length(box) != 4 || @@ -1160,6 +1163,30 @@ pdf_doc_get_page (pdf_file *pf, long page_no, long *count_p, } pdf_release_obj(tmp); } + + if (medbox && PageBox) { + double mllx, mlly, murx, mury; + for (i = 4; i--; ) { + double x; + pdf_obj *tmp = pdf_deref_obj(pdf_get_array(medbox, i)); + if (!PDF_OBJ_NUMBERTYPE(tmp)) { + pdf_release_obj(tmp); + goto error; + } + x = pdf_number_value(tmp); + switch (i) { + case 0: mllx = x; break; + case 1: mlly = x; break; + case 2: murx = x; break; + case 3: mury = x; break; + } + pdf_release_obj(tmp); + } + if (bbox->llx < mllx) bbox->llx = mllx; + if (bbox->lly < mlly) bbox->lly = mlly; + if (bbox->urx > murx) bbox->urx = murx; + if (bbox->ury > mury) bbox->ury = mury; + } } pdf_release_obj(box); diff --git a/Build/source/texk/dvipdfm-x/spc_pdfm.c b/Build/source/texk/dvipdfm-x/spc_pdfm.c index a642bf49ca1..cc9ee9a008b 100644 --- a/Build/source/texk/dvipdfm-x/spc_pdfm.c +++ b/Build/source/texk/dvipdfm-x/spc_pdfm.c @@ -997,7 +997,7 @@ spc_handler_pdfm_image (struct spc_env *spe, struct spc_arg *args) /* Initialize the PageBox as the default value */ - PageBox = 1; + PageBox = 0; skip_white(&args->curptr, args->endptr); if (args->curptr[0] == '@') { diff --git a/Build/source/texk/dvipdfm-x/spc_util.c b/Build/source/texk/dvipdfm-x/spc_util.c index 56325e17cc9..18efb3cb253 100644 --- a/Build/source/texk/dvipdfm-x/spc_util.c +++ b/Build/source/texk/dvipdfm-x/spc_util.c @@ -670,7 +670,7 @@ spc_read_dimtrns_pdfm (struct spc_env *spe, transform_info *p, struct spc_arg *a else if (strcasecmp(q, "trimbox") == 0) PageBox = 4; else if (strcasecmp(q, "bleedbox") == 0) PageBox = 5; } else { - PageBox = 1; + PageBox = 0; } } break; diff --git a/Build/source/texk/dvipdfm-x/xbb.c b/Build/source/texk/dvipdfm-x/xbb.c index 1e9ed1c663a..ca2aa4e91d8 100644 --- a/Build/source/texk/dvipdfm-x/xbb.c +++ b/Build/source/texk/dvipdfm-x/xbb.c @@ -43,8 +43,9 @@ #define XBB_PROGRAM "extractbb" -int PageBox = 1; +int PageBox = 0; /* + PageBox=0 :default PageBox=1 :cropbox PageBox=2 :mediabox PageBox=3 :artbox |