summaryrefslogtreecommitdiff
path: root/Build/source/texk/dvipdfmx/src
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2009-05-19 00:42:35 +0000
committerKarl Berry <karl@freefriends.org>2009-05-19 00:42:35 +0000
commit136f54b7dc95964f3db31da84ba3f1961967babe (patch)
tree2050345bf4d6396bce5b756842aea46626c7d53b /Build/source/texk/dvipdfmx/src
parent53241b23b422addce6dd1145dfa1d334a940c45d (diff)
update to http://project.ktug.or.kr/dvipdfmx/snapshot/latest/dvipdfmx-20090506.tar.gz
git-svn-id: svn://tug.org/texlive/trunk@13221 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/dvipdfmx/src')
-rw-r--r--Build/source/texk/dvipdfmx/src/Makefile.in132
-rw-r--r--Build/source/texk/dvipdfmx/src/cff.c3
-rw-r--r--Build/source/texk/dvipdfmx/src/cid.c20
-rw-r--r--Build/source/texk/dvipdfmx/src/cmap_read.c4
-rw-r--r--Build/source/texk/dvipdfmx/src/dpxfile.c13
-rw-r--r--Build/source/texk/dvipdfmx/src/dpxfile.h6
-rw-r--r--Build/source/texk/dvipdfmx/src/dpxutil.c10
-rw-r--r--Build/source/texk/dvipdfmx/src/dpxutil.h3
-rw-r--r--Build/source/texk/dvipdfmx/src/dvi.c7
-rw-r--r--Build/source/texk/dvipdfmx/src/dvipdfmx.c50
-rw-r--r--Build/source/texk/dvipdfmx/src/epdf.c27
-rw-r--r--Build/source/texk/dvipdfmx/src/epdf.h5
-rw-r--r--Build/source/texk/dvipdfmx/src/jpegimage.c68
-rw-r--r--Build/source/texk/dvipdfmx/src/jpegimage.h4
-rw-r--r--Build/source/texk/dvipdfmx/src/mem.c3
-rw-r--r--Build/source/texk/dvipdfmx/src/pdfdev.c30
-rw-r--r--Build/source/texk/dvipdfmx/src/pdfdoc.c227
-rw-r--r--Build/source/texk/dvipdfmx/src/pdfdoc.h11
-rw-r--r--Build/source/texk/dvipdfmx/src/pdfdraw.c47
-rw-r--r--Build/source/texk/dvipdfmx/src/pdfencoding.c3
-rw-r--r--Build/source/texk/dvipdfmx/src/pdfencrypt.c13
-rw-r--r--Build/source/texk/dvipdfmx/src/pdflimits.h11
-rw-r--r--Build/source/texk/dvipdfmx/src/pdfnames.c172
-rw-r--r--Build/source/texk/dvipdfmx/src/pdfnames.h4
-rw-r--r--Build/source/texk/dvipdfmx/src/pdfobj.c160
-rw-r--r--Build/source/texk/dvipdfmx/src/pdfobj.h13
-rw-r--r--Build/source/texk/dvipdfmx/src/pdfparse.c84
-rw-r--r--Build/source/texk/dvipdfmx/src/pdfximage.c23
-rw-r--r--Build/source/texk/dvipdfmx/src/pdfximage.h3
-rw-r--r--Build/source/texk/dvipdfmx/src/pngimage.c50
-rw-r--r--Build/source/texk/dvipdfmx/src/pngimage.h4
-rw-r--r--Build/source/texk/dvipdfmx/src/spc_color.c8
-rw-r--r--Build/source/texk/dvipdfmx/src/spc_html.c14
-rw-r--r--Build/source/texk/dvipdfmx/src/spc_pdfm.c32
-rw-r--r--Build/source/texk/dvipdfmx/src/spc_tpic.c4
-rw-r--r--Build/source/texk/dvipdfmx/src/spc_util.c50
-rw-r--r--Build/source/texk/dvipdfmx/src/spc_util.h5
-rw-r--r--Build/source/texk/dvipdfmx/src/specials.c25
-rw-r--r--Build/source/texk/dvipdfmx/src/t1_load.c33
-rw-r--r--Build/source/texk/dvipdfmx/src/tt_table.c8
-rw-r--r--Build/source/texk/dvipdfmx/src/xbb.c301
41 files changed, 885 insertions, 805 deletions
diff --git a/Build/source/texk/dvipdfmx/src/Makefile.in b/Build/source/texk/dvipdfmx/src/Makefile.in
index dded26e67c5..b49126ddb0b 100644
--- a/Build/source/texk/dvipdfmx/src/Makefile.in
+++ b/Build/source/texk/dvipdfmx/src/Makefile.in
@@ -1,8 +1,9 @@
-# Makefile.in generated by automake 1.10.2 from Makefile.am.
+# Makefile.in generated by automake 1.11 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
+# Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
@@ -16,8 +17,9 @@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
-pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
@@ -50,11 +52,11 @@ am__aclocal_m4_deps = $(top_srcdir)/../../m4/cho-kpse.m4 \
$(top_srcdir)/../../m4/maw-time.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
-mkinstalldirs = $(install_sh) -d
+mkinstalldirs = $(SHELL) $(top_srcdir)/../../build-aux/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
am__installdirs = "$(DESTDIR)$(bindir)"
-binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
PROGRAMS = $(bin_PROGRAMS)
am_dvipdfmx_OBJECTS = agl.$(OBJEXT) bmpimage.$(OBJEXT) cff.$(OBJEXT) \
cff_dict.$(OBJEXT) cid.$(OBJEXT) cidtype0.$(OBJEXT) \
@@ -85,6 +87,7 @@ am__DEPENDENCIES_1 =
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
depcomp = $(SHELL) $(top_srcdir)/../../build-aux/depcomp
am__depfiles_maybe = depfiles
+am__mv = mv -f
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
@@ -262,9 +265,9 @@ $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__confi
exit 1;; \
esac; \
done; \
- echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/Makefile'; \
- cd $(top_srcdir) && \
- $(AUTOMAKE) --foreign src/Makefile
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --foreign src/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
@@ -282,34 +285,50 @@ $(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
install-binPROGRAMS: $(bin_PROGRAMS)
@$(NORMAL_INSTALL)
test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
- @list='$(bin_PROGRAMS)'; for p in $$list; do \
- p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
- if test -f $$p \
- || test -f $$p1 \
- ; then \
- f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
- echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
- $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
- else :; fi; \
- done
+ @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+ for p in $$list; do echo "$$p $$p"; done | \
+ sed 's/$(EXEEXT)$$//' | \
+ while read p p1; do if test -f $$p || test -f $$p1; \
+ then echo "$$p"; echo "$$p"; else :; fi; \
+ done | \
+ sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \
+ -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
+ sed 'N;N;N;s,\n, ,g' | \
+ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
+ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
+ if ($$2 == $$4) files[d] = files[d] " " $$1; \
+ else { print "f", $$3 "/" $$4, $$1; } } \
+ END { for (d in files) print "f", d, files[d] }' | \
+ while read type dir files; do \
+ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
+ test -z "$$files" || { \
+ echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \
+ $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
+ } \
+ ; done
uninstall-binPROGRAMS:
@$(NORMAL_UNINSTALL)
- @list='$(bin_PROGRAMS)'; for p in $$list; do \
- f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
- echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
- rm -f "$(DESTDIR)$(bindir)/$$f"; \
- done
+ @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+ files=`for p in $$list; do echo "$$p"; done | \
+ sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
+ -e 's/$$/$(EXEEXT)/' `; \
+ test -n "$$list" || exit 0; \
+ echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
+ cd "$(DESTDIR)$(bindir)" && rm -f $$files
clean-binPROGRAMS:
- @list='$(bin_PROGRAMS)'; for p in $$list; do \
- f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
- echo " rm -f $$p $$f"; \
- rm -f $$p $$f ; \
- done
+ @list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \
+ echo " rm -f" $$list; \
+ rm -f $$list || exit $$?; \
+ test -n "$(EXEEXT)" || exit 0; \
+ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f" $$list; \
+ rm -f $$list
dvipdfmx$(EXEEXT): $(dvipdfmx_OBJECTS) $(dvipdfmx_DEPENDENCIES)
@rm -f dvipdfmx$(EXEEXT)
$(LINK) $(dvipdfmx_OBJECTS) $(dvipdfmx_LDADD) $(LIBS)
@@ -392,21 +411,21 @@ distclean-compile:
.c.o:
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
-@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(COMPILE) -c $<
.c.obj:
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
-@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
.c.lo:
@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
-@am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
@@ -429,7 +448,7 @@ tags: TAGS
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
- tags=; \
+ set x; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
@@ -437,29 +456,34 @@ TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
- if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
- $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
- $$tags $$unique; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
fi
ctags: CTAGS
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
- tags=; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in files) print i; }; }'`; \
- test -z "$(CTAGS_ARGS)$$tags$$unique" \
+ test -z "$(CTAGS_ARGS)$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
- $$tags $$unique
+ $$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
- && cd $(top_srcdir) \
- && gtags -i $(GTAGS_ARGS) $$here
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
@@ -480,13 +504,17 @@ distdir: $(DISTFILES)
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
- cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
- cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
else \
- test -f $(distdir)/$$file \
- || cp -p $$d/$$file $(distdir)/$$file \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
|| exit 1; \
fi; \
done
@@ -517,6 +545,7 @@ clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@@ -537,6 +566,8 @@ dvi-am:
html: html-am
+html-am:
+
info: info-am
info-am:
@@ -545,20 +576,29 @@ install-data-am:
install-dvi: install-dvi-am
+install-dvi-am:
+
install-exec-am: install-binPROGRAMS
@$(NORMAL_INSTALL)
$(MAKE) $(AM_MAKEFLAGS) install-exec-hook
-
install-html: install-html-am
+install-html-am:
+
install-info: install-info-am
+install-info-am:
+
install-man:
install-pdf: install-pdf-am
+install-pdf-am:
+
install-ps: install-ps-am
+install-ps-am:
+
installcheck-am:
maintainer-clean: maintainer-clean-am
@@ -582,7 +622,6 @@ ps-am:
uninstall-am: uninstall-binPROGRAMS
@$(NORMAL_INSTALL)
$(MAKE) $(AM_MAKEFLAGS) uninstall-hook
-
.MAKE: install-am install-exec-am install-strip uninstall-am
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
@@ -613,6 +652,7 @@ install-exec-hook:
uninstall-hook:
rm -f $(DESTDIR)$(bindir)/ebb$(EXEEXT)
rm -f $(DESTDIR)$(bindir)/extractbb$(EXEEXT)
+
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
diff --git a/Build/source/texk/dvipdfmx/src/cff.c b/Build/source/texk/dvipdfmx/src/cff.c
index 6dbcaf6094f..000334b64e4 100644
--- a/Build/source/texk/dvipdfmx/src/cff.c
+++ b/Build/source/texk/dvipdfmx/src/cff.c
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/cff.c,v 1.16 2008/10/13 19:42:48 matthias Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/cff.c,v 1.17 2009/03/24 07:55:52 chofchof Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -24,6 +24,7 @@
#include <string.h>
#include "system.h"
+#include "system.h"
#include "mem.h"
#include "error.h"
#include "mfileio.h"
diff --git a/Build/source/texk/dvipdfmx/src/cid.c b/Build/source/texk/dvipdfmx/src/cid.c
index b7a56494b75..3213e3aa102 100644
--- a/Build/source/texk/dvipdfmx/src/cid.c
+++ b/Build/source/texk/dvipdfmx/src/cid.c
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/cid.c,v 1.32 2008/11/30 21:12:27 matthias Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/cid.c,v 1.33 2009/05/06 01:50:55 matthias Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -59,16 +59,18 @@
static struct {
const char *registry;
const char *ordering;
- /* Heighest Supplement values supported by PDF-1.0, 1.1, ... */
+ /* Heighest Supplement values supported by PDF-1.0, 1.1, ...; see
+ * also http://partners.adobe.com/public/developer/font/index.html#ckf
+ */
int supplement[16];
} CIDFont_stdcc_def[] = {
- {"Adobe", "UCS", {-1, -1, 0, 0, 0, 0, 0}},
- {"Adobe", "GB1", {-1, -1, 0, 2, 4, 4, 4}},
- {"Adobe", "CNS1", {-1, -1, 0, 0, 3, 4, 4}},
- {"Adobe", "Japan1", {-1, -1, 2, 2, 4, 5, 6}},
- {"Adobe", "Korea1", {-1, -1, 1, 1, 2, 2, 2}},
- {"Adobe", "Identity", {-1, -1, 0, 0, 0, 0, 0}},
- {NULL, NULL, {0,0,0,0,0,0,0}}
+ {"Adobe", "UCS", {-1, -1, 0, 0, 0, 0, 0, 0}},
+ {"Adobe", "GB1", {-1, -1, 0, 2, 4, 4, 4, 4}},
+ {"Adobe", "CNS1", {-1, -1, 0, 0, 3, 4, 4, 4}},
+ {"Adobe", "Japan1", {-1, -1, 2, 2, 4, 5, 6, 6}},
+ {"Adobe", "Korea1", {-1, -1, 1, 1, 2, 2, 2, 2}},
+ {"Adobe", "Identity", {-1, -1, 0, 0, 0, 0, 0, 0}},
+ {NULL, NULL, {0,0,0,0,0,0,0,0}}
};
#define UCS_CC 0
#define ACC_START 1
diff --git a/Build/source/texk/dvipdfmx/src/cmap_read.c b/Build/source/texk/dvipdfmx/src/cmap_read.c
index f927b40de77..7830350d926 100644
--- a/Build/source/texk/dvipdfmx/src/cmap_read.c
+++ b/Build/source/texk/dvipdfmx/src/cmap_read.c
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/cmap_read.c,v 1.3 2008/01/11 18:04:15 matthias Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/cmap_read.c,v 1.4 2009/05/06 01:51:01 chofchof Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -510,7 +510,7 @@ CMap_parse_check_sig (FILE *fp)
if (fread(sig, sizeof(char), CMAP_SIG_MAX, fp) != CMAP_SIG_MAX)
result = -1;
else {
- sig[CMAP_SIG_MAX+1] = 0;
+ sig[CMAP_SIG_MAX] = 0;
if (strncmp(sig, "%!PS", 4))
result = -1;
else if (strstr(sig+4, "Resource-CMap"))
diff --git a/Build/source/texk/dvipdfmx/src/dpxfile.c b/Build/source/texk/dvipdfmx/src/dpxfile.c
index 1107e73a943..e95cf9bfb8a 100644
--- a/Build/source/texk/dvipdfmx/src/dpxfile.c
+++ b/Build/source/texk/dvipdfmx/src/dpxfile.c
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/dpxfile.c,v 1.24 2008/05/22 10:08:02 matthias Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/dpxfile.c,v 1.25 2009/03/12 19:29:48 matthias Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -705,7 +705,9 @@ dpx_delete_temp_file (char *tmp)
* Please modify as appropriate (see also pdfximage.c and dvipdfmx.c).
*/
int
-dpx_file_apply_filter (const char *cmdtmpl, const char *input, const char *output)
+dpx_file_apply_filter (const char *cmdtmpl,
+ const char *input, const char *output,
+ unsigned char version)
{
char *cmd = NULL;
char *p, *q;
@@ -746,6 +748,13 @@ if ((l) + (n) >= (m)) { \
} else {
strcpy(cmd + n, input); n += strlen(input);
}
+ case 'v': /* Version number, e.g. 1.4 */ {
+ char buf[6];
+ sprintf(buf, "1.%hhu", version);
+ need(cmd, n, size, strlen(buf));
+ strcpy(cmd + n, buf); n += strlen(buf);
+ break;
+ }
case 0:
break;
case '%':
diff --git a/Build/source/texk/dvipdfmx/src/dpxfile.h b/Build/source/texk/dvipdfmx/src/dpxfile.h
index fd6d8e17a2d..5e61e59cc36 100644
--- a/Build/source/texk/dvipdfmx/src/dpxfile.h
+++ b/Build/source/texk/dvipdfmx/src/dpxfile.h
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/dpxfile.h,v 1.8 2008/05/18 12:05:22 chofchof Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/dpxfile.h,v 1.9 2009/03/12 19:29:48 matthias Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -53,7 +53,9 @@ extern FILE *dpx_open_file (const char *filename, int type);
extern void dpx_file_set_verbose (void);
-extern int dpx_file_apply_filter (const char *cmdtmpl, const char *input, const char *output);
+extern int dpx_file_apply_filter (const char *cmdtmpl,
+ const char *input, const char *output,
+ unsigned char version);
extern char *dpx_create_temp_file (void);
extern void dpx_delete_temp_file (char *tmp); /* tmp freed here */
diff --git a/Build/source/texk/dvipdfmx/src/dpxutil.c b/Build/source/texk/dvipdfmx/src/dpxutil.c
index e153d050476..0de3631f73f 100644
--- a/Build/source/texk/dvipdfmx/src/dpxutil.c
+++ b/Build/source/texk/dvipdfmx/src/dpxutil.c
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/dpxutil.c,v 1.9 2008/11/03 22:49:29 matthias Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/dpxutil.c,v 1.11 2009/04/26 21:23:29 matthias Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -29,6 +29,7 @@
#include <time.h>
#include "system.h"
+#include "system.h"
#include "mem.h"
#include "error.h"
@@ -202,6 +203,13 @@ ht_clear_table (struct ht_table *ht, void (*hval_free_fn) (void *))
ht->count = 0;
}
+long ht_table_size (struct ht_table *ht)
+{
+ ASSERT(ht);
+
+ return ht->count;
+}
+
static unsigned int
get_hash (const void *key, int keylen)
{
diff --git a/Build/source/texk/dvipdfmx/src/dpxutil.h b/Build/source/texk/dvipdfmx/src/dpxutil.h
index 09a755c22b8..5d230c655af 100644
--- a/Build/source/texk/dvipdfmx/src/dpxutil.h
+++ b/Build/source/texk/dvipdfmx/src/dpxutil.h
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/dpxutil.h,v 1.8 2007/11/14 03:36:01 chofchof Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/dpxutil.h,v 1.9 2009/04/26 21:23:29 matthias Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -73,6 +73,7 @@ struct ht_table {
extern void ht_init_table (struct ht_table *ht);
extern void ht_clear_table (struct ht_table *ht, void (*hval_free_fn) (void *));
+extern long ht_table_size (struct ht_table *ht);
extern void *ht_lookup_table (struct ht_table *ht, const void *key, int keylen);
extern void ht_append_table (struct ht_table *ht,
const void *key, int keylen, void *value) ;
diff --git a/Build/source/texk/dvipdfmx/src/dvi.c b/Build/source/texk/dvipdfmx/src/dvi.c
index 571489c15e5..2c98895796b 100644
--- a/Build/source/texk/dvipdfmx/src/dvi.c
+++ b/Build/source/texk/dvipdfmx/src/dvi.c
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/dvi.c,v 1.39 2008/11/30 21:12:27 matthias Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/dvi.c,v 1.40 2009/04/04 02:10:44 matthias Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -1660,6 +1660,7 @@ read_length (double *vp, double mag, char **pp, char *endptr)
q = parse_c_ident(&p, endptr);
if (q) {
+ char *qq = q;
if (strlen(q) > strlen("true") &&
!memcmp(q, "true", strlen("true"))) {
u /= mag != 0.0 ? mag : 1.0; /* inverse magnify */
@@ -1673,11 +1674,11 @@ read_length (double *vp, double mag, char **pp, char *endptr)
case K_UNIT__MM: u *= 72.0 / 25.4 ; break;
case K_UNIT__BP: u *= 1.0 ; break;
default:
- WARN("Unknown unit of measure: %s", q);
+ WARN("Unknown unit of measure: %s", qq);
error = -1;
break;
}
- RELEASE(q);
+ RELEASE(qq);
}
*vp = v * u; *pp = p;
diff --git a/Build/source/texk/dvipdfmx/src/dvipdfmx.c b/Build/source/texk/dvipdfmx/src/dvipdfmx.c
index 27b0792afa2..1e71b205b66 100644
--- a/Build/source/texk/dvipdfmx/src/dvipdfmx.c
+++ b/Build/source/texk/dvipdfmx/src/dvipdfmx.c
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/dvipdfmx.c,v 1.68 2009/01/15 21:46:08 chofchof Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/dvipdfmx.c,v 1.74 2009/05/06 06:07:09 chofchof Exp $
This is DVIPDFMx, an eXtended version of DVIPDFM by Mark A. Wicks.
@@ -30,6 +30,7 @@
#include <string.h>
#include <limits.h>
#include <ctype.h>
+#include <libgen.h>
#include "system.h"
#include "mem.h"
@@ -40,6 +41,7 @@
#include "dvi.h"
+#include "pdflimits.h"
#include "pdfdoc.h"
#include "pdfdev.h"
#include "pdfparse.h"
@@ -125,6 +127,9 @@ set_default_pdf_filename(void)
static void
usage (void)
{
+ if (really_quiet)
+ return;
+
fprintf (stdout, "\nThis is %s-%s by the DVIPDFMx project team,\n", PACKAGE, VERSION);
fprintf (stdout, "an extended version of dvipdfm-0.13.2c developed by Mark A. Wicks.\n");
fprintf (stdout, "\nCopyright (C) 2002-2009 by the DVIPDFMx project team\n");
@@ -157,7 +162,7 @@ usage (void)
fprintf (stdout, "\t\t\t instead of opaque gray color. (requires PDF 1.4)\n");
fprintf (stdout, "\t\t 0x0004 Treat all CIDFont as fixed-pitch font.\n");
fprintf (stdout, "\t\t 0x0008 Do not replace duplicate fontmap entries.\n");
- fprintf (stdout, "\t\t 0x0010 Do not remove unused PDF destinations.\n");
+ fprintf (stdout, "\t\t 0x0010 Do not optimize PDF destinations.\n");
fprintf (stdout, "\t\tPositive values are always ORed with previously given flags.\n");
fprintf (stdout, "\t\tAnd negative values replace old values.\n");
fprintf (stdout, "-D template\tPS->PDF conversion command line template [none]\n");
@@ -311,7 +316,8 @@ select_pages (const char *pagespec)
#define POP_ARG() {argv += 1; argc -= 1;}
/* It doesn't work as expected (due to dvi filename). */
#define CHECK_ARG(n,m) if (argc < (n) + 1) {\
- fprintf (stderr, "\nMissing %s after \"-%c\".\n", (m), *flag);\
+ if (!really_quiet)\
+ fprintf (stderr, "\nMissing %s after \"-%c\".\n", (m), *flag);\
usage();\
}
@@ -443,11 +449,11 @@ do_args (int argc, char *argv[])
ver_minor = atoi(argv[1]);
POP_ARG();
}
- if (ver_minor < 3 || ver_minor > 6) {
- WARN("PDF version 1.%d not supported. (1.4 used instead)", ver_minor);
- ver_minor = 4;
- }
- pdf_set_version((unsigned) ver_minor);
+ if (ver_minor < PDF_VERSION_MIN || ver_minor > PDF_VERSION_MAX) {
+ WARN("PDF version 1.%d not supported. Using PDF 1.%d instead.",
+ ver_minor, pdf_get_version());
+ } else
+ pdf_set_version((unsigned) ver_minor);
}
break;
case 'z':
@@ -517,7 +523,8 @@ do_args (int argc, char *argv[])
POP_ARG();
break;
default:
- fprintf (stderr, "Unknown option in \"%s\"", flag);
+ if (!really_quiet)
+ fprintf (stderr, "Unknown option in \"%s\"", flag);
usage();
break;
}
@@ -526,7 +533,8 @@ do_args (int argc, char *argv[])
}
if (argc > 1) {
- fprintf(stderr, "Multiple dvi filenames?");
+ if (!really_quiet)
+ fprintf(stderr, "Multiple dvi filenames?");
usage();
} else if (argc > 0) {
/*
@@ -619,7 +627,8 @@ error_cleanup (void)
pdf_error_cleanup();
if (pdf_filename) {
remove(pdf_filename);
- fprintf(stderr, "\nOutput file removed.\n");
+ if (!really_quiet)
+ fprintf(stderr, "\nOutput file removed.\n");
}
}
@@ -778,15 +787,19 @@ main (int argc, char *argv[])
{
double dvi2pts;
- if (strcmp(argv[0], "ebb") == 0)
- return extractbb(argc, argv, EBB_OUTPUT);
- else if (strcmp(argv[0], "xbb") == 0 || strcmp(argv[0], "extractbb") == 0)
- return extractbb(argc, argv, XBB_OUTPUT);
+ {
+ char *base = basename(argv[0]);
+ if (strcmp(base, "ebb") == 0)
+ return extractbb(argc, argv, EBB_OUTPUT);
+ else if (strcmp(base, "xbb") == 0 || strcmp(base, "extractbb") == 0)
+ return extractbb(argc, argv, XBB_OUTPUT);
+ }
mem_debug_init();
if (argc < 2) {
- fprintf(stderr, "No dvi filename specified.");
+ if (!really_quiet)
+ fprintf(stderr, "No dvi filename specified.");
usage();
return 1;
}
@@ -833,9 +846,10 @@ main (int argc, char *argv[])
MESG("%s -> %s\n", dvi_filename, pdf_filename);
if (do_encryption) {
+ if (key_bits > 40 && pdf_get_version() <= PDF_VERSION_MIN)
+ ERROR("Chosen key length requires at least PDF 1.4. "
+ "Use \"-V 4\" to change.");
pdf_enc_set_passwd(key_bits, permission, dvi_filename, pdf_filename);
- if (key_bits > 40 && pdf_get_version() < 4)
- pdf_set_version(4);
}
if (mp_mode) {
diff --git a/Build/source/texk/dvipdfmx/src/epdf.c b/Build/source/texk/dvipdfmx/src/epdf.c
index 0da13e58a7b..78e269e04c3 100644
--- a/Build/source/texk/dvipdfmx/src/epdf.c
+++ b/Build/source/texk/dvipdfmx/src/epdf.c
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/epdf.c,v 1.25 2008/10/01 00:48:46 matthias Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/epdf.c,v 1.27 2009/05/04 00:41:42 matthias Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -49,31 +49,32 @@
#include "epdf.h"
int
-pdf_include_page (pdf_ximage *ximage, FILE *image_file)
+pdf_include_page (pdf_ximage *ximage, FILE *image_file, const char *filename)
{
- char *ident = pdf_ximage_get_ident(ximage);
pdf_file *pf;
xform_info info;
- pdf_obj *trailer, *contents = NULL;
+ pdf_obj *contents = NULL, *catalog;
pdf_obj *page = NULL, *resources = NULL, *markinfo = NULL;
long page_no, count;
- pdf_ximage_init_form_info(&info);
-
- pf = pdf_open(ident, image_file);
+ pf = pdf_open(filename, image_file);
if (!pf)
return -1;
- trailer = pdf_file_get_trailer(pf);
+ if (pdf_file_get_version(pf) > pdf_get_version())
+ goto too_recent;
+
+ pdf_ximage_init_form_info(&info);
page_no = pdf_ximage_get_page(ximage);
- page = pdf_doc_get_page(trailer, &page_no, &count,
- &info.bbox, &resources, &markinfo);
+ page = pdf_doc_get_page(pf, &page_no, &count, &info.bbox, &resources);
if(!page)
goto error_silent;
+ catalog = pdf_file_get_catalog(pf);
+ markinfo = pdf_deref_obj(pdf_lookup_dict(catalog, "MarkInfo"));
if (markinfo) {
pdf_obj *tmp = pdf_deref_obj(pdf_lookup_dict(markinfo, "Marked"));
pdf_release_obj(markinfo);
@@ -199,4 +200,10 @@ pdf_include_page (pdf_ximage *ximage, FILE *image_file)
pdf_close(pf);
return -1;
+
+ too_recent:
+ WARN("PDF version of input file more recent than in output file.");
+ WARN("Converting. Use \"-V\" switch to change output PDF version.");
+ pdf_close(pf);
+ return 1;
}
diff --git a/Build/source/texk/dvipdfmx/src/epdf.h b/Build/source/texk/dvipdfmx/src/epdf.h
index 21703a8c96c..849589f3ebe 100644
--- a/Build/source/texk/dvipdfmx/src/epdf.h
+++ b/Build/source/texk/dvipdfmx/src/epdf.h
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/epdf.h,v 1.8 2004/09/11 14:50:28 hirata Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/epdf.h,v 1.9 2009/05/03 00:13:04 matthias Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -28,6 +28,7 @@
#include "mfileio.h"
#include "pdfximage.h"
-extern int pdf_include_page (pdf_ximage *ximage, FILE *file);
+extern int pdf_include_page (pdf_ximage *ximage, FILE *file,
+ const char *filename);
#endif /* _EPDF_H_ */
diff --git a/Build/source/texk/dvipdfmx/src/jpegimage.c b/Build/source/texk/dvipdfmx/src/jpegimage.c
index c605394311e..ed8d69165a2 100644
--- a/Build/source/texk/dvipdfmx/src/jpegimage.c
+++ b/Build/source/texk/dvipdfmx/src/jpegimage.c
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/jpegimage.c,v 1.9 2007/05/18 05:19:01 chofchof Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/jpegimage.c,v 1.10 2009/03/24 02:07:48 matthias Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -194,6 +194,8 @@ static int JPEG_copy_stream (struct JPEG_info *j_info,
static void JPEG_info_init (struct JPEG_info *j_info);
static void JPEG_info_clear (struct JPEG_info *j_info);
static pdf_obj *JPEG_get_iccp (struct JPEG_info *j_info);
+static void jpeg_get_density (struct JPEG_info *j_info,
+ double *xdensity, double *ydensity);
int
check_for_jpeg (FILE *fp)
@@ -331,36 +333,44 @@ jpeg_include_image (pdf_ximage *ximage, FILE *fp)
info.bits_per_component = j_info.bits_per_component;
info.num_components = j_info.num_components;
-#define IS_JFIF(j) ((j).flags & HAVE_APPn_JFIF)
+ jpeg_get_density(&j_info, &info.xdensity, &info.ydensity);
+
+ pdf_ximage_set_image(ximage, &info, stream);
+ JPEG_info_clear(&j_info);
+
+ return 0;
+}
+
+#define IS_JFIF(j) ((j)->flags & HAVE_APPn_JFIF)
+
+static void
+jpeg_get_density (struct JPEG_info *j_info,
+ double *xdensity, double *ydensity)
+{
if (IS_JFIF(j_info)) {
struct JPEG_APPn_JFIF *app_data;
int i;
- for (i = 0; i < j_info.num_appn; i++) {
- if (j_info.appn[i].marker != JM_APP0 ||
- j_info.appn[i].app_sig != JS_APPn_JFIF)
- continue;
+ for (i = 0; i < j_info->num_appn; i++) {
+ if (j_info->appn[i].marker == JM_APP0 ||
+ j_info->appn[i].app_sig == JS_APPn_JFIF)
+ break;
}
- if (i < j_info.num_appn) {
- app_data = (struct JPEG_APPn_JFIF *)j_info.appn[i].app_data;
+ if (i < j_info->num_appn) {
+ app_data = (struct JPEG_APPn_JFIF *)j_info->appn[i].app_data;
switch (app_data->units) {
case 1: /* pixels per inch */
- info.xdensity = 72.0 / app_data->Xdensity;
- info.ydensity = 72.0 / app_data->Ydensity;
+ *xdensity = 72.0 / app_data->Xdensity;
+ *ydensity = 72.0 / app_data->Ydensity;
break;
case 2: /* pixels per centimeter */
- info.xdensity = 72.0 / 2.54 / app_data->Xdensity;
- info.ydensity = 72.0 / 2.54 / app_data->Ydensity;
+ *xdensity = 72.0 / 2.54 / app_data->Xdensity;
+ *ydensity = 72.0 / 2.54 / app_data->Ydensity;
break;
default:
break;
}
}
}
-
- pdf_ximage_set_image(ximage, &info, stream);
- JPEG_info_clear(&j_info);
-
- return 0;
}
static void
@@ -749,3 +759,27 @@ JPEG_scan_file (struct JPEG_info *j_info, FILE *fp)
return (found_SOFn ? 0 : -1);
}
+
+int
+jpeg_get_bbox (FILE *fp, long *width, long *height,
+ double *xdensity, double *ydensity)
+{
+ struct JPEG_info j_info;
+
+ JPEG_info_init(&j_info);
+
+ if (JPEG_scan_file(&j_info, fp) < 0) {
+ WARN("%s: Not a JPEG file?", JPEG_DEBUG_STR);
+ JPEG_info_clear(&j_info);
+ return -1;
+ }
+
+ *width = j_info.width;
+ *height = j_info.height;
+
+ jpeg_get_density(&j_info, xdensity, ydensity);
+
+ JPEG_info_clear(&j_info);
+
+ return 0;
+}
diff --git a/Build/source/texk/dvipdfmx/src/jpegimage.h b/Build/source/texk/dvipdfmx/src/jpegimage.h
index a47da0c0434..4b1e57c1e2c 100644
--- a/Build/source/texk/dvipdfmx/src/jpegimage.h
+++ b/Build/source/texk/dvipdfmx/src/jpegimage.h
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/jpegimage.h,v 1.2 2004/03/11 11:50:21 hirata Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/jpegimage.h,v 1.3 2009/03/24 02:07:48 matthias Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -30,6 +30,8 @@
extern int check_for_jpeg (FILE *fp);
extern int jpeg_include_image (pdf_ximage *ximage, FILE *fp);
+extern int jpeg_get_bbox (FILE *fp, long *width, long *height,
+ double *xdensity, double *ydensity);
#endif /* _JPEGIMAGE_H_ */
diff --git a/Build/source/texk/dvipdfmx/src/mem.c b/Build/source/texk/dvipdfmx/src/mem.c
index a5435cee40d..7e50f9f3c74 100644
--- a/Build/source/texk/dvipdfmx/src/mem.c
+++ b/Build/source/texk/dvipdfmx/src/mem.c
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/mem.c,v 1.6 2008/11/03 22:49:29 matthias Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/mem.c,v 1.7 2009/03/24 07:55:52 chofchof Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -26,6 +26,7 @@
#include <stdlib.h>
#include "system.h"
+#include "system.h"
#include "mem.h"
#include "error.h"
diff --git a/Build/source/texk/dvipdfmx/src/pdfdev.c b/Build/source/texk/dvipdfmx/src/pdfdev.c
index 21ea4e781a7..c539add58f7 100644
--- a/Build/source/texk/dvipdfmx/src/pdfdev.c
+++ b/Build/source/texk/dvipdfmx/src/pdfdev.c
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/pdfdev.c,v 1.70 2008/12/11 16:03:04 matthias Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/pdfdev.c,v 1.71 2009/03/16 22:26:40 matthias Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -536,7 +536,7 @@ dev_set_text_matrix (spt_t xpos, spt_t ypos, double slant, double extend, int ro
format_buffer[len++] = 'T';
format_buffer[len++] = 'm';
- pdf_doc_add_page_content(format_buffer, len);
+ pdf_doc_add_page_content(format_buffer, len); /* op: Tm */
text_state.ref_x = xpos;
text_state.ref_y = ypos;
@@ -556,7 +556,7 @@ reset_text_state (void)
/*
* We need to reset the line matrix to handle slanted fonts.
*/
- pdf_doc_add_page_content(" BT", 3);
+ pdf_doc_add_page_content(" BT", 3); /* op: BT */
/*
* text_state.matrix is identity at top of page.
* This sometimes write unnecessary "Tm"s when transition from
@@ -584,7 +584,7 @@ text_mode (void)
case TEXT_MODE:
break;
case STRING_MODE:
- pdf_doc_add_page_content(text_state.is_mb ? ">]TJ" : ")]TJ", 4);
+ pdf_doc_add_page_content(text_state.is_mb ? ">]TJ" : ")]TJ", 4); /* op: TJ */
break;
case GRAPHICS_MODE:
reset_text_state();
@@ -601,10 +601,10 @@ graphics_mode (void)
case GRAPHICS_MODE:
break;
case STRING_MODE:
- pdf_doc_add_page_content(text_state.is_mb ? ">]TJ" : ")]TJ", 4);
+ pdf_doc_add_page_content(text_state.is_mb ? ">]TJ" : ")]TJ", 4); /* op: TJ */
/* continue */
case TEXT_MODE:
- pdf_doc_add_page_content(" ET", 3);
+ pdf_doc_add_page_content(" ET", 3); /* op: ET */
text_state.force_reset = 0;
text_state.font_id = -1;
break;
@@ -731,12 +731,12 @@ start_string (spt_t xpos, spt_t ypos, double slant, double extend, int rotate)
len += dev_sprint_bp(format_buffer+len, desired_dely, &error_dely);
break;
}
- pdf_doc_add_page_content(format_buffer, len);
+ pdf_doc_add_page_content(format_buffer, len); /* op: */
/*
* dvipdfm wrongly using "TD" in place of "Td".
* The TD operator set leading, but we are not using T* etc.
*/
- pdf_doc_add_page_content(text_state.is_mb ? " Td[<" : " Td[(", 5);
+ pdf_doc_add_page_content(text_state.is_mb ? " Td[<" : " Td[(", 5); /* op: Td */
/* Error correction */
text_state.ref_x = xpos - error_delx;
@@ -757,7 +757,7 @@ string_mode (spt_t xpos, spt_t ypos, double slant, double extend, int rotate)
case TEXT_MODE:
if (text_state.force_reset) {
dev_set_text_matrix(xpos, ypos, slant, extend, rotate);
- pdf_doc_add_page_content(text_state.is_mb ? "[<" : "[(", 2);
+ pdf_doc_add_page_content(text_state.is_mb ? "[<" : "[(", 2); /* op: */
text_state.force_reset = 0;
} else {
start_string(xpos, ypos, slant, extend, rotate);
@@ -832,14 +832,14 @@ dev_set_font (int font_id)
format_buffer[len++] = ' ';
format_buffer[len++] = 'T';
format_buffer[len++] = 'f';
- pdf_doc_add_page_content(format_buffer, len);
+ pdf_doc_add_page_content(format_buffer, len); /* op: Tf */
if (font->bold > 0.0 || font->bold != text_state.bold_param) {
if (font->bold <= 0.0)
len = sprintf(format_buffer, " 0 Tr");
else
len = sprintf(format_buffer, " 2 Tr %.2f w", font->bold); /* _FIXME_ */
- pdf_doc_add_page_content(format_buffer, len);
+ pdf_doc_add_page_content(format_buffer, len); /* op: Tr w */
}
text_state.bold_param = font->bold;
@@ -1134,7 +1134,7 @@ pdf_dev_set_string (spt_t xpos, spt_t ypos,
len += p_itoa( kern, format_buffer + len);
}
format_buffer[len++] = text_state.is_mb ? '<' : '(';
- pdf_doc_add_page_content(format_buffer, len);
+ pdf_doc_add_page_content(format_buffer, len); /* op: */
len = 0;
}
@@ -1154,7 +1154,7 @@ pdf_dev_set_string (spt_t xpos, spt_t ypos,
FORMAT_BUF_SIZE - len, str_ptr, length);
}
/* I think if you really care about speed, you should avoid memcopy here. */
- pdf_doc_add_page_content(format_buffer, len);
+ pdf_doc_add_page_content(format_buffer, len); /* op: */
text_state.offset += width;
}
@@ -1533,7 +1533,7 @@ pdf_dev_set_rule (spt_t xpos, spt_t ypos, spt_t width, spt_t height)
}
format_buffer[len++] = ' ';
format_buffer[len++] = 'Q';
- pdf_doc_add_page_content(format_buffer, len);
+ pdf_doc_add_page_content(format_buffer, len); /* op: q re f Q */
}
/* Rectangle in device space coordinate. */
@@ -1740,7 +1740,7 @@ pdf_dev_put_image (int id,
res_name = pdf_ximage_get_resname(id);
len = sprintf(work_buffer, " /%s Do", res_name);
- pdf_doc_add_page_content(work_buffer, len);
+ pdf_doc_add_page_content(work_buffer, len); /* op: Do */
pdf_dev_grestore();
diff --git a/Build/source/texk/dvipdfmx/src/pdfdoc.c b/Build/source/texk/dvipdfmx/src/pdfdoc.c
index 6b226ed08d6..087ca41e1ee 100644
--- a/Build/source/texk/dvipdfmx/src/pdfdoc.c
+++ b/Build/source/texk/dvipdfmx/src/pdfdoc.c
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/pdfdoc.c,v 1.65 2008/12/11 16:03:05 matthias Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/pdfdoc.c,v 1.70 2009/05/04 00:41:42 matthias Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -373,7 +373,7 @@ static void pdf_doc_close_page_tree (pdf_doc *p);
static void pdf_doc_init_names (pdf_doc *p, int check_gotos);
static void pdf_doc_close_names (pdf_doc *p);
-static void pdf_doc_add_gotos (pdf_obj *annot_dict);
+static void pdf_doc_add_goto (pdf_obj *annot_dict);
static void pdf_doc_init_docinfo (pdf_doc *p);
static void pdf_doc_close_docinfo (pdf_doc *p);
@@ -929,33 +929,16 @@ pdf_doc_close_page_tree (pdf_doc *p)
*/
pdf_obj *
-pdf_doc_get_page (pdf_obj *trailer, long *page_p, long *count_p,
- pdf_rect *bbox, pdf_obj **resources_p,
- pdf_obj **markinfo_p) {
+pdf_doc_get_page (pdf_file *pf, long *page_p, 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 *catalog;
long page_no = *page_p, page_idx;
- if (pdf_lookup_dict(trailer, "Encrypt")) {
- WARN("This PDF document is encrypted.");
- pdf_release_obj(trailer);
- goto error_silent;
- }
-
- catalog = pdf_deref_obj(pdf_lookup_dict(trailer, "Root"));
- pdf_release_obj(trailer);
- if (!PDF_OBJ_DICTTYPE(catalog)) {
- if (catalog)
- pdf_release_obj(catalog);
- goto error;
- }
-
- if (markinfo_p)
- *markinfo_p = pdf_deref_obj(pdf_lookup_dict(catalog, "MarkInfo"));
+ catalog = pdf_file_get_catalog(pf);
page_tree = pdf_deref_obj(pdf_lookup_dict(catalog, "Pages"));
- pdf_release_obj(catalog);
if (!PDF_OBJ_DICTTYPE(page_tree))
goto error;
@@ -1094,7 +1077,7 @@ pdf_doc_get_page (pdf_obj *trailer, long *page_p, long *count_p,
{
int i;
- for (i = 4; --i; ) {
+ for (i = 4; i--; ) {
double x;
pdf_obj *tmp = pdf_deref_obj(pdf_get_array(box, i));
if (!PDF_OBJ_NUMBERTYPE(tmp)) {
@@ -1382,7 +1365,7 @@ pdf_doc_bookmarks_add (pdf_obj *dict, int is_open)
p->outlines.current = item;
- pdf_doc_add_gotos(dict);
+ pdf_doc_add_goto(dict);
return;
}
@@ -1475,63 +1458,54 @@ pdf_doc_add_names (const char *category,
}
static void
-pdf_doc_add_gotos (pdf_obj *annot_dict)
+pdf_doc_add_goto (pdf_obj *annot_dict)
{
- pdf_obj *subtype, *A, *S, *D = NULL, *tmp;
- char *dest;
+ pdf_obj *subtype = NULL, *A = NULL, *S = NULL, *D = NULL, *D_new, *dict;
+ char *dest, *key;
if (!pdoc.check_gotos)
return;
/*
- * We cannot use pdf_deref_obj because if it return NULL
- * we don't know whether a dictionary does not exist
- * or has been declared as @foo and not yet defined. (As
- * long as @foo is undefined, it is stored as "null" object.)
- */
-
- /*
* An annotation dictionary coming from an annotation special
* must have a "Subtype". An annotation dictionary coming from
* an outline special has none.
*/
- subtype = pdf_lookup_dict(annot_dict, "Subtype");
- if (PDF_OBJ_INDIRECTTYPE(subtype))
- goto indirect;
- else if (subtype && !PDF_OBJ_NULLTYPE(subtype)) {
- if (!PDF_OBJ_NAMETYPE(subtype))
+ subtype = pdf_deref_obj(pdf_lookup_dict(annot_dict, "Subtype"));
+ if (subtype) {
+ if (PDF_OBJ_UNDEFINED(subtype))
+ goto undefined;
+ else if (!PDF_OBJ_NAMETYPE(subtype))
goto error;
else if (strcmp(pdf_name_value(subtype), "Link"))
- return;
+ goto cleanup;
}
- A = pdf_lookup_dict(annot_dict, "A");
- if (PDF_OBJ_DICTTYPE(A)) {
- S = pdf_lookup_dict(A, "S");
- if (PDF_OBJ_INDIRECTTYPE(S))
- goto indirect;
- else if (!PDF_OBJ_NAMETYPE(S))
- goto error;
- else if (strcmp(pdf_name_value(S), "GoTo"))
- return;
-
- D = pdf_lookup_dict(A, "D");
- if (PDF_OBJ_NULLTYPE(D))
- D = NULL;
- } else if (PDF_OBJ_INDIRECTTYPE(A))
- goto indirect;
- else if (A && !PDF_OBJ_NULLTYPE(A))
- goto error;
-
- tmp = pdf_lookup_dict(annot_dict, "Dest");
- if (PDF_OBJ_NULLTYPE(tmp))
- tmp = NULL;
+ dict = annot_dict;
+ key = "Dest";
+ D = pdf_deref_obj(pdf_lookup_dict(annot_dict, key));
+ if (PDF_OBJ_UNDEFINED(D))
+ goto undefined;
- if (tmp) {
- if (D)
+ A = pdf_deref_obj(pdf_lookup_dict(annot_dict, "A"));
+ if (A) {
+ if (PDF_OBJ_UNDEFINED(A))
+ goto undefined;
+ else if (D || !PDF_OBJ_DICTTYPE(A))
goto error;
- else
- D = tmp;
+ else {
+ S = pdf_deref_obj(pdf_lookup_dict(A, "S"));
+ if (PDF_OBJ_UNDEFINED(S))
+ goto undefined;
+ else if (!PDF_OBJ_NAMETYPE(S))
+ goto error;
+ else if (strcmp(pdf_name_value(S), "GoTo"))
+ goto cleanup;
+
+ dict = A;
+ key = "D";
+ D = pdf_deref_obj(pdf_lookup_dict(A, key));
+ }
}
if (PDF_OBJ_STRINGTYPE(D))
@@ -1542,26 +1516,51 @@ pdf_doc_add_gotos (pdf_obj *annot_dict)
dest = pdf_name_value(D);
#endif
else if (PDF_OBJ_ARRAYTYPE(D))
- return;
- else if (PDF_OBJ_INDIRECTTYPE(D))
- goto indirect;
+ goto cleanup;
+ else if (PDF_OBJ_UNDEFINED(D))
+ goto undefined;
else
goto error;
- ht_insert_table(&pdoc.gotos, dest, strlen(dest), NULL+1, NULL);
- /* NULL+1 is just some non-null pointer */
- return;
+ D_new = ht_lookup_table(&pdoc.gotos, dest, strlen(dest));
+ if (!D_new) {
+ char buf[10];
+
+ /* We use hexadecimal notation for our numeric destinations.
+ * Other bases (e.g., 10+26 or 10+2*26) would be more efficient.
+ */
+ sprintf(buf, "%lx", ht_table_size(&pdoc.gotos));
+ D_new = pdf_new_string(buf, strlen(buf));
+ ht_insert_table(&pdoc.gotos, dest, strlen(dest),
+ D_new, (void (*) (void *)) pdf_release_obj);
+ }
+
+ {
+ pdf_obj *key_obj = pdf_new_name(key);
+ if (!pdf_add_dict(dict, key_obj, pdf_link_obj(D_new)))
+ pdf_release_obj(key_obj);
+ }
+
+ cleanup:
+ if (subtype)
+ pdf_release_obj(subtype);
+ if (A)
+ pdf_release_obj(A);
+ if (S)
+ pdf_release_obj(S);
+ if (D)
+ pdf_release_obj(D);
- indirect:
- pdoc.check_gotos = 0;
- if (verbose)
- MESG("\nFound unexpected annotation format."
- " Will not remove PDF destinations\n");
return;
error:
- WARN("Unknown PDF annotation format.");
- return;
+ WARN("Unknown PDF annotation format. Output file may be broken.");
+ goto cleanup;
+
+ undefined:
+ WARN("Cannot optimize PDF annotations. Output file may be broken."
+ " Please restart with option \"-C 0x10\"\n");
+ goto cleanup;
}
static void
@@ -1645,57 +1644,57 @@ pdf_doc_close_names (pdf_doc *p)
RELEASE(p->names);
p->names = NULL;
- ht_clear_table(&p->gotos, NULL);
+ ht_clear_table(&p->gotos, (void (*) (void *)) pdf_release_obj);
return;
}
void
-pdf_doc_add_annot (unsigned page_no, const pdf_rect *rect, pdf_obj *annot_dict)
+pdf_doc_add_annot (unsigned page_no, const pdf_rect *rect,
+ pdf_obj *annot_dict, int new_annot)
{
pdf_doc *p = &pdoc;
pdf_page *page;
pdf_obj *rect_array;
double annot_grow = p->opt.annot_grow;
+ double xpos, ypos;
+ pdf_rect mediabox, annbox;
page = doc_get_page_entry(p, page_no);
if (!page->annots)
page->annots = pdf_new_array();
-#if 1
- {
- pdf_rect mediabox;
-
- pdf_doc_get_mediabox(page_no, &mediabox);
- if (rect->llx < mediabox.llx ||
- rect->urx > mediabox.urx ||
- rect->lly < mediabox.lly ||
- rect->ury > mediabox.ury) {
- WARN("Annotation out of page boundary.");
- WARN("Current page's MediaBox: [%g %g %g %g]",
- mediabox.llx, mediabox.lly, mediabox.urx, mediabox.ury);
- WARN("Annotation: [%g %g %g %g]",
- rect->llx, rect->lly, rect->urx, rect->ury);
- WARN("Maybe incorrect paper size specified.");
- }
- if (rect->llx > rect->urx || rect->lly > rect->ury) {
- WARN("Rectangle with negative width/height: [%g %g %g %g]",
- rect->llx, rect->lly, rect->urx, rect->ury);
- }
+ pdf_doc_get_mediabox(page_no, &mediabox);
+ pdf_dev_get_coord(&xpos, &ypos);
+ annbox.llx = rect->llx - xpos; annbox.lly = rect->lly - ypos;
+ annbox.urx = rect->urx - xpos; annbox.ury = rect->ury - ypos;
+
+ if (annbox.llx < mediabox.llx || annbox.urx > mediabox.urx ||
+ annbox.lly < mediabox.lly || annbox.ury > mediabox.ury) {
+ WARN("Annotation out of page boundary.");
+ WARN("Current page's MediaBox: [%g %g %g %g]",
+ mediabox.llx, mediabox.lly, mediabox.urx, mediabox.ury);
+ WARN("Annotation: [%g %g %g %g]",
+ annbox.llx, annbox.lly, annbox.urx, annbox.ury);
+ WARN("Maybe incorrect paper size specified.");
+ }
+ if (annbox.llx > annbox.urx || annbox.lly > annbox.ury) {
+ WARN("Rectangle with negative width/height: [%g %g %g %g]",
+ annbox.llx, annbox.lly, annbox.urx, annbox.ury);
}
-#endif
rect_array = pdf_new_array();
- pdf_add_array(rect_array, pdf_new_number(ROUND(rect->llx - annot_grow, 0.001)));
- pdf_add_array(rect_array, pdf_new_number(ROUND(rect->lly - annot_grow, 0.001)));
- pdf_add_array(rect_array, pdf_new_number(ROUND(rect->urx + annot_grow, 0.001)));
- pdf_add_array(rect_array, pdf_new_number(ROUND(rect->ury + annot_grow, 0.001)));
+ pdf_add_array(rect_array, pdf_new_number(ROUND(annbox.llx - annot_grow, 0.001)));
+ pdf_add_array(rect_array, pdf_new_number(ROUND(annbox.lly - annot_grow, 0.001)));
+ pdf_add_array(rect_array, pdf_new_number(ROUND(annbox.urx + annot_grow, 0.001)));
+ pdf_add_array(rect_array, pdf_new_number(ROUND(annbox.ury + annot_grow, 0.001)));
pdf_add_dict (annot_dict, pdf_new_name("Rect"), rect_array);
pdf_add_array(page->annots, pdf_ref_obj(annot_dict));
- pdf_doc_add_gotos(annot_dict);
+ if (new_annot)
+ pdf_doc_add_goto(annot_dict);
return;
}
@@ -2653,17 +2652,16 @@ pdf_doc_end_grabbing (pdf_obj *attrib)
static struct
{
int dirty;
+ int broken;
pdf_obj *annot_dict;
pdf_rect rect;
-} breaking_state = {0, NULL, {0.0, 0.0, 0.0, 0.0}};
+} breaking_state = {0, 0, NULL, {0.0, 0.0, 0.0, 0.0}};
static void
reset_box (void)
{
- breaking_state.rect.llx = 10000.0; /* large value */
- breaking_state.rect.lly = 10000.0; /* large value */
- breaking_state.rect.urx = 0.0; /* small value */
- breaking_state.rect.ury = 0.0; /* small value */
+ breaking_state.rect.llx = breaking_state.rect.lly = HUGE_VAL;
+ breaking_state.rect.urx = breaking_state.rect.ury = -HUGE_VAL;
breaking_state.dirty = 0;
}
@@ -2671,6 +2669,7 @@ void
pdf_doc_begin_annot (pdf_obj *dict)
{
breaking_state.annot_dict = dict;
+ breaking_state.broken = 0;
reset_box();
}
@@ -2690,9 +2689,11 @@ pdf_doc_break_annot (void)
/* Copy dict */
annot_dict = pdf_new_dict();
pdf_merge_dict(annot_dict, breaking_state.annot_dict);
- pdf_doc_add_annot(pdf_doc_current_page_number(),
- &(breaking_state.rect), annot_dict);
+ pdf_doc_add_annot(pdf_doc_current_page_number(), &(breaking_state.rect),
+ annot_dict, !breaking_state.broken);
pdf_release_obj(annot_dict);
+
+ breaking_state.broken = 1;
}
reset_box();
}
diff --git a/Build/source/texk/dvipdfmx/src/pdfdoc.h b/Build/source/texk/dvipdfmx/src/pdfdoc.h
index 2056c84c35e..b824888bd9e 100644
--- a/Build/source/texk/dvipdfmx/src/pdfdoc.h
+++ b/Build/source/texk/dvipdfmx/src/pdfdoc.h
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/pdfdoc.h,v 1.28 2008/11/30 21:12:27 matthias Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/pdfdoc.h,v 1.31 2009/05/04 00:41:43 matthias Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -56,10 +56,9 @@ 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_obj *trailer,
+extern pdf_obj *pdf_doc_get_page (pdf_file *pf,
long *page_p, long *count_p,
- pdf_rect *bbox, pdf_obj **resources_p,
- pdf_obj **markinfo_p);
+ pdf_rect *bbox, pdf_obj **resources_p);
extern long pdf_doc_current_page_number (void);
extern pdf_obj *pdf_doc_current_page_resources (void);
@@ -116,7 +115,9 @@ extern void pdf_doc_end_grabbing (pdf_obj *attrib);
/* Annotation */
extern void pdf_doc_add_annot (unsigned page_no,
- const pdf_rect *rect, pdf_obj *annot_dict);
+ const pdf_rect *rect,
+ pdf_obj *annot_dict,
+ int dest_is_new);
/* Annotation with auto- clip and line (or page) break */
extern void pdf_doc_begin_annot (pdf_obj *dict);
diff --git a/Build/source/texk/dvipdfmx/src/pdfdraw.c b/Build/source/texk/dvipdfmx/src/pdfdraw.c
index 5bbc8d39ab5..6474282ffe1 100644
--- a/Build/source/texk/dvipdfmx/src/pdfdraw.c
+++ b/Build/source/texk/dvipdfmx/src/pdfdraw.c
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/pdfdraw.c,v 1.18 2008/12/11 16:03:05 matthias Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/pdfdraw.c,v 1.19 2009/03/16 22:26:40 matthias Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -799,7 +799,7 @@ pdf_dev__rectshape (pdf_dev *P,
buf[len++] = ' ';
buf[len++] = isclip ? 'n' : 'Q';
- pdf_doc_add_page_content(buf, len); len = 0;
+ pdf_doc_add_page_content(buf, len); /* op: q cm n re Q */
return 0;
}
@@ -842,7 +842,8 @@ pdf_dev__flushpath (pdf_dev *P,
b[len++] = ' ';
b[len++] = 'r';
b[len++] = 'e';
- pdf_doc_add_page_content(b, len); len = 0;
+ pdf_doc_add_page_content(b, len); /* op: re */
+ len = 0;
} else {
n_seg = PA_LENGTH(pa);
for (i = 0, len = 0, pe = &pa->path[0];
@@ -856,11 +857,13 @@ pdf_dev__flushpath (pdf_dev *P,
b[len++] = ' ';
b[len++] = PE_OPCHR(pe);
if (len + 128 > b_len) {
- pdf_doc_add_page_content(b, len); len = 0;
+ pdf_doc_add_page_content(b, len); /* op: m l c v y h */
+ len = 0;
}
}
if (len > 0) {
- pdf_doc_add_page_content(b, len); len = 0;
+ pdf_doc_add_page_content(b, len); /* op: m l c v y h */
+ len = 0;
}
}
@@ -869,7 +872,7 @@ pdf_dev__flushpath (pdf_dev *P,
if (rule == PDF_FILL_RULE_EVENODD)
b[len++] = '*';
- pdf_doc_add_page_content(b, len);
+ pdf_doc_add_page_content(b, len); /* op: f F s S b B W f* F* s* S* b* B* W* */
return 0;
}
@@ -1107,7 +1110,7 @@ pdf_dev_gsave (void)
copy_a_gstate(gs1, gs0);
m_stack_push(&gs_stack, gs1);
- pdf_doc_add_page_content(" q", 2);
+ pdf_doc_add_page_content(" q", 2); /* op: q */
return 0;
}
@@ -1126,7 +1129,7 @@ pdf_dev_grestore (void)
clear_a_gstate(gs);
RELEASE(gs);
- pdf_doc_add_page_content(" Q", 2);
+ pdf_doc_add_page_content(" Q", 2); /* op: Q */
pdf_dev_reset_fonts();
@@ -1188,7 +1191,7 @@ pdf_dev_grestore_to (int depth)
}
while (m_stack_depth(gss) > depth + 1) {
- pdf_doc_add_page_content(" Q", 2);
+ pdf_doc_add_page_content(" Q", 2); /* op: Q */
gs = m_stack_pop(gss);
clear_a_gstate(gs);
RELEASE(gs);
@@ -1283,7 +1286,7 @@ pdf_dev_set_color (const pdf_color *color, char mask, int force)
default: /* already verified the given color */
break;
}
- pdf_doc_add_page_content(fmt_buf, len);
+ pdf_doc_add_page_content(fmt_buf, len); /* op: RG K G rg k g */
pdf_color_copycolor(current, color);
}
@@ -1327,7 +1330,7 @@ pdf_dev_concat (const pdf_tmatrix *M)
buf[len++] = ' ';
buf[len++] = 'c';
buf[len++] = 'm';
- pdf_doc_add_page_content(buf, len);
+ pdf_doc_add_page_content(buf, len); /* op: cm */
pdf_concatmatrix(CTM, M);
@@ -1362,7 +1365,7 @@ pdf_dev_setmiterlimit (double mlimit)
len += pdf_sprint_length(buf + len, mlimit);
buf[len++] = ' ';
buf[len++] = 'M';
- pdf_doc_add_page_content(buf, len);
+ pdf_doc_add_page_content(buf, len); /* op: M */
gs->miterlimit = mlimit;
}
@@ -1379,7 +1382,7 @@ pdf_dev_setlinecap (int capstyle)
if (gs->linecap != capstyle) {
len = sprintf(buf, " %d J", capstyle);
- pdf_doc_add_page_content(buf, len);
+ pdf_doc_add_page_content(buf, len); /* op: J */
gs->linecap = capstyle;
}
@@ -1396,7 +1399,7 @@ pdf_dev_setlinejoin (int joinstyle)
if (gs->linejoin != joinstyle) {
len = sprintf(buf, " %d j", joinstyle);
- pdf_doc_add_page_content(buf, len);
+ pdf_doc_add_page_content(buf, len); /* op: j */
gs->linejoin = joinstyle;
}
@@ -1416,7 +1419,7 @@ pdf_dev_setlinewidth (double width)
len += pdf_sprint_length(buf + len, width);
buf[len++] = ' ';
buf[len++] = 'w';
- pdf_doc_add_page_content(buf, len);
+ pdf_doc_add_page_content(buf, len); /* op: w */
gs->linewidth = width;
}
@@ -1434,17 +1437,17 @@ pdf_dev_setdash (int count, double *pattern, double offset)
gs->linedash.num_dash = count;
gs->linedash.offset = offset;
- pdf_doc_add_page_content(" [", 2);
+ pdf_doc_add_page_content(" [", 2); /* op: */
for (i = 0; i < count; i++) {
buf[0] = ' ';
len = pdf_sprint_length (buf + 1, pattern[i]);
- pdf_doc_add_page_content(buf, len + 1);
+ pdf_doc_add_page_content(buf, len + 1); /* op: */
gs->linedash.pattern[i] = pattern[i];
}
- pdf_doc_add_page_content("] ", 2);
+ pdf_doc_add_page_content("] ", 2); /* op: */
len = pdf_sprint_length (buf, offset);
- pdf_doc_add_page_content(buf, len);
- pdf_doc_add_page_content(" d", 2);
+ pdf_doc_add_page_content(buf, len); /* op: */
+ pdf_doc_add_page_content(" d", 2); /* op: d */
return 0;
}
@@ -1464,7 +1467,7 @@ pdf_dev_setflat (int flatness)
if (gs->flatness != flatness) {
gs->flatness = flatness;
len = sprintf(buf, " %d i", flatness);
- pdf_doc_add_page_content(buf, len);
+ pdf_doc_add_page_content(buf, len); /* op: i */
}
return 0;
@@ -1523,7 +1526,7 @@ pdf_dev_newpath (void)
pdf_path__clearpath (p);
}
/* The following is required for "newpath" operator in mpost.c. */
- pdf_doc_add_page_content(" n", 2);
+ pdf_doc_add_page_content(" n", 2); /* op: n */
return 0;
}
diff --git a/Build/source/texk/dvipdfmx/src/pdfencoding.c b/Build/source/texk/dvipdfmx/src/pdfencoding.c
index 296674d9880..108500adbb1 100644
--- a/Build/source/texk/dvipdfmx/src/pdfencoding.c
+++ b/Build/source/texk/dvipdfmx/src/pdfencoding.c
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/pdfencoding.c,v 1.11 2008/05/22 11:03:09 chofchof Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/pdfencoding.c,v 1.12 2009/03/24 07:55:52 chofchof Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -29,6 +29,7 @@
#include <string.h>
#include "system.h"
+#include "system.h"
#include "mem.h"
#include "error.h"
#include "dpxutil.h"
diff --git a/Build/source/texk/dvipdfmx/src/pdfencrypt.c b/Build/source/texk/dvipdfmx/src/pdfencrypt.c
index e76f18eedaa..42902371fcf 100644
--- a/Build/source/texk/dvipdfmx/src/pdfencrypt.c
+++ b/Build/source/texk/dvipdfmx/src/pdfencrypt.c
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/pdfencrypt.c,v 1.10 2008/02/12 18:44:40 matthias Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/pdfencrypt.c,v 1.13 2009/03/27 23:47:01 matthias Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -37,6 +37,7 @@
#endif /* WIN32 */
#include "system.h"
+#include "system.h"
#include "mem.h"
#include "error.h"
#include "pdfobj.h"
@@ -49,7 +50,7 @@
#define MAX_PWD_LEN 128
static unsigned char algorithm, revision, key_size;
-static unsigned long permission;
+static long permission;
static unsigned char key_data[MAX_KEY_LEN], id_string[MAX_KEY_LEN];
static unsigned char opwd_string[MAX_STR_LEN], upwd_string[MAX_STR_LEN];
@@ -389,10 +390,10 @@ void pdf_enc_set_passwd (unsigned bits, unsigned perm, char *dviname, char *pdfn
key_size = (unsigned char)(bits / 8);
algorithm = (key_size == 5 ? 1 : 2);
- permission = (unsigned long)perm | 0x000000C0;
- revision = ((algorithm == 1 && permission < 0x100) ? 2 : 3);
+ permission = (long) (perm | 0xC0U);
+ revision = ((algorithm == 1 && permission < 0x100L) ? 2 : 3);
if (revision == 3)
- permission |= 0xFFFFF000;
+ permission |= ~0xFFFL;
compute_id_string(dviname, pdfname);
compute_owner_password();
@@ -501,7 +502,7 @@ pdf_obj *pdf_encrypt_obj (void)
pdf_new_name ("U"),
pdf_new_string (upwd_string, 32));
/* KEY : P
- * TYPE : integer
+ * TYPE : (signed 32 bit) integer
* VALUE: (Required) A set of flags specifying which operations are
* permitted when the document is opened with user access.
*/
diff --git a/Build/source/texk/dvipdfmx/src/pdflimits.h b/Build/source/texk/dvipdfmx/src/pdflimits.h
index 6cc162857f6..f3871dea24a 100644
--- a/Build/source/texk/dvipdfmx/src/pdflimits.h
+++ b/Build/source/texk/dvipdfmx/src/pdflimits.h
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/pdflimits.h,v 1.4 2004/09/05 13:30:05 hirata Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/pdflimits.h,v 1.6 2009/05/06 06:07:09 chofchof Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -26,6 +26,15 @@
#define _PDFLIMITS_H_
/*
+ * The minimal and maximal PDF version supported by DVIPDFMx.
+ * NOTE: Don't forget to update CIDFont_stdcc_def[] in cid.c
+ * if you increase PDF_VERSION_MAX!
+ */
+#define PDF_VERSION_MIN 3
+#define PDF_VERSION_MAX 7
+#define PDF_VERSION_DEFAULT 4
+
+/*
* PDF_NAME_LEN_MAX: see, Appendix C of PDF Ref. v1.3, 2nd. ed.
* This is Acrobat implementation limit.
*/
diff --git a/Build/source/texk/dvipdfmx/src/pdfnames.c b/Build/source/texk/dvipdfmx/src/pdfnames.c
index ed7a9b7c6a2..a209e110397 100644
--- a/Build/source/texk/dvipdfmx/src/pdfnames.c
+++ b/Build/source/texk/dvipdfmx/src/pdfnames.c
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/pdfnames.c,v 1.5 2008/11/03 22:49:29 matthias Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/pdfnames.c,v 1.6 2009/04/26 21:23:29 matthias Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -44,9 +44,8 @@
struct obj_data
{
- pdf_obj *object_ref;
pdf_obj *object;
- int reserve; /* 1 if object is not actually defined. */
+ int closed; /* 1 if object is closed */
};
char *
@@ -86,7 +85,7 @@ pdf_new_name_tree (void)
}
static void
-flush_objects (struct ht_table *ht_tab)
+check_objects_defined (struct ht_table *ht_tab)
{
struct ht_iter iter;
@@ -98,19 +97,12 @@ flush_objects (struct ht_table *ht_tab)
key = ht_iter_getkey(&iter, &keylen);
value = ht_iter_getval(&iter);
- if (value->reserve) {
- WARN("Unresolved object reference \"%s\" found!!!",
+ ASSERT(value->object);
+ if (PDF_OBJ_UNDEFINED(value->object)) {
+ pdf_names_add_object(ht_tab, key, keylen, pdf_new_null());
+ WARN("Object @%s used, but not defined. Replaced by null.",
printable_key(key, keylen));
}
- if (value->object) {
- pdf_release_obj(value->object);
- }
- if (value->object_ref) {
- pdf_release_obj(value->object_ref);
- }
- value->object = NULL;
- value->object_ref = NULL;
- value->reserve = 0;
} while (ht_iter_next(&iter) >= 0);
ht_clear_iter(&iter);
}
@@ -122,14 +114,11 @@ hval_free (void *hval)
struct obj_data *value;
value = (struct obj_data *) hval;
- if (value->object)
- pdf_release_obj(value->object);
- if (value->object_ref)
- pdf_release_obj(value->object_ref);
- value->object = NULL;
- value->object_ref = NULL;
- value->reserve = 0;
+ if (value->object) {
+ pdf_release_obj(value->object);
+ value->object = NULL;
+ }
RELEASE(value);
@@ -141,7 +130,8 @@ pdf_delete_name_tree (struct ht_table **names)
{
ASSERT(names && *names);
- flush_objects (*names);
+ check_objects_defined(*names);
+
ht_clear_table(*names, hval_free);
RELEASE(*names);
*names = NULL;
@@ -163,64 +153,20 @@ pdf_names_add_object (struct ht_table *names,
value = ht_lookup_table(names, key, keylen);
if (!value) {
value = NEW(1, struct obj_data);
- value->object = object;
- value->object_ref = NULL;
- value->reserve = 0;
+ value->object = object;
+ value->closed = 0;
ht_append_table(names, key, keylen, value);
} else {
- if (value->reserve) {
- /* null object is used for undefined objects */
+ ASSERT(value->object);
+ if (PDF_OBJ_UNDEFINED(value->object)) {
pdf_transfer_label(object, value->object);
pdf_release_obj(value->object);
value->object = object;
} else {
- if (value->object || value->object_ref) {
- WARN("Object reference with key \"%s\" is in use.",
- printable_key(key, keylen));
- pdf_release_obj(object);
- return -1;
- } else {
- value->object = object;
- }
- }
- value->reserve = 0;
- }
-
- return 0;
-}
-
-int
-pdf_names_add_reference (struct ht_table *names,
- const void *key, int keylen, pdf_obj *object_ref)
-{
- struct obj_data *value;
-
- ASSERT(names);
-
- if (!PDF_OBJ_INDIRECTTYPE(object_ref)) {
- WARN("Invalid type: @%s is not reference...",
- printable_key(key, keylen));
- return -1;
- }
-
- value = ht_lookup_table(names, key, keylen);
- if (!value) {
- value = NEW(1, struct obj_data);
- value->object = NULL;
- value->object_ref = object_ref;
- value->reserve = 0;
- ht_append_table(names, key, keylen, value);
- } else {
- if (value->object || value->object_ref) {
- WARN("Object reference \"%s\" is in use.",
- printable_key(key, keylen));
- WARN("Please close it before redefining.");
+ WARN("Object @%s already defined.", printable_key(key, keylen));
+ pdf_release_obj(object);
return -1;
- } else {
- value->object = NULL;
- value->object_ref = object_ref;
}
- value->reserve = 0;
}
return 0;
@@ -234,29 +180,24 @@ pdf_names_lookup_reference (struct ht_table *names,
const void *key, int keylen)
{
struct obj_data *value;
+ pdf_obj *object;
ASSERT(names);
value = ht_lookup_table(names, key, keylen);
- /* Reserve object label */
- if (!value) {
- value = NEW(1, struct obj_data);
- value->object = pdf_new_null(); /* dummy */
- value->object_ref = NULL;
- value->reserve = 1;
- ht_append_table(names, key, keylen, value);
- }
-
- if (!value->object_ref) {
- if (value->object)
- value->object_ref = pdf_ref_obj(value->object);
- else {
- WARN("Object @%s not defined or already closed.",
- printable_key(key, keylen));
- }
+ if (value) {
+ object = value->object;
+ } else {
+ /* A null object as dummy would create problems because as value
+ * of a dictionary entry, a null object is be equivalent to no entry
+ * at all. This matters for optimization of PDF destinations.
+ */
+ object = pdf_new_undefined();
+ pdf_names_add_object(names, key, keylen, object);
}
+ ASSERT(object);
- return pdf_link_obj(value->object_ref);
+ return pdf_ref_obj(object);
}
pdf_obj *
@@ -268,12 +209,9 @@ pdf_names_lookup_object (struct ht_table *names,
ASSERT(names);
value = ht_lookup_table(names, key, keylen);
- if (!value)
+ if (!value || PDF_OBJ_UNDEFINED(value->object))
return NULL;
- else if (!value->object) {
- WARN("Object @%s not defined or already closed.",
- printable_key(key, keylen));
- }
+ ASSERT(value->object);
return value->object;
}
@@ -287,21 +225,19 @@ pdf_names_close_object (struct ht_table *names,
ASSERT(names);
value = ht_lookup_table(names, key, keylen);
- if (!value) {
- WARN("Tried to release nonexistent reference: %s",
- printable_key(key, keylen));
+ if (!value ||PDF_OBJ_UNDEFINED(value->object) ) {
+ WARN("Cannot close undefined object @%s.", printable_key(key, keylen));
return -1;
}
+ ASSERT(value->object);
- if (value->object) {
- pdf_release_obj(value->object);
- value->object = NULL;
- } else {
- WARN("Trying to close object @%s twice?",
- printable_key(key, keylen));
+ if (value->closed) {
+ WARN("Object @%s already closed.", printable_key(key, keylen));
return -1;
}
+ value->closed = 1;
+
return 0;
}
@@ -434,32 +370,28 @@ flat_table (struct ht_table *ht_tab, long *num_entries,
key = ht_iter_getkey(&iter, &keylen);
- if (filter && !ht_lookup_table(filter, key, keylen))
- continue;
+ if (filter) {
+ pdf_obj *new_obj = ht_lookup_table(filter, key, keylen);
+
+ if (!new_obj)
+ continue;
+
+ key = pdf_string_value(new_obj);
+ keylen = pdf_string_length(new_obj);
+ }
value = ht_iter_getval(&iter);
- if (value->reserve) {
- WARN("Named object \"%s\" not defined!!!",
+ ASSERT(value->object);
+ if (PDF_OBJ_UNDEFINED(value->object)) {
+ WARN("Object @%s\" not defined. Replaced by null.",
printable_key(key, keylen));
- WARN("Replacing with null.");
objects[count].key = (char *) key;
objects[count].keylen = keylen;
objects[count].value = pdf_new_null();
- } else if (value->object_ref) {
- objects[count].key = (char *) key;
- objects[count].keylen = keylen;
- objects[count].value = pdf_link_obj(value->object_ref);
} else if (value->object) {
objects[count].key = (char *) key;
objects[count].keylen = keylen;
objects[count].value = pdf_link_obj(value->object);
- } else {
- WARN("Named object \"%s\" not defined!!!",
- printable_key(key, keylen));
- WARN("Replacing with null.");
- objects[count].key = (char *) key;
- objects[count].keylen = keylen;
- objects[count].value = pdf_new_null();
}
count++;
diff --git a/Build/source/texk/dvipdfmx/src/pdfnames.h b/Build/source/texk/dvipdfmx/src/pdfnames.h
index e02e0eb29f9..4eaaffbb3f1 100644
--- a/Build/source/texk/dvipdfmx/src/pdfnames.h
+++ b/Build/source/texk/dvipdfmx/src/pdfnames.h
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/pdfnames.h,v 1.2 2008/11/03 22:49:29 matthias Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/pdfnames.h,v 1.3 2009/04/26 21:23:29 matthias Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -35,8 +35,6 @@ extern void pdf_delete_name_tree (struct ht_table **names);
extern int pdf_names_add_object (struct ht_table *names,
const void *key, int keylen, pdf_obj *object);
-extern int pdf_names_add_reference (struct ht_table *names,
- const void *key, int keylen, pdf_obj *object_ref);
extern pdf_obj *pdf_names_lookup_reference (struct ht_table *names,
const void *key, int keylen);
extern pdf_obj *pdf_names_lookup_object (struct ht_table *names,
diff --git a/Build/source/texk/dvipdfmx/src/pdfobj.c b/Build/source/texk/dvipdfmx/src/pdfobj.c
index e25d481f7c5..86b6c698abb 100644
--- a/Build/source/texk/dvipdfmx/src/pdfobj.c
+++ b/Build/source/texk/dvipdfmx/src/pdfobj.c
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/pdfobj.c,v 1.63 2008/11/30 21:12:27 matthias Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/pdfobj.c,v 1.70 2009/05/06 06:07:09 chofchof Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -161,6 +161,7 @@ struct pdf_file
FILE *file;
pdf_obj *trailer;
xref_entry *xref_table;
+ pdf_obj *catalog;
long num_obj;
long file_size;
int version;
@@ -179,6 +180,8 @@ static pdf_obj *xref_stream;
/* Internal static routines */
+static int check_for_pdf_version (FILE *file);
+
static void pdf_flush_obj (pdf_obj *object, FILE *file);
static void pdf_label_obj (pdf_obj *object);
static void pdf_write_obj (pdf_obj *object, FILE *file);
@@ -240,13 +243,13 @@ pdf_set_compression (int level)
return;
}
-static unsigned pdf_version = 4;
+static unsigned pdf_version = PDF_VERSION_DEFAULT;
void
pdf_set_version (unsigned version)
{
/* Don't forget to update CIDFont_stdcc_def[] in cid.c too! */
- if (version >= 3 && version <= 6) {
+ if (version >= PDF_VERSION_MIN && version <= PDF_VERSION_MAX) {
pdf_version = version;
}
}
@@ -581,16 +584,13 @@ void pdf_out_white (FILE *file)
ERROR("typecheck: Invalid object type: %d %d (line %d)", (o) ? (o)->type : -1, (t), __LINE__);\
}
-#define INVALIDOBJ(o) ((o) == NULL || (o)->type <= 0 || (o)->type > PDF_INDIRECT)
+#define INVALIDOBJ(o) ((o) == NULL || (o)->type <= 0 || (o)->type > PDF_UNDEFINED)
static pdf_obj *
pdf_new_obj(int type)
{
pdf_obj *result;
- if (type > PDF_INDIRECT || type < PDF_UNDEFINED)
- ERROR("Invalid object type: %d", type);
-
result = NEW(1, pdf_obj);
result->type = type;
result->data = NULL;
@@ -599,6 +599,9 @@ pdf_new_obj(int type)
result->refcount = 1;
result->flags = 0;
+ if (INVALIDOBJ(result))
+ ERROR("Invalid object type: %d", type);
+
return result;
}
@@ -696,6 +699,20 @@ write_indirect (pdf_indirect *indirect, FILE *file)
pdf_out(file, format_buffer, length);
}
+/* The undefined object is used as a placeholder in pdfnames.c
+ * for objects which are referenced before they are defined.
+ */
+pdf_obj *
+pdf_new_undefined (void)
+{
+ pdf_obj *result;
+
+ result = pdf_new_obj(PDF_UNDEFINED);
+ result->data = NULL;
+
+ return result;
+}
+
pdf_obj *
pdf_new_null (void)
{
@@ -834,19 +851,17 @@ pdf_new_string (const void *str, unsigned length)
pdf_obj *result;
pdf_string *data;
+ ASSERT(str);
+
result = pdf_new_obj(PDF_STRING);
data = NEW(1, pdf_string);
result->data = data;
- if (length != 0) {
- data->length = length;
- data->string = NEW(length+1, unsigned char);
- memcpy(data->string, str, length);
- /* Shouldn't assume NULL terminated. */
- data->string[length] = '\0';
- } else {
- data->length = 0;
- data->string = NULL;
- }
+
+ data->length = length;
+ data->string = NEW(length+1, unsigned char);
+ memcpy(data->string, str, length);
+ /* Shouldn't assume NULL terminated. */
+ data->string[length] = '\0';
return result;
}
@@ -1327,14 +1342,20 @@ pdf_pop_array (pdf_obj *array)
static void
write_dict (pdf_dict *dict, FILE *file)
{
+#if 0
pdf_out (file, "<<\n", 3); /* dropping \n saves few kb. */
+#else
+ pdf_out (file, "<<", 2);
+#endif
while (dict->key != NULL) {
pdf_write_obj(dict->key, file);
if (pdf_need_white(PDF_NAME, (dict->value)->type)) {
pdf_out_white(file);
}
pdf_write_obj(dict->value, file);
+#if 0
pdf_out_char (file, '\n'); /* removing this saves few kb. */
+#endif
dict = dict->next;
}
pdf_out(file, ">>", 2);
@@ -1925,7 +1946,7 @@ pdf_write_obj (pdf_obj *object, FILE *file)
return;
}
- if (INVALIDOBJ(object))
+ if (INVALIDOBJ(object) || PDF_OBJ_UNDEFINED(object))
ERROR("pdf_write_obj: Invalid object, type = %d\n", object->type);
if (file == stderr)
@@ -2735,7 +2756,6 @@ parse_xref_stream (pdf_file *pf, long xref_pos, pdf_obj **trailer)
return 0;
}
-/* TODO: parse Version entry */
static pdf_obj *
read_xref (pdf_file *pf)
{
@@ -2820,6 +2840,7 @@ pdf_file_new (FILE *file)
pf->file = file;
pf->trailer = NULL;
pf->xref_table = NULL;
+ pf->catalog = NULL;
pf->num_obj = 0;
pf->version = 0;
@@ -2845,8 +2866,15 @@ pdf_file_free (pdf_file *pf)
pdf_release_obj(pf->xref_table[i].indirect);
}
- RELEASE(pf->xref_table);
- pdf_release_obj(pf->trailer);
+ RELEASE(pf->xref_table);
+ if (pf->trailer) {
+ pdf_release_obj(pf->trailer);
+ pf->trailer = NULL;
+ }
+ if (pf->catalog) {
+ pdf_release_obj(pf->catalog);
+ pf->catalog = NULL;
+ }
RELEASE(pf);
}
@@ -2858,15 +2886,31 @@ pdf_files_init (void)
ht_init_table(pdf_files);
}
+int
+pdf_file_get_version (pdf_file *pf)
+{
+ ASSERT(pf);
+ return pf->version;
+}
+
+#if 0
pdf_obj *
pdf_file_get_trailer (pdf_file *pf)
{
ASSERT(pf);
- return pdf_link_obj(pf->trailer);
+ return pf->trailer;
+}
+#endif
+
+pdf_obj *
+pdf_file_get_catalog (pdf_file *pf)
+{
+ ASSERT(pf);
+ return pf->catalog;
}
pdf_file *
-pdf_open (char *ident, FILE *file)
+pdf_open (const char *ident, FILE *file)
{
pdf_file *pf;
@@ -2877,24 +2921,57 @@ pdf_open (char *ident, FILE *file)
if (pf) {
pf->file = file;
} else {
- int version = check_for_pdf(file);
- if (!version) {
- WARN("pdf_open: Not a PDF 1.[1-5] file.");
+ int version;
+ pdf_obj *new_version;
+
+ version = check_for_pdf_version(file);
+ if (version < 0) {
+ WARN("Not a PDF file.");
return NULL;
}
pf = pdf_file_new(file);
pf->version = version;
- if (!(pf->trailer = read_xref(pf))) {
- pdf_file_free(pf);
- return NULL;
+ if (!(pf->trailer = read_xref(pf)))
+ goto error;
+
+ if (pdf_lookup_dict(pf->trailer, "Encrypt")) {
+ WARN("PDF document is encrypted.");
+ goto error;
+ }
+
+ pf->catalog = pdf_deref_obj(pdf_lookup_dict(pf->trailer, "Root"));
+ if (!PDF_OBJ_DICTTYPE(pf->catalog)) {
+ WARN("Cannot read PDF document catalog. Broken PDF file?");
+ goto error;
+ }
+
+ new_version = pdf_deref_obj(pdf_lookup_dict(pf->catalog, "Version"));
+ if (new_version) {
+ unsigned char minor;
+
+ if (!PDF_OBJ_NAMETYPE(new_version) ||
+ sscanf(pdf_name_value(new_version), "1.%hhu", &minor) != 1) {
+ pdf_release_obj(new_version);
+ WARN("Illegal Version entry in document catalog. Broken PDF file?");
+ goto error;
+ }
+
+ if (pf->version < minor)
+ pf->version = minor;
+
+ pdf_release_obj(new_version);
}
ht_append_table(pdf_files, ident, strlen(ident), pf);
}
return pf;
+
+ error:
+ pdf_file_free(pf);
+ return NULL;
}
void
@@ -2912,24 +2989,21 @@ pdf_files_close (void)
RELEASE(pdf_files);
}
-int
-check_for_pdf (FILE *file)
+static int
+check_for_pdf_version (FILE *file)
{
- int result = 0;
+ unsigned char minor;
rewind(file);
- if (fread(work_buffer, sizeof(char), strlen("%PDF-1.x"), file) ==
- strlen("%PDF-1.x") &&
- !strncmp(work_buffer, "%PDF-1.", strlen("%PDF-1."))) {
- if (work_buffer[7] >= '0' && work_buffer[7] <= '0' + pdf_version)
- result = 1;
- else {
- WARN("Version of PDF file (1.%c) is newer than version limit specification.",
- work_buffer[7]);
- }
- }
- return result;
+ return (ungetc(fgetc(file), file) == '%' &&
+ fscanf(file, "%%PDF-1.%hhu", &minor) == 1) ? minor : -1;
+}
+
+int
+check_for_pdf (FILE *file)
+{
+ return (check_for_pdf_version(file) >= 0);
}
static int CDECL
diff --git a/Build/source/texk/dvipdfmx/src/pdfobj.h b/Build/source/texk/dvipdfmx/src/pdfobj.h
index a80e9a22147..a50220bfcd8 100644
--- a/Build/source/texk/dvipdfmx/src/pdfobj.h
+++ b/Build/source/texk/dvipdfmx/src/pdfobj.h
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/pdfobj.h,v 1.31 2008/11/30 21:12:27 matthias Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/pdfobj.h,v 1.34 2009/05/03 00:13:04 matthias Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -38,9 +38,9 @@
#define PDF_STREAM 7
#define PDF_NULL 8
#define PDF_INDIRECT 9
+#define PDF_UNDEFINED 10
#define PDF_OBJ_INVALID 0
-#define PDF_UNDEFINED PDF_OBJ_INVALID
#define STREAM_COMPRESS (1 << 0)
@@ -73,6 +73,7 @@ extern int pdf_obj_typeof (pdf_obj *object);
#define PDF_OBJ_DICTTYPE(o) ((o) && pdf_obj_typeof((o)) == PDF_DICT)
#define PDF_OBJ_STREAMTYPE(o) ((o) && pdf_obj_typeof((o)) == PDF_STREAM)
#define PDF_OBJ_INDIRECTTYPE(o) ((o) && pdf_obj_typeof((o)) == PDF_INDIRECT)
+#define PDF_OBJ_UNDEFINED(o) ((o) && pdf_obj_typeof((o)) == PDF_UNDEFINED)
#define PDF_OBJ_TYPEOF(o) pdf_obj_typeof((o))
@@ -81,6 +82,8 @@ extern pdf_obj *pdf_ref_obj (pdf_obj *object);
extern pdf_obj *pdf_link_obj (pdf_obj *object);
extern void pdf_transfer_label (pdf_obj *dst, pdf_obj *src);
+extern pdf_obj *pdf_new_undefined (void);
+
extern pdf_obj *pdf_new_null (void);
extern pdf_obj *pdf_new_boolean (char value);
@@ -188,9 +191,13 @@ extern void pdf_set_encrypt (pdf_obj *encrypt, pdf_obj *id);
extern void pdf_files_init (void);
extern void pdf_files_close (void);
extern int check_for_pdf (FILE *file);
-extern pdf_file *pdf_open (char *ident, FILE *file);
+extern pdf_file *pdf_open (const char *ident, FILE *file);
extern void pdf_close (pdf_file *pf);
+#if 0
extern pdf_obj *pdf_file_get_trailer (pdf_file *pf);
+#endif
+extern int pdf_file_get_version (pdf_file *pf);
+extern pdf_obj *pdf_file_get_catalog (pdf_file *pf);
extern pdf_obj *pdf_deref_obj (pdf_obj *object);
extern pdf_obj *pdf_import_object (pdf_obj *object);
diff --git a/Build/source/texk/dvipdfmx/src/pdfparse.c b/Build/source/texk/dvipdfmx/src/pdfparse.c
index 111114ec362..7709e7fced7 100644
--- a/Build/source/texk/dvipdfmx/src/pdfparse.c
+++ b/Build/source/texk/dvipdfmx/src/pdfparse.c
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/pdfparse.c,v 1.43 2008/06/07 09:54:38 chofchof Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/pdfparse.c,v 1.44 2009/04/29 11:20:21 chofchof Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -503,10 +503,18 @@ parse_pdf_literal_string (char **pp, char *endptr)
p++;
- /*
- * Accroding to the PDF spec., an end-of-line marker, not preceded
- * by a backslash, must be converted to single \n.
- */
+ /* The carriage return (CR, 0x0d) and line feed (LF, 0x0a) characters,
+ * also called newline characters, are treated as end-of-line (EOL)
+ * markers. The combination of a carriage return followed immediately
+ * by a line feed is treated as one EOL marker.
+ * [PDF Reference, 6th ed., version 1.7, p. 50] */
+
+ /* If an end-of-line marker appears within a literal string
+ * without a preceding backslash, the result is equivalent to
+ * \n (regardless of whether the end-of-line marker was
+ * a carriage return, a line feed, or both).
+ * [PDF Reference, 6th ed., version 1.7, p. 55] */
+
while (p < endptr) {
ch = p[0];
@@ -666,7 +674,7 @@ parse_pdf_tainted_dict (char **pp, char *endptr)
}
#else /* PDF_PARSE_STRICT */
pdf_obj *
-parse_pdf_tainted_dict (char **pp, char *endptr, int level)
+parse_pdf_tainted_dict (char **pp, char *endptr)
{
return parse_pdf_dict(pp, endptr, NULL);
}
@@ -788,26 +796,19 @@ parse_pdf_stream (char **pp, char *endptr, pdf_obj *dict, pdf_file *pf)
}
p += 6;
- /* Carrige return alone is not allowed after keyword "stream".
- * See, PDF Reference, 4th ed., version 1.5, p. 36.
- */
+ /* The keyword stream that follows the stream dictionary
+ * should be followed by an end-of-line marker consisting of
+ * either a carriage return (0x0D;\r) and a line feed (0x0A;\n)
+ * or just a line feed, and not by a carriage return alone.
+ * [PDF Reference, 6th ed., version 1.7, pp. 60-61] */
+
+ /* Notice that TeX translates an end-of-line marker to a single space. */
if (p < endptr && p[0] == '\n') {
p++;
} else if (p + 1 < endptr &&
(p[0] == '\r' && p[1] == '\n')) {
p += 2;
}
-#ifndef PDF_PARSE_STRICT
- else {
- /* TeX translate end-of-line marker to a single space. */
- if (parser_state.tainted) {
- if (p < endptr && p[0] == ' ') {
- p++;
- }
- }
- }
- /* The end-of-line marker not mandatory? */
-#endif /* !PDF_PARSE_STRICT */
/* Stream length */
{
@@ -824,31 +825,6 @@ parse_pdf_stream (char **pp, char *endptr, pdf_obj *dict, pdf_file *pf)
}
pdf_release_obj(tmp2);
}
-#ifndef PDF_PARSE_STRICT
- else if (p + 9 <= endptr)
- {
- /*
- * This was added to allow TeX users to write PDF stream object
- * directly in their TeX source. This violates PDF spec.
- */
- char *q;
-
- stream_length = -1;
- for (q = endptr - 1; q >= p + 8; q--) {
- if (q[0] != 'm')
- continue;
- else {
- if (!memcmp(q - 8, "endstrea", 8)) {
- /* The end-of-line marker is not skipped here. There are
- * no way to decide if it is a part of the stream or not.
- */
- stream_length = ((long) (q - p)) - 8;
- break;
- }
- }
- }
- }
-#endif /* !PDF_PARSE_STRICT */
else {
return NULL;
}
@@ -882,24 +858,14 @@ parse_pdf_stream (char **pp, char *endptr, pdf_obj *dict, pdf_file *pf)
/* Check "endsteam" */
{
- /*
- * It is an error if the stream contained too much data except there
- * may be an extra end-of-line marker before the keyword "endstream".
- */
-#ifdef PDF_PARSE_STRICT
+ /* It is recommended that there be an end-of-line marker
+ * after the data and before endstream; this marker is not included
+ * in the stream length.
+ * [PDF Reference, 6th ed., version 1.7, pp. 61] */
if (p < endptr && p[0] == '\r')
p++;
if (p < endptr && p[0] == '\n')
p++;
-#else /* !PDF_PARSE_STRICT */
- /*
- * This may skip data starting with '%' and terminated by a
- * '\r' or '\n' or '\r\n'. The PDF syntax rule should not be
- * applied to the content of the stream data.
- * TeX may have converted end-of-line to single white space.
- */
- skip_white(&p, endptr);
-#endif /* !PDF_PARSE_STRICT */
if (p + 9 > endptr ||
memcmp(p, "endstream", 9)) {
diff --git a/Build/source/texk/dvipdfmx/src/pdfximage.c b/Build/source/texk/dvipdfmx/src/pdfximage.c
index d33b9629b51..b51541c8e67 100644
--- a/Build/source/texk/dvipdfmx/src/pdfximage.c
+++ b/Build/source/texk/dvipdfmx/src/pdfximage.c
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/pdfximage.c,v 1.21 2008/05/29 13:43:51 chofchof Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/pdfximage.c,v 1.23 2009/05/03 00:13:04 matthias Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -261,8 +261,14 @@ load_image (const char *ident, const char *fullname, int format, FILE *fp,
case IMAGE_TYPE_PDF:
if (_opts.verbose)
MESG("[PDF]");
- if (pdf_include_page(I, fp) < 0)
- goto error;
+ {
+ int result = pdf_include_page(I, fp, ident);
+ if (result > 0)
+ /* PDF version too recent */
+ result = ps_include_page(I, fullname);
+ if (result < 0)
+ goto error;
+ }
if (_opts.verbose)
MESG(",Page:%ld", I->page_no);
I->subtype = PDF_XOBJECT_TYPE_FORM;
@@ -443,12 +449,6 @@ pdf_ximage_init_image_info (ximage_info *info)
info->xdensity = info->ydensity = 1.0;
}
-char *
-pdf_ximage_get_ident (pdf_ximage *I)
-{
- return I->ident;
-}
-
void
pdf_ximage_set_image (pdf_ximage *I, void *image_info, pdf_obj *resource)
{
@@ -827,7 +827,8 @@ ps_include_page (pdf_ximage *ximage, const char *filename)
MESG("pdf_image>> ...");
}
- error = dpx_file_apply_filter(distiller_template, filename, temp);
+ error = dpx_file_apply_filter(distiller_template, filename, temp,
+ (unsigned char) pdf_get_version());
if (error) {
WARN("Image format conversion for \"%s\" failed...", filename);
dpx_delete_temp_file(temp);
@@ -840,7 +841,7 @@ ps_include_page (pdf_ximage *ximage, const char *filename)
dpx_delete_temp_file(temp);
return -1;
}
- error = pdf_include_page(ximage, fp);
+ error = pdf_include_page(ximage, fp, temp);
MFCLOSE(fp);
if (_opts.verbose > 1) {
diff --git a/Build/source/texk/dvipdfmx/src/pdfximage.h b/Build/source/texk/dvipdfmx/src/pdfximage.h
index dc74d373af7..34d4ef2518a 100644
--- a/Build/source/texk/dvipdfmx/src/pdfximage.h
+++ b/Build/source/texk/dvipdfmx/src/pdfximage.h
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/pdfximage.h,v 1.13 2008/05/29 13:43:51 chofchof Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/pdfximage.h,v 1.14 2009/05/03 00:13:04 matthias Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -70,7 +70,6 @@ extern int pdf_ximage_defineresource (const char *ident, int subtype,
/* 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 char *pdf_ximage_get_ident (pdf_ximage *ximage);
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_page (pdf_ximage *ximage, long page_no, long page_count);
diff --git a/Build/source/texk/dvipdfmx/src/pngimage.c b/Build/source/texk/dvipdfmx/src/pngimage.c
index f7eb4ba3513..6d4953650cd 100644
--- a/Build/source/texk/dvipdfmx/src/pngimage.c
+++ b/Build/source/texk/dvipdfmx/src/pngimage.c
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/pngimage.c,v 1.25 2007/05/18 05:19:01 chofchof Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/pngimage.c,v 1.26 2009/03/24 02:07:48 matthias Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -206,9 +206,6 @@ png_include_image (pdf_ximage *ximage, FILE *png_file)
png_read_update_info(png_ptr, png_info_ptr);
rowbytes = png_get_rowbytes(png_ptr, png_info_ptr);
- stream = pdf_new_stream (STREAM_COMPRESS);
- stream_dict = pdf_stream_dict(stream);
-
/* Values listed below will not be modified in the remaining process. */
info.width = width;
info.height = height;
@@ -218,6 +215,9 @@ png_include_image (pdf_ximage *ximage, FILE *png_file)
if (yppm > 0)
info.ydensity = 72.0 / 0.0254 / yppm;
+ stream = pdf_new_stream (STREAM_COMPRESS);
+ stream_dict = pdf_stream_dict(stream);
+
stream_data_ptr = (png_bytep) NEW(rowbytes*height, png_byte);
read_image_data(png_ptr, png_info_ptr, stream_data_ptr, height, rowbytes);
@@ -1006,4 +1006,46 @@ read_image_data (png_structp png_ptr, png_infop info_ptr, /* info_ptr unused */
RELEASE(rows_p);
}
+int
+png_get_bbox (FILE *png_file, long *width, long *height,
+ double *xdensity, double *ydensity)
+{
+ png_structp png_ptr;
+ png_infop png_info_ptr;
+ png_uint_32 xppm, yppm;
+
+ rewind (png_file);
+ png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
+ if (png_ptr == NULL ||
+ (png_info_ptr = png_create_info_struct (png_ptr)) == NULL) {
+ WARN("%s: Creating Libpng read/info struct failed.", PNG_DEBUG_STR);
+ if (png_ptr)
+ png_destroy_read_struct(&png_ptr, NULL, NULL);
+ return -1;
+ }
+
+ /* Inititializing file IO. */
+ png_init_io (png_ptr, png_file);
+
+ /* Read PNG info-header and get some info. */
+ png_read_info(png_ptr, png_info_ptr);
+ *width = png_get_image_width (png_ptr, png_info_ptr);
+ *height = png_get_image_height(png_ptr, png_info_ptr);
+ xppm = png_get_x_pixels_per_meter(png_ptr, png_info_ptr);
+ yppm = png_get_y_pixels_per_meter(png_ptr, png_info_ptr);
+
+ /* Cleanup */
+ if (png_info_ptr)
+ png_destroy_info_struct(png_ptr, &png_info_ptr);
+ if (png_ptr)
+ png_destroy_read_struct(&png_ptr, NULL, NULL);
+
+ if (xppm > 0)
+ *xdensity = 72.0 / 0.0254 / xppm;
+ if (yppm > 0)
+ *ydensity = 72.0 / 0.0254 / yppm;
+
+ return 0;
+}
+
#endif /* HAVE_LIBPNG */
diff --git a/Build/source/texk/dvipdfmx/src/pngimage.h b/Build/source/texk/dvipdfmx/src/pngimage.h
index fe9c4a7e1e8..4bb33726ab5 100644
--- a/Build/source/texk/dvipdfmx/src/pngimage.h
+++ b/Build/source/texk/dvipdfmx/src/pngimage.h
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/pngimage.h,v 1.4 2004/03/11 11:50:25 hirata Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/pngimage.h,v 1.5 2009/03/24 02:07:48 matthias Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -37,6 +37,8 @@
extern int png_include_image (pdf_ximage *ximage, FILE *file);
extern int check_for_png (FILE *file);
+extern int png_get_bbox (FILE *fp, long *width, long *height,
+ double *xdensity, double *ydensity);
#endif
diff --git a/Build/source/texk/dvipdfmx/src/spc_color.c b/Build/source/texk/dvipdfmx/src/spc_color.c
index dbbe5254999..c1b730b6059 100644
--- a/Build/source/texk/dvipdfmx/src/spc_color.c
+++ b/Build/source/texk/dvipdfmx/src/spc_color.c
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/spc_color.c,v 1.8 2008/12/11 16:03:05 matthias Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/spc_color.c,v 1.9 2009/04/29 11:22:19 chofchof Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -53,7 +53,7 @@ spc_handler_color_push (struct spc_env *spe, struct spc_arg *args)
int error;
pdf_color colorspec;
- error = spc_util_read_colorspec(spe, &colorspec, args, 1);
+ error = spc_util_read_colorspec(spe, &colorspec, args);
if (!error) {
pdf_color_push(&colorspec, &colorspec);
}
@@ -78,7 +78,7 @@ spc_handler_color_default (struct spc_env *spe, struct spc_arg *args)
int error;
pdf_color colorspec;
- error = spc_util_read_colorspec(spe, &colorspec, args, 1);
+ error = spc_util_read_colorspec(spe, &colorspec, args);
if (!error) {
pdf_color_clear_stack();
pdf_color_set(&colorspec, &colorspec);
@@ -97,7 +97,7 @@ spc_handler_background (struct spc_env *spe, struct spc_arg *args)
int error;
pdf_color colorspec;
- error = spc_util_read_colorspec(spe, &colorspec, args, 1);
+ error = spc_util_read_colorspec(spe, &colorspec, args);
if (!error)
pdf_doc_set_bgcolor(&colorspec);
diff --git a/Build/source/texk/dvipdfmx/src/spc_html.c b/Build/source/texk/dvipdfmx/src/spc_html.c
index 276f8b1c947..35fbdbbdbb9 100644
--- a/Build/source/texk/dvipdfmx/src/spc_html.c
+++ b/Build/source/texk/dvipdfmx/src/spc_html.c
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/spc_html.c,v 1.9 2008/11/30 21:31:24 matthias Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/spc_html.c,v 1.10 2009/03/16 22:26:40 matthias Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -662,9 +662,9 @@ spc_html__img_empty (struct spc_env *spe, pdf_obj *attr, struct spc_html_ *sd)
res_name, pdf_ref_obj(dict));
pdf_release_obj(dict);
}
- pdf_doc_add_page_content(" /", 2);
- pdf_doc_add_page_content(res_name, strlen(res_name));
- pdf_doc_add_page_content(" gs", 3);
+ pdf_doc_add_page_content(" /", 2); /* op: */
+ pdf_doc_add_page_content(res_name, strlen(res_name)); /* op: */
+ pdf_doc_add_page_content(" gs", 3); /* op: gs */
RELEASE(res_name);
}
}
@@ -677,9 +677,9 @@ spc_html__img_empty (struct spc_env *spe, pdf_obj *attr, struct spc_html_ *sd)
pdf_dev_rectclip(r.llx, r.lly, r.urx - r.llx, r.ury - r.lly);
res_name = pdf_ximage_get_resname(id);
- pdf_doc_add_page_content(" /", 2);
- pdf_doc_add_page_content(res_name, strlen(res_name));
- pdf_doc_add_page_content(" Do", 3);
+ pdf_doc_add_page_content(" /", 2); /* op: */
+ pdf_doc_add_page_content(res_name, strlen(res_name)); /* op: */
+ pdf_doc_add_page_content(" Do", 3); /* op: Do */
pdf_dev_grestore();
diff --git a/Build/source/texk/dvipdfmx/src/spc_pdfm.c b/Build/source/texk/dvipdfmx/src/spc_pdfm.c
index e756420c404..beed3752125 100644
--- a/Build/source/texk/dvipdfmx/src/spc_pdfm.c
+++ b/Build/source/texk/dvipdfmx/src/spc_pdfm.c
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/spc_pdfm.c,v 1.45 2008/12/11 16:03:05 matthias Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/spc_pdfm.c,v 1.48 2009/04/29 11:22:19 chofchof Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -572,7 +572,7 @@ spc_handler_pdfm_annot (struct spc_env *spe, struct spc_arg *args)
if (ident)
spc_push_object(ident, pdf_link_obj(annot_dict));
/* This add reference. */
- pdf_doc_add_annot(pdf_doc_current_page_number(), &rect, annot_dict);
+ pdf_doc_add_annot(pdf_doc_current_page_number(), &rect, annot_dict, 1);
if (ident) {
spc_flush_object(ident);
@@ -643,11 +643,13 @@ spc_handler_pdfm_bcolor (struct spc_env *spe, struct spc_arg *ap)
{
int error;
pdf_color fc, sc;
+ pdf_color *pfc, *psc;
- error = spc_util_read_colorspec(spe, &fc, ap, 0);
+ pdf_color_get_current(&psc, &pfc);
+ error = spc_util_read_pdfcolor(spe, &fc, ap, pfc);
if (!error) {
if (ap->curptr < ap->endptr) {
- error = spc_util_read_colorspec(spe, &sc, ap, 0);
+ error = spc_util_read_pdfcolor(spe, &sc, ap, psc);
} else {
pdf_color_copycolor(&sc, &fc);
}
@@ -671,11 +673,13 @@ spc_handler_pdfm_scolor (struct spc_env *spe, struct spc_arg *ap)
{
int error;
pdf_color fc, sc;
+ pdf_color *pfc, *psc;
- error = spc_util_read_colorspec(spe, &fc, ap, 0);
+ pdf_color_get_current(&psc, &pfc);
+ error = spc_util_read_pdfcolor(spe, &fc, ap, pfc);
if (!error) {
if (ap->curptr < ap->endptr) {
- error = spc_util_read_colorspec(spe, &sc, ap, 0);
+ error = spc_util_read_pdfcolor(spe, &sc, ap, psc);
} else {
pdf_color_copycolor(&sc, &fc);
}
@@ -1252,10 +1256,10 @@ spc_handler_pdfm_content (struct spc_env *spe, struct spc_arg *args)
work_buffer[len++] = 'm';
work_buffer[len++] = ' ';
- pdf_doc_add_page_content(work_buffer, len);
+ pdf_doc_add_page_content(work_buffer, len); /* op: q cm */
len = (long) (args->endptr - args->curptr);
- pdf_doc_add_page_content(args->curptr, len);
- pdf_doc_add_page_content(" Q", 2);
+ pdf_doc_add_page_content(args->curptr, len); /* op: ANY */
+ pdf_doc_add_page_content(" Q", 2); /* op: Q */
}
args->curptr = args->endptr;
@@ -1290,8 +1294,8 @@ spc_handler_pdfm_literal (struct spc_env *spe, struct spc_arg *args)
M.e = spe->x_user; M.f = spe->y_user;
pdf_dev_concat(&M);
}
- pdf_doc_add_page_content(" ", 1);
- pdf_doc_add_page_content(args->curptr, (long) (args->endptr - args->curptr));
+ pdf_doc_add_page_content(" ", 1); /* op: */
+ pdf_doc_add_page_content(args->curptr, (long) (args->endptr - args->curptr)); /* op: ANY */
if (!direct) {
M.e = -spe->x_user; M.f = -spe->y_user;
pdf_dev_concat(&M);
@@ -1333,8 +1337,8 @@ 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));
+ pdf_doc_add_page_content(" ", 1); /* op: */
+ pdf_doc_add_page_content(args->curptr, (long) (args->endptr - args->curptr)); /* op: ANY */
args->curptr = args->endptr;
}
@@ -1669,7 +1673,7 @@ spc_handler_pdfm_bgcolor (struct spc_env *spe, struct spc_arg *args)
int error;
pdf_color colorspec;
- error = spc_util_read_colorspec(spe, &colorspec, args, 0);
+ error = spc_util_read_pdfcolor(spe, &colorspec, args, NULL);
if (error)
spc_warn(spe, "No valid color specified?");
else {
diff --git a/Build/source/texk/dvipdfmx/src/spc_tpic.c b/Build/source/texk/dvipdfmx/src/spc_tpic.c
index 2fab3d83839..100ead5eadf 100644
--- a/Build/source/texk/dvipdfmx/src/spc_tpic.c
+++ b/Build/source/texk/dvipdfmx/src/spc_tpic.c
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/spc_tpic.c,v 1.5 2008/11/30 21:39:19 matthias Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/spc_tpic.c,v 1.6 2009/03/16 22:26:40 matthias Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -193,7 +193,7 @@ set_fillstyle (double g, double a, int f_ais)
}
len += sprintf(buf + len, " /%s gs", resname);
- pdf_doc_add_page_content(buf, len);
+ pdf_doc_add_page_content(buf, len); /* op: gs */
}
{
diff --git a/Build/source/texk/dvipdfmx/src/spc_util.c b/Build/source/texk/dvipdfmx/src/spc_util.c
index bd1fe8d906f..d3db0e4cf25 100644
--- a/Build/source/texk/dvipdfmx/src/spc_util.c
+++ b/Build/source/texk/dvipdfmx/src/spc_util.c
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/spc_util.c,v 1.14 2008/06/01 01:38:32 chofchof Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/spc_util.c,v 1.16 2009/04/29 11:30:51 chofchof Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -204,18 +204,18 @@ spc_read_color_pdf (struct spc_env *spe, pdf_color *colorspec, struct spc_arg *a
default:
/* 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;
+ if (q) {
+ error = pdf_color_namedcolor(colorspec, q);
+ if (error)
+ spc_warn(spe, "Unrecognized color name: %s, keep the current color", q);
+ RELEASE(q);
+ } else {
+ error = -1;
}
- error = pdf_color_namedcolor(colorspec, q);
- if (error)
- spc_warn(spe, "Unrecognized color name: %s", q);
- RELEASE(q);
break;
}
- if (!error && isarry) {
+ if (isarry) {
skip_blank(&ap->curptr, ap->endptr);
if (ap->curptr >= ap->endptr || ap->curptr[0] != ']') {
spc_warn(spe, "Unbalanced '[' and ']' in color specification.");
@@ -231,26 +231,36 @@ spc_read_color_pdf (struct spc_env *spe, pdf_color *colorspec, struct spc_arg *a
/* This is for reading *single* color specification. */
int
-spc_util_read_colorspec (struct spc_env *spe, pdf_color *colorspec, struct spc_arg *ap, int syntax)
+spc_util_read_colorspec (struct spc_env *spe, pdf_color *colorspec, struct spc_arg *ap)
{
- int error = 0;
-
ASSERT(colorspec && spe && ap);
skip_blank(&ap->curptr, ap->endptr);
if (ap->curptr >= ap->endptr) {
return -1;
}
+ return spc_read_color_color(spe, colorspec, ap);
+}
+
+int
+spc_util_read_pdfcolor (struct spc_env *spe, pdf_color *colorspec, struct spc_arg *ap, pdf_color *defaultcolor)
+{
+ int error = 0;
- if (syntax)
- error = spc_read_color_color(spe, colorspec, ap);
- else
- error = spc_read_color_pdf(spe, colorspec, ap);
+ ASSERT(colorspec && spe && ap);
- return error;
+ skip_blank(&ap->curptr, ap->endptr);
+ if (ap->curptr >= ap->endptr) {
+ return -1;
+ }
+ error = spc_read_color_pdf(spe, colorspec, ap);
+ if (error < 0 && defaultcolor) {
+ pdf_color_copycolor(colorspec, defaultcolor);
+ error = 0;
+ }
+ return error;
}
-
/* This need to allow 'true' prefix for unit and
* length value must be divided by current magnification.
*/
@@ -481,9 +491,9 @@ spc_read_dimtrns_pdfm (struct spc_env *spe, transform_info *p, struct spc_arg *a
#define K_TRN__XSCALE 4
#define K_TRN__YSCALE 5
#define K_TRN__ROTATE 6
- "scale", "xscale", "yscale", "rotate",
+ "scale", "xscale", "yscale", "rotate", /* See "Dvipdfmx User's Manual", p.5 */
#define K_TRN__BBOX 7
- "bbox", /* See "Dvipdfmx User's Manual", p.5 */
+ "bbox",
#define K_TRN__MATRIX 8
"matrix",
#undef K__CLIP
diff --git a/Build/source/texk/dvipdfmx/src/spc_util.h b/Build/source/texk/dvipdfmx/src/spc_util.h
index 0dd2c938ea1..e27c369415f 100644
--- a/Build/source/texk/dvipdfmx/src/spc_util.h
+++ b/Build/source/texk/dvipdfmx/src/spc_util.h
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/spc_util.h,v 1.5 2008/02/13 20:22:21 matthias Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/spc_util.h,v 1.6 2009/04/29 11:22:19 chofchof Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -35,7 +35,8 @@
*
* 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_colorspec (struct spc_env *spe, pdf_color *colorspec, 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_dimtrns (struct spc_env *spe, transform_info *dimtrns, struct spc_arg *args, long *page, int syntax);
extern int spc_util_read_length (struct spc_env *spe, double *length, struct spc_arg *ap);
diff --git a/Build/source/texk/dvipdfmx/src/specials.c b/Build/source/texk/dvipdfmx/src/specials.c
index 9ef4bd2670b..3c04720b451 100644
--- a/Build/source/texk/dvipdfmx/src/specials.c
+++ b/Build/source/texk/dvipdfmx/src/specials.c
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/specials.c,v 1.12 2009/01/15 21:04:38 chofchof Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/specials.c,v 1.13 2009/04/26 21:23:29 matthias Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -283,31 +283,12 @@ spc_lookup_object (const char *key)
void
spc_push_object (const char *key, pdf_obj *value)
{
- int error = 0;
+ ASSERT(named_objects);
if (!key || !value)
return;
- if (PDF_OBJ_INDIRECTTYPE(value)) {
- pdf_names_add_reference(named_objects,
- key, strlen(key), value);
- } else {
- error = pdf_names_add_object(named_objects,
- key, strlen(key), value);
- if (!error) {
- /* _FIXME_:
- * Objects created by pdf:obj must always
- * be written to output regardless of if
- * they are actually used in document.
- */
- pdf_obj *obj_ref = pdf_names_lookup_reference(named_objects,
- key, strlen(key));
- if (obj_ref)
- pdf_release_obj(obj_ref);
- }
- }
-
- return;
+ pdf_names_add_object(named_objects, key, strlen(key), value);
}
void
diff --git a/Build/source/texk/dvipdfmx/src/t1_load.c b/Build/source/texk/dvipdfmx/src/t1_load.c
index 9efbb20c149..d58428cf616 100644
--- a/Build/source/texk/dvipdfmx/src/t1_load.c
+++ b/Build/source/texk/dvipdfmx/src/t1_load.c
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/t1_load.c,v 1.12 2008/10/13 19:42:48 matthias Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/t1_load.c,v 1.13 2009/04/08 03:10:58 chofchof Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -566,18 +566,24 @@ parse_subrs (cff_font *font,
}
if (mode != 1) {
- subrs = font->subrs[0] = cff_new_index(count);
- subrs->data = NEW(offset, card8);
- offset = 0;
- for (i = 0; i < count; i++) {
- subrs->offset[i] = offset + 1;
- if (lengths[i] > 0) {
- memcpy(subrs->data + offset, data + offsets[i], lengths[i]);
- offset += lengths[i];
+ if (font->subrs[0] == NULL) {
+ subrs = font->subrs[0] = cff_new_index(count);
+ subrs->data = NEW(offset, card8);
+ offset = 0;
+ for (i = 0; i < count; i++) {
+ subrs->offset[i] = offset + 1;
+ if (lengths[i] > 0) {
+ memcpy(subrs->data + offset, data + offsets[i], lengths[i]);
+ offset += lengths[i];
+ }
}
+ subrs->offset[count] = offset + 1;
+ } else {
+ /* Adobe's OPO_____.PFB and OPBO____.PFB have two /Subrs dicts,
+ * and also have /CharStrings not followed by dicts.
+ * Simply ignores those data. By ChoF on 2009/04/08. */
+ WARN("Already found /Subrs; ignores the other /Subrs dicts.");
}
- subrs->offset[count] = offset + 1;
-
RELEASE(data);
RELEASE(offsets);
RELEASE(lengths);
@@ -605,8 +611,11 @@ parse_charstrings (cff_font *font,
tok = pst_get_token(start, end);
if (!PST_INTEGERTYPE(tok) ||
pst_getIV(tok) < 0 || pst_getIV(tok) > CFF_GLYPH_MAX) {
+ unsigned char *s = pst_getSV(tok);
+ WARN("Ignores non dict \"/CharStrings %s ...\"", s);
+ RELEASE(s);
RELEASE_TOK(tok);
- return -1;
+ return 0;
}
count = pst_getIV(tok);
RELEASE_TOK(tok);
diff --git a/Build/source/texk/dvipdfmx/src/tt_table.c b/Build/source/texk/dvipdfmx/src/tt_table.c
index ce2e1f109c0..418c1e956ff 100644
--- a/Build/source/texk/dvipdfmx/src/tt_table.c
+++ b/Build/source/texk/dvipdfmx/src/tt_table.c
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/tt_table.c,v 1.10 2008/11/30 21:12:27 matthias Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/tt_table.c,v 1.11 2009/05/02 12:16:32 chofchof Exp $
This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
@@ -188,7 +188,6 @@ tt_read_hhea_table (sfnt *sfont)
ULONG len;
struct tt_hhea_table *table = NULL;
- len = sfnt_find_table_len(sfont, "hhea");
sfnt_locate_table(sfont, "hhea");
table = NEW(1, struct tt_hhea_table);
@@ -210,6 +209,8 @@ tt_read_hhea_table (sfnt *sfont)
if (table->metricDataFormat != 0)
ERROR("unknown metricDaraFormat");
table->numOfLongHorMetrics = sfnt_get_ushort(sfont);
+
+ len = sfnt_find_table_len(sfont, "hmtx");
table->numOfExSideBearings = (USHORT)((len - table->numOfLongHorMetrics * 4) / 2);
return table;
@@ -251,7 +252,6 @@ struct tt_vhea_table *tt_read_vhea_table (sfnt *sfont)
ULONG len;
struct tt_vhea_table *table = NULL;
- len = sfnt_find_table_len(sfont, "vhea");
sfnt_locate_table(sfont, "vhea");
table = NEW(1, struct tt_vhea_table);
@@ -271,6 +271,8 @@ struct tt_vhea_table *tt_read_vhea_table (sfnt *sfont)
}
table->metricDataFormat = sfnt_get_short(sfont);
table->numOfLongVerMetrics = sfnt_get_ushort(sfont);
+
+ len = sfnt_find_table_len(sfont, "vmtx");
table->numOfExSideBearings = (USHORT)((len - table->numOfLongVerMetrics * 4) / 2);
return table;
diff --git a/Build/source/texk/dvipdfmx/src/xbb.c b/Build/source/texk/dvipdfmx/src/xbb.c
index 484322845d1..03db02e0bed 100644
--- a/Build/source/texk/dvipdfmx/src/xbb.c
+++ b/Build/source/texk/dvipdfmx/src/xbb.c
@@ -1,4 +1,4 @@
-/* $Header: /home/cvsroot/dvipdfmx/src/xbb.c,v 1.17 2008/12/11 16:09:29 matthias Exp $
+/* $Header: /home/cvsroot/dvipdfmx/src/xbb.c,v 1.25 2009/05/04 00:41:43 matthias Exp $
This is extractbb, a bounding box extraction program.
@@ -21,11 +21,12 @@
#include <stdio.h>
#include <time.h>
#include <string.h>
+
+#include "numbers.h"
#include "system.h"
#include "mem.h"
#include "error.h"
#include "mfileio.h"
-#include "numbers.h"
#include "pdfobj.h"
#include "pdfdev.h"
#include "pdfdoc.h"
@@ -33,29 +34,34 @@
#include "config.h"
-#ifdef HAVE_LIBPNG
-#include <png.h>
-#endif
+#include "jpegimage.h"
+#include "pngimage.h"
#include "xbb.h"
#define XBB_PROGRAM "extractbb"
-#define XBB_VERSION "Version 0.2"
+#define XBB_VERSION VERSION
+
+static int really_quiet = 0;
static void usage(void)
{
- fprintf (stderr, "%s, version %s, Copyright (C) 2008 by Jin-Hwan Cho\n",
+ if (really_quiet)
+ return;
+
+ printf("%s, version %s, Copyright (C) 2008 by Jin-Hwan Cho\n",
XBB_PROGRAM, XBB_VERSION);
- fprintf (stderr, "A bounding box extraction utility from PDF, PNG, and JPG.\n");
- fprintf (stdout, "\nThis is free software; you can redistribute it and/or modify\n");
- fprintf (stdout, "it under the terms of the GNU General Public License as published by\n");
- fprintf (stdout, "the Free Software Foundation; either version 2 of the License, or\n");
- fprintf (stdout, "(at your option) any later version.\n");
- fprintf (stderr, "\nUsage: %s [-v] [-b] [-m|-x] [files]\n", XBB_PROGRAM);
- fprintf (stderr, "\t-b\tWrite output file in binary mode\n");
- fprintf (stderr, "\t-m\tOutput .bb file used in DVIPDFM\n");
- fprintf (stderr, "\t-x\tOutput .xbb file used in DVIPDFMx (default)\n");
- fprintf (stderr, "\t-v\tVerbose\n");
+ printf("A bounding box extraction utility from PDF, PNG, and JPEG.\n");
+ printf("\nThis is free software; you can redistribute it and/or modify\n");
+ printf("it under the terms of the GNU General Public License as published by\n");
+ printf("the Free Software Foundation; either version 2 of the License, or\n");
+ printf("(at your option) any later version.\n");
+ printf("\nUsage: %s [-v|-q] [-O] [-m|-x] [files]\n", XBB_PROGRAM);
+ printf("\t-v\tBe verbose\n");
+ printf("\t-q\tBe quiet\n");
+ printf("\t-O\tWrite output to stdout\n");
+ printf("\t-m\tOutput .bb file used in DVIPDFM\n");
+ printf("\t-x\tOutput .xbb file used in DVIPDFMx (default)\n");
exit(1);
}
@@ -77,6 +83,8 @@ char *extensions[] = {
static int xbb_output_mode = XBB_OUTPUT;
+static int xbb_to_file = 1;
+
static char *make_xbb_filename(const char *name)
{
int i;
@@ -88,7 +96,7 @@ static char *make_xbb_filename(const char *name)
break;
}
if (i == sizeof(extensions) / sizeof(extensions[0])) {
- fprintf(stderr, "Warning: %s: Filename does not end in a recognizable extension.\n", name);
+ WARN("%s: Filename does not end in a recognizable extension.\n", name);
result = NEW(strlen(name)+5, char); /* 5 = ".xbb" + trailing 0 */
strcpy(result, name);
} else { /* Remove extension */
@@ -100,210 +108,103 @@ static char *make_xbb_filename(const char *name)
return result;
}
-static char *xbb_file_mode = FOPEN_W_MODE;
-
-static void write_xbb(char *fname, int bbllx, int bblly, int bburx, int bbury)
+static void write_xbb(char *fname,
+ double bbllx_f, double bblly_f,
+ double bburx_f, double bbury_f,
+ int pdf_version, long pagecount)
{
- char *outname;
+ char *outname = NULL;
FILE *fp;
- outname = make_xbb_filename(fname);
- if ((fp = MFOPEN(outname, xbb_file_mode)) == NULL) {
- fprintf(stderr, "Unable to open output file: %s\n", outname);
- RELEASE(outname);
- return;
+ long bbllx = ROUND(bbllx_f, 1.0), bblly = ROUND(bblly_f, 1.0);
+ long bburx = ROUND(bburx_f, 1.0), bbury = ROUND(bbury_f, 1.0);
+
+ if (xbb_to_file) {
+ outname = make_xbb_filename(fname);
+ if ((fp = MFOPEN(outname, FOPEN_W_MODE)) == NULL) {
+ ERROR("Unable to open output file: %s\n", outname);
+ }
+ } else {
+ fp = stdout;
}
+
if (verbose) {
- fprintf(stderr, "Writing to %s: ", outname);
- fprintf(stderr, "Bounding box: %d %d %d %d\n", bbllx, bblly, bburx, bbury);
+ MESG("Writing to %s: ", xbb_to_file ? outname : "stdout");
+ MESG("Bounding box: %d %d %d %d\n", bbllx, bblly, bburx, bbury);
}
- fprintf(fp,"%%%%Title: %s\n", fname);
- fprintf(fp,"%%%%Creator: %s %s\n", XBB_PROGRAM, XBB_VERSION);
- fprintf(fp,"%%%%BoundingBox: %d %d %d %d\n", bbllx, bblly, bburx, bbury);
- do_time(fp);
- RELEASE(outname);
- MFCLOSE(fp);
-}
-
-typedef enum {
- JM_SOF0 = 0xc0, JM_SOF1 = 0xc1, JM_SOF2 = 0xc2, JM_SOF3 = 0xc3,
- JM_SOF5 = 0xc5, JM_DHT = 0xc4, JM_SOF6 = 0xc6, JM_SOF7 = 0xc7,
- JM_SOF9 = 0xc9, JM_SOF10 = 0xca, JM_SOF11 = 0xcb, JM_DAC = 0xcc,
- JM_SOF13 = 0xcd, JM_SOF14 = 0xce, JM_SOF15 = 0xcf,
-
- JM_RST0 = 0xd0, JM_RST1 = 0xd1, JM_RST2 = 0xd2, JM_RST3 = 0xd3,
- JM_RST4 = 0xd4, JM_RST5 = 0xd5, JM_RST6 = 0xd6, JM_RST7 = 0xd7,
-
- JM_SOI = 0xd8, JM_EOI = 0xd9, JM_SOS = 0xda, JM_DQT = 0xdb,
- JM_DNL = 0xdc, JM_DRI = 0xdd, JM_DHP = 0xde, JM_EXP = 0xdf,
- JM_APP0 = 0xe0, JM_APP2 = 0xe2, JM_APP14 = 0xee, JM_APP15 = 0xef,
+ fprintf(fp, "%%%%Title: %s\n", fname);
+ fprintf(fp, "%%%%Creator: %s %s\n", XBB_PROGRAM, XBB_VERSION);
+ fprintf(fp, "%%%%BoundingBox: %ld %ld %ld %ld\n", bbllx, bblly, bburx, bbury);
- JM_COM = 0xfe
-} JPEG_marker;
-
-static JPEG_marker JPEG_get_marker (FILE *fp)
-{
- int c = fgetc(fp);
- if (c != 255) return -1;
- for (;;) {
- c = fgetc(fp);
- if (c < 0) return -1;
- else if (c > 0 && c < 255) return c;
+ if (xbb_output_mode == XBB_OUTPUT) {
+ /* Note:
+ * According to Adobe Technical Note #5644, the arguments to
+ * "%%HiResBoundingBox:" must be of type real. And according
+ * to the PostScript Language Reference, a real number must
+ * be written with a decimal point (or an exponent). Hence
+ * it seems illegal to replace "0.0" by "0".
+ */
+ fprintf(fp, "%%%%HiResBoundingBox: %f %f %f %f\n",
+ bbllx_f, bblly_f, bburx_f, bbury_f);
+ if (pdf_version >= 0) {
+ fprintf(fp, "%%%%PDFVersion: 1.%d\n", pdf_version);
+ fprintf(fp, "%%%%Pages: %ld\n", pagecount);
+ }
}
- return -1;
-}
-static int check_for_jpeg (FILE *fp)
-{
- unsigned char jpeg_sig[2];
- rewind(fp);
- if (fread(jpeg_sig, sizeof(unsigned char), 2, fp) != 2) return 0;
- else if (jpeg_sig[0] != 0xff || jpeg_sig[1] != JM_SOI) return 0;
- return 1;
-}
-
-static int jpeg_get_info (FILE *fp, int *width, int *height)
-{
- JPEG_marker marker;
- unsigned short length;
- int count;
- float xdensity = 1.0, ydensity = 1.0;
- char app_sig[128];
-
- if (!check_for_jpeg(fp)) {
- rewind(fp);
- return -1;
- }
- rewind(fp);
- count = 0;
- while ((marker = JPEG_get_marker(fp)) >= 0) {
- if (marker == JM_SOI || (marker >= JM_RST0 && marker <= JM_RST7)) {
- count++; continue;
- }
- length = get_unsigned_pair(fp) - 2;
- switch (marker) {
- case JM_SOF0: case JM_SOF1: case JM_SOF2: case JM_SOF3:
- case JM_SOF5: case JM_SOF6: case JM_SOF7: case JM_SOF9:
- case JM_SOF10: case JM_SOF11: case JM_SOF13: case JM_SOF14:
- case JM_SOF15:
- get_unsigned_byte(fp);
- if (xbb_output_mode != XBB_OUTPUT) { /* EBB_OUTPUT */
- xdensity = ydensity = 72.0 / 100.0;
- }
- *height = (int)(get_unsigned_pair(fp) * ydensity + 0.5);
- *width = (int)(get_unsigned_pair(fp) * xdensity + 0.5);
- return 0;
- case JM_APP0:
- if (length > 5) {
- if (fread(app_sig, sizeof(char), 5, fp) != 5) return -1;
- length -= 5;
- if (!memcmp(app_sig, "JFIF\000", 5)) {
- int units, xden, yden;
- get_unsigned_pair(fp);
- units = (int)get_unsigned_byte(fp);
- xden = (int)get_unsigned_pair(fp);
- yden = (int)get_unsigned_pair(fp);
- switch (units) {
- case 1: /* pixels per inch */
- xdensity = 72.0 / xden;
- ydensity = 72.0 / yden;
- break;
- case 2: /* pixels per centimeter */
- xdensity = 72.0 / 2.54 / xden;
- ydensity = 72.0 / 2.54 / yden;
- break;
- default:
- break;
- }
- length -= 7;
- }
- }
- seek_relative(fp, length);
- break;
- default:
- seek_relative(fp, length);
- break;
- }
- count++;
+ do_time(fp);
+
+ if (xbb_to_file) {
+ RELEASE(outname);
+ MFCLOSE(fp);
}
- return -1;
}
static void do_jpeg (FILE *fp, char *filename)
{
- int width, height;
+ long width, height;
+ double xdensity = 1.0, ydensity = 1.0;
- if (jpeg_get_info(fp, &width, &height) < 0) {
- fprintf (stderr, "%s does not look like a JPEG file...\n", filename);
+ if (jpeg_get_bbox(fp, &width, &height, &xdensity, &ydensity) < 0) {
+ WARN("%s does not look like a JPEG file...\n", filename);
return;
}
- write_xbb(filename, 0, 0, width, height);
+
+ if (xbb_output_mode == EBB_OUTPUT)
+ xdensity = ydensity = 72.0 / 100.0;
+
+ write_xbb(filename, 0, 0, xdensity*width, ydensity*height, -1, -1);
return;
}
#ifdef HAVE_LIBPNG
-static int check_for_png (FILE *png_file)
-{
- unsigned char sigbytes[4];
- rewind (png_file);
- if (fread(sigbytes, 1, sizeof(sigbytes), png_file) != sizeof(sigbytes) ||
- (!png_check_sig (sigbytes, sizeof(sigbytes)))) return 0;
- else return 1;
-}
-
-static int png_get_info(FILE *png_file, int *width, int *height)
-{
- png_structp png_ptr;
- png_infop png_info_ptr;
- png_uint_32 xppm, yppm;
-
- rewind(png_file);
-
- png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
- if (png_ptr == NULL || (png_info_ptr = png_create_info_struct(png_ptr)) == NULL) {
- if (png_ptr) png_destroy_read_struct(&png_ptr, NULL, NULL);
- return -1;
- }
- png_init_io(png_ptr, png_file);
- png_read_info(png_ptr, png_info_ptr);
-
- *width = (int)png_get_image_width(png_ptr, png_info_ptr);
- *height = (int)png_get_image_height(png_ptr, png_info_ptr);
-
- if (xbb_output_mode == XBB_OUTPUT) {
- xppm = png_get_x_pixels_per_meter(png_ptr, png_info_ptr);
- yppm = png_get_y_pixels_per_meter(png_ptr, png_info_ptr);
- if (xppm > 0)
- *width = (int)(*width * 72.0 / 0.0254 / xppm + 0.5);
- if (yppm > 0)
- *height = (int)(*height * 72.0 / 0.0254 / yppm + 0.5);
- } else { /* EBB_OUTPUT */
- *width = (int)(*width * 72.0 / 100.0 + 0.5);
- *height = (int)(*height * 72.0 / 100.0 + 0.5);
- }
- return 0;
-}
static void do_png (FILE *fp, char *filename)
{
- int width, height;
+ long width, height;
+ double xdensity = 1.0, ydensity = 1.0;
- if (png_get_info(fp, &width, &height) < 0) {
- fprintf (stderr, "%s does not look like a PNG file...\n", filename);
+ if (png_get_bbox(fp, &width, &height, &xdensity, &ydensity) < 0) {
+ WARN("%s does not look like a PNG file...\n", filename);
return;
}
- write_xbb(filename, 0, 0, width, height);
+
+ if (xbb_output_mode == EBB_OUTPUT)
+ xdensity = ydensity = 72.0 / 100.0;
+
+ write_xbb(filename, 0, 0, xdensity*width, ydensity*height, -1, -1);
return;
}
+
#endif /* HAVE_LIBPNG */
static void do_pdf (FILE *fp, char *filename)
{
- pdf_obj *page, *trailer;
+ pdf_obj *page;
pdf_file *pf;
long page_no = 1;
- long count; /* dummy */
+ long count;
pdf_rect bbox;
pf = pdf_open(filename, fp);
@@ -312,9 +213,7 @@ static void do_pdf (FILE *fp, char *filename)
return;
}
- trailer = pdf_file_get_trailer(pf);
-
- page = pdf_doc_get_page(trailer, &page_no, &count, &bbox, NULL, NULL);
+ page = pdf_doc_get_page(pf, &page_no, &count, &bbox, NULL);
pdf_close(pf);
@@ -322,7 +221,8 @@ static void do_pdf (FILE *fp, char *filename)
return;
pdf_release_obj(page);
- write_xbb(filename, bbox.llx, bbox.lly, bbox.urx, bbox.ury);
+ write_xbb(filename, bbox.llx, bbox.lly, bbox.urx, bbox.ury,
+ pdf_file_get_version(pf), count);
}
int extractbb (int argc, char *argv[], int mode)
@@ -343,8 +243,8 @@ int extractbb (int argc, char *argv[], int mode)
while (argc > 0 && *argv[0] == '-') {
switch (*(argv[0]+1)) {
- case 'b':
- xbb_file_mode = FOPEN_WBIN_MODE;
+ case 'O':
+ xbb_to_file = 0;
argc -= 1; argv += 1;
break;
case 'm':
@@ -363,16 +263,29 @@ int extractbb (int argc, char *argv[], int mode)
usage();
argc -= 1; argv += 1;
break;
+ case 'q':
+ really_quiet = 1;
+ shut_up();
+ argc -= 1; argv += 1;
+ break;
+ case 'b':
+ if (mode == EBB_OUTPUT) {
+ /* ignore obsolete "binary mode" option */
+ argc -= 1; argv += 1;
+ break;
+ }
+ /* else fall through */
default:
usage();
}
}
+
for (; argc > 0; argc--, argv++) {
FILE *infile = NULL;
char *kpse_file_name;
if (!(kpse_file_name = kpse_find_pict(argv[0])) ||
(infile = MFOPEN(kpse_file_name, FOPEN_RBIN_MODE)) == NULL) {
- fprintf(stderr, "Can't find file (%s)...skipping\n", argv[0]);
+ WARN("Can't find file (%s)...skipping\n", argv[0]);
goto cont;
}
if (check_for_jpeg(infile)) {
@@ -389,7 +302,7 @@ int extractbb (int argc, char *argv[], int mode)
goto cont;
}
#endif /* HAVE_LIBPNG */
- fprintf(stderr, "Can't handle file type for file named %s\n", argv[0]);
+ WARN("Can't handle file type for file named %s\n", argv[0]);
cont:
if (kpse_file_name)
RELEASE(kpse_file_name);