texlive[44963] Build/source/texk/dvipdfm-x: dvipdfm-x: Support

commits+kakuto at tug.org commits+kakuto at tug.org
Sun Aug 6 09:02:47 CEST 2017


Revision: 44963
          http://tug.org/svn/texlive?view=revision&revision=44963
Author:   kakuto
Date:     2017-08-06 09:02:46 +0200 (Sun, 06 Aug 2017)
Log Message:
-----------
dvipdfm-x: Support /Rotate page attribute in PDF inclusion (by S. Hirata).

Modified Paths:
--------------
    trunk/Build/source/texk/dvipdfm-x/ChangeLog
    trunk/Build/source/texk/dvipdfm-x/configure
    trunk/Build/source/texk/dvipdfm-x/configure.ac
    trunk/Build/source/texk/dvipdfm-x/dpxutil.c
    trunk/Build/source/texk/dvipdfm-x/dpxutil.h
    trunk/Build/source/texk/dvipdfm-x/epdf.c
    trunk/Build/source/texk/dvipdfm-x/pdfdoc.c
    trunk/Build/source/texk/dvipdfm-x/pdfdoc.h
    trunk/Build/source/texk/dvipdfm-x/pdfximage.c
    trunk/Build/source/texk/dvipdfm-x/xbb.c

Modified: trunk/Build/source/texk/dvipdfm-x/ChangeLog
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/ChangeLog	2017-08-06 00:21:23 UTC (rev 44962)
+++ trunk/Build/source/texk/dvipdfm-x/ChangeLog	2017-08-06 07:02:46 UTC (rev 44963)
@@ -1,3 +1,9 @@
+2017-08-06  Shunsaku Hirata  <shunsaku.hirata74 at gmail.com>
+
+	* dpxutil.[ch], epdf.c, pdfdoc.[ch], pdfximage.c, xbb.c:
+	Support for /Rotate page attribute in PDF inclusion.
+	configure.ac: Version 20170806.
+
 2017-06-27  Akira Kakuto  <kakuto at fuk.kindai.ac.jp>
 
 	* pdfdoc.c: Simplify the change in pdf_doc_get_page().

Modified: trunk/Build/source/texk/dvipdfm-x/configure
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/configure	2017-08-06 00:21:23 UTC (rev 44962)
+++ trunk/Build/source/texk/dvipdfm-x/configure	2017-08-06 07:02:46 UTC (rev 44963)
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for dvipdfm-x (TeX Live) 20170627.
+# Generated by GNU Autoconf 2.69 for dvipdfm-x (TeX Live) 20170806.
 #
 # Report bugs to <tex-k at tug.org>.
 #
@@ -590,8 +590,8 @@
 # Identity of this package.
 PACKAGE_NAME='dvipdfm-x (TeX Live)'
 PACKAGE_TARNAME='dvipdfm-x--tex-live-'
-PACKAGE_VERSION='20170627'
-PACKAGE_STRING='dvipdfm-x (TeX Live) 20170627'
+PACKAGE_VERSION='20170806'
+PACKAGE_STRING='dvipdfm-x (TeX Live) 20170806'
 PACKAGE_BUGREPORT='tex-k at tug.org'
 PACKAGE_URL=''
 
@@ -1350,7 +1350,7 @@
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures dvipdfm-x (TeX Live) 20170627 to adapt to many kinds of systems.
+\`configure' configures dvipdfm-x (TeX Live) 20170806 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1421,7 +1421,7 @@
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of dvipdfm-x (TeX Live) 20170627:";;
+     short | recursive ) echo "Configuration of dvipdfm-x (TeX Live) 20170806:";;
    esac
   cat <<\_ACEOF
 
@@ -1551,7 +1551,7 @@
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-dvipdfm-x (TeX Live) configure 20170627
+dvipdfm-x (TeX Live) configure 20170806
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2390,7 +2390,7 @@
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by dvipdfm-x (TeX Live) $as_me 20170627, which was
+It was created by dvipdfm-x (TeX Live) $as_me 20170806, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -8075,7 +8075,7 @@
 
 # Define the identity of the package.
  PACKAGE='dvipdfm-x--tex-live-'
- VERSION='20170627'
+ VERSION='20170806'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -14744,7 +14744,7 @@
 Report bugs to <bug-libtool at gnu.org>."
 
 lt_cl_version="\
-dvipdfm-x (TeX Live) config.lt 20170627
+dvipdfm-x (TeX Live) config.lt 20170806
 configured by $0, generated by GNU Autoconf 2.69.
 
 Copyright (C) 2011 Free Software Foundation, Inc.
@@ -16624,7 +16624,7 @@
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by dvipdfm-x (TeX Live) $as_me 20170627, which was
+This file was extended by dvipdfm-x (TeX Live) $as_me 20170806, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -16694,7 +16694,7 @@
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-dvipdfm-x (TeX Live) config.status 20170627
+dvipdfm-x (TeX Live) config.status 20170806
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 

Modified: trunk/Build/source/texk/dvipdfm-x/configure.ac
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/configure.ac	2017-08-06 00:21:23 UTC (rev 44962)
+++ trunk/Build/source/texk/dvipdfm-x/configure.ac	2017-08-06 07:02:46 UTC (rev 44963)
@@ -7,7 +7,7 @@
 dnl   gives unlimited permission to copy and/or distribute it,
 dnl   with or without modifications, as long as this notice is preserved.
 dnl
-AC_INIT([dvipdfm-x (TeX Live)], [20170627], [tex-k at tug.org])
+AC_INIT([dvipdfm-x (TeX Live)], [20170806], [tex-k at tug.org])
 AC_PREREQ([2.65])
 AC_CONFIG_SRCDIR([agl.c])
 AC_CONFIG_AUX_DIR([../../build-aux])

Modified: trunk/Build/source/texk/dvipdfm-x/dpxutil.c
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/dpxutil.c	2017-08-06 00:21:23 UTC (rev 44962)
+++ trunk/Build/source/texk/dvipdfm-x/dpxutil.c	2017-08-06 07:02:46 UTC (rev 44963)
@@ -1,6 +1,6 @@
 /* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
 
-    Copyright (C) 2002-2016 by Jin-Hwan Cho and Shunsaku Hirata,
+    Copyright (C) 2002-2017 by Jin-Hwan Cho and Shunsaku Hirata,
     the dvipdfmx project team.
 
     Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks at kettering.edu>
@@ -49,6 +49,26 @@
     return -1;
 }
 
+double
+min4 (double x1, double x2, double x3, double x4)
+{
+  double v = x1;
+  if (x2 < v) v = x2;
+  if (x3 < v) v = x3;
+  if (x4 < v) v = x4;
+  return v;
+}
+
+double
+max4 (double x1, double x2, double x3, double x4)
+{
+  double v = x1;
+  if (x2 > v) v = x2;
+  if (x3 > v) v = x3;
+  if (x4 > v) v = x4;
+  return v;
+}
+
 void
 skip_white_spaces (unsigned char **s, unsigned char *endptr)
 {

Modified: trunk/Build/source/texk/dvipdfm-x/dpxutil.h
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/dpxutil.h	2017-08-06 00:21:23 UTC (rev 44962)
+++ trunk/Build/source/texk/dvipdfm-x/dpxutil.h	2017-08-06 07:02:46 UTC (rev 44963)
@@ -1,6 +1,6 @@
 /* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
 
-    Copyright (C) 2002-2016 by Jin-Hwan Cho and Shunsaku Hirata,
+    Copyright (C) 2002-2017 by Jin-Hwan Cho and Shunsaku Hirata,
     the dvipdfmx project team.
 
     Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks at kettering.edu>
@@ -30,6 +30,9 @@
 #undef  ABS
 #define ABS(a)    (((a) < 0) ? -(a) : (a))
 
+extern double min4(double v1, double v2, double v3, double v4);
+extern double max4(double v1, double v2, double v3, double v4);
+
 #ifndef is_space
 #define is_space(c) ((c) == ' '  || (c) == '\t' || (c) == '\f' || \
 		     (c) == '\r' || (c) == '\n' || (c) == '\0')

Modified: trunk/Build/source/texk/dvipdfm-x/epdf.c
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/epdf.c	2017-08-06 00:21:23 UTC (rev 44962)
+++ trunk/Build/source/texk/dvipdfm-x/epdf.c	2017-08-06 07:02:46 UTC (rev 44963)
@@ -1,6 +1,6 @@
 /* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
 
-    Copyright (C) 2007-2016 by Jin-Hwan Cho and Shunsaku Hirata,
+    Copyright (C) 2007-2017 by Jin-Hwan Cho and Shunsaku Hirata,
     the dvipdfmx project team.
     
     Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks at kettering.edu>
@@ -51,13 +51,7 @@
 #include "epdf.h"
 
 static int  rect_equal       (pdf_obj *rect1, pdf_obj *rect2);
-#if 0
-#if HAVE_ZLIB
-#include <zlib.h>
-static int  add_stream_flate (pdf_obj *dst, const void *data, int len);
-#endif
-static int  concat_stream    (pdf_obj *dst, pdf_obj *src);
-#endif
+
 /*
  * From PDFReference15_v6.pdf (p.119 and p.834)
  *
@@ -314,9 +308,6 @@
   }
 
   if (rotate) {
-    if (pdf_number_value(rotate) != 0.0)
-      WARN("<< /Rotate %d >> found. (Not supported yet)",
-            (int)pdf_number_value(rotate));
     pdf_release_obj(rotate);
     rotate = NULL;
   }
@@ -422,7 +413,7 @@
     options.page_no = 1;
   page = pdf_doc_get_page(pf,
                           options.page_no, options.bbox_type,
-                          &info.bbox, &resources);
+                          &info.bbox, &info.matrix, &resources);
 
   if(!page)
     goto error_silent;
@@ -512,12 +503,12 @@
     pdf_add_dict(contents_dict, pdf_new_name("BBox"), bbox);
 
     matrix = pdf_new_array();
-    pdf_add_array(matrix, pdf_new_number(1.0));
-    pdf_add_array(matrix, pdf_new_number(0.0));
-    pdf_add_array(matrix, pdf_new_number(0.0));
-    pdf_add_array(matrix, pdf_new_number(1.0));
-    pdf_add_array(matrix, pdf_new_number(0.0));
-    pdf_add_array(matrix, pdf_new_number(0.0));
+    pdf_add_array(matrix, pdf_new_number(info.matrix.a));
+    pdf_add_array(matrix, pdf_new_number(info.matrix.b));
+    pdf_add_array(matrix, pdf_new_number(info.matrix.c));
+    pdf_add_array(matrix, pdf_new_number(info.matrix.d));
+    pdf_add_array(matrix, pdf_new_number(info.matrix.e));
+    pdf_add_array(matrix, pdf_new_number(info.matrix.f));
 
     pdf_add_dict(contents_dict, pdf_new_name("Matrix"), matrix);
 

Modified: trunk/Build/source/texk/dvipdfm-x/pdfdoc.c
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/pdfdoc.c	2017-08-06 00:21:23 UTC (rev 44962)
+++ trunk/Build/source/texk/dvipdfm-x/pdfdoc.c	2017-08-06 07:02:46 UTC (rev 44963)
@@ -979,7 +979,8 @@
 pdf_obj *
 pdf_doc_get_page (pdf_file *pf,
                   int page_no, int options,             /* load options */
-                  pdf_rect *bbox, pdf_obj **resources_p /* returned values */
+                  pdf_rect *bbox, pdf_tmatrix *matrix,  /* returned value */
+                  pdf_obj **resources_p /* returned values */
                   ) {
   pdf_obj *page_tree = NULL;
   pdf_obj *resources = NULL, *box = NULL, *rotate = NULL, *medbox = NULL;
@@ -1167,15 +1168,6 @@
       !PDF_OBJ_DICTTYPE(resources))
     goto error;
 
-  if (PDF_OBJ_NUMBERTYPE(rotate)) {
-    if (pdf_number_value(rotate))
-      WARN("<< /Rotate %d >> found. (Not supported yet)", 
-           (int) pdf_number_value(rotate));
-    pdf_release_obj(rotate);
-    rotate = NULL;
-  } else if (rotate)
-    goto error;
-
   {
     int i;
 
@@ -1216,9 +1208,51 @@
       }
     }
   }
-
   pdf_release_obj(box);
 
+  matrix->a = matrix->d = 1.0;
+  matrix->b = matrix->c = 0.0;
+  matrix->e = matrix->f = 0.0;
+  if (PDF_OBJ_NUMBERTYPE(rotate)) {
+    double deg = pdf_number_value(rotate);
+    if (deg - (int)deg != 0.0)
+    WARN("Invalid value specified for /Rotate: %f", deg);
+    else if (deg != 0.0) {
+      int rot = (int) deg;
+      if (rot % 90 != 0.0) {
+        WARN("Invalid value specified for /Rotate: %f", deg);
+      } else {
+        rot = rot % 360;
+        if (rot < 0) rot += 360;
+        switch (rot) {
+        case 90:
+          matrix->a = matrix->d = 0;
+          matrix->b = -1;
+          matrix->c = 1;
+          matrix->e = bbox->llx - bbox->lly;
+          matrix->f = bbox->lly + bbox->urx;
+          break;
+        case 180:
+          matrix->a = matrix->d = -1;
+          matrix->b = matrix->c = 0;
+          matrix->e = bbox->llx + bbox->urx;
+          matrix->f = bbox->lly + bbox->ury;
+          break;
+        case 270:
+          matrix->a = matrix->d = 0;
+          matrix->b = 1;
+          matrix->c = -1;
+          matrix->e = bbox->llx + bbox->ury;
+          matrix->f = bbox->lly - bbox->llx;
+          break;
+        }
+      }
+    }
+    pdf_release_obj(rotate);
+    rotate = NULL;
+  } else if (rotate)
+    goto error;
+
   if (resources_p)
     *resources_p = resources;
   else if (resources)

Modified: trunk/Build/source/texk/dvipdfm-x/pdfdoc.h
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/pdfdoc.h	2017-08-06 00:21:23 UTC (rev 44962)
+++ trunk/Build/source/texk/dvipdfm-x/pdfdoc.h	2017-08-06 07:02:46 UTC (rev 44963)
@@ -1,6 +1,6 @@
 /* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
 
-    Copyright (C) 2007-2016 by Jin-Hwan Cho and Shunsaku Hirata,
+    Copyright (C) 2007-2017 by Jin-Hwan Cho and Shunsaku Hirata,
     the dvipdfmx project team.
     
     Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks at kettering.edu>
@@ -58,7 +58,7 @@
 
 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);
+				  pdf_rect *bbox, pdf_tmatrix *matrix, pdf_obj **resources_p);
 
 extern int      pdf_doc_current_page_number    (void);
 extern pdf_obj *pdf_doc_current_page_resources (void);

Modified: trunk/Build/source/texk/dvipdfm-x/pdfximage.c
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/pdfximage.c	2017-08-06 00:21:23 UTC (rev 44962)
+++ trunk/Build/source/texk/dvipdfm-x/pdfximage.c	2017-08-06 07:02:46 UTC (rev 44963)
@@ -1,6 +1,6 @@
 /* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
 
-    Copyright (C) 2007-2016 by Jin-Hwan Cho and Shunsaku Hirata,
+    Copyright (C) 2007-2017 by Jin-Hwan Cho and Shunsaku Hirata,
     the dvipdfmx project team.
     
     Copyright (C) 1998, 1999 by Mark A. Wicks <mwicks at kettering.edu>
@@ -29,6 +29,7 @@
 #include "mem.h"
 
 #include "dpxfile.h"
+#include "dpxutil.h"
 
 #include "pdfobj.h"
 
@@ -552,14 +553,27 @@
 pdf_ximage_set_form (pdf_ximage *I, void *form_info, pdf_obj *resource)
 {
   xform_info *info = form_info;
+  pdf_coord   p1, p2, p3, p4;
 
   I->subtype   = PDF_XOBJECT_TYPE_FORM;
 
-  I->attr.bbox.llx = info->bbox.llx;
-  I->attr.bbox.lly = info->bbox.lly;
-  I->attr.bbox.urx = info->bbox.urx;
-  I->attr.bbox.ury = info->bbox.ury;
+  /* Image's attribute "bbox" here is affected by /Rotate entry of included
+   * PDF page.
+   */
+  p1.x = info->bbox.llx; p1.y = info->bbox.lly;
+  pdf_dev_transform(&p1, &info->matrix);
+  p2.x = info->bbox.urx; p1.y = info->bbox.lly;
+  pdf_dev_transform(&p2, &info->matrix);
+  p3.x = info->bbox.urx; p3.y = info->bbox.ury;
+  pdf_dev_transform(&p3, &info->matrix);
+  p4.x = info->bbox.llx; p4.y = info->bbox.ury;
+  pdf_dev_transform(&p4, &info->matrix);
 
+  I->attr.bbox.llx = min4(p1.x, p2.x, p3.x, p4.x);
+  I->attr.bbox.lly = min4(p1.y, p2.y, p3.y, p4.y);
+  I->attr.bbox.urx = max4(p1.x, p2.x, p3.x, p4.x);
+  I->attr.bbox.ury = max4(p1.y, p2.y, p3.y, p4.y);
+
   I->reference = pdf_ref_obj(resource);
 
   pdf_release_obj(resource); /* Caller don't know we are using reference. */

Modified: trunk/Build/source/texk/dvipdfm-x/xbb.c
===================================================================
--- trunk/Build/source/texk/dvipdfm-x/xbb.c	2017-08-06 00:21:23 UTC (rev 44962)
+++ trunk/Build/source/texk/dvipdfm-x/xbb.c	2017-08-06 07:02:46 UTC (rev 44963)
@@ -24,6 +24,8 @@
 #include <time.h>
 #include <string.h>
 
+#include "dpxutil.h"
+
 #include "numbers.h"
 #include "system.h"
 #include "mem.h"
@@ -32,6 +34,7 @@
 #include "pdfobj.h"
 #include "pdfdoc.h"
 #include "pdfparse.h"
+#include "pdfdraw.h"
 
 #include "bmpimage.h"
 #include "jpegimage.h"
@@ -255,6 +258,8 @@
   int page_no = Include_Page;
   int count;
   pdf_rect bbox;
+  pdf_tmatrix matrix;
+  pdf_coord   p1, p2, p3, p4;
 
   pf = pdf_open(filename, fp);
   if (!pf) {
@@ -262,7 +267,7 @@
     return;
   }
   count = pdf_doc_get_page_count(pf);
-  page  = pdf_doc_get_page(pf, page_no, PageBox, &bbox, NULL);
+  page  = pdf_doc_get_page(pf, page_no, PageBox, &bbox, &matrix, NULL);
 
   pdf_close(pf);
 
@@ -270,6 +275,24 @@
     return;
 
   pdf_release_obj(page);
+
+  /* Image's attribute "bbox" here is affected by /Rotate entry of included
+   * PDF page.
+   */
+  p1.x = bbox.llx; p1.y = bbox.lly;
+  pdf_dev_transform(&p1, &matrix);
+  p2.x = bbox.urx; p2.y = bbox.lly;
+  pdf_dev_transform(&p2, &matrix);
+  p3.x = bbox.urx; p3.y = bbox.ury;
+  pdf_dev_transform(&p3, &matrix);
+  p4.x = bbox.llx; p4.y = bbox.ury;
+  pdf_dev_transform(&p4, &matrix);
+
+  bbox.llx = min4(p1.x, p2.x, p3.x, p4.x);
+  bbox.lly = min4(p1.y, p2.y, p3.y, p4.y);
+  bbox.urx = max4(p1.x, p2.x, p3.x, p4.x);
+  bbox.ury = max4(p1.y, p2.y, p3.y, p4.y);
+
   write_xbb(filename, bbox.llx, bbox.lly, bbox.urx, bbox.ury,
             pdf_file_get_version(pf), count);
 }



More information about the tex-live-commits mailing list