diff options
author | Siep Kroonenberg <siepo@cybercomm.nl> | 2016-05-06 12:21:28 +0000 |
---|---|---|
committer | Siep Kroonenberg <siepo@cybercomm.nl> | 2016-05-06 12:21:28 +0000 |
commit | 46b1c1b4d581fcb533618024c84361a3f1847daa (patch) | |
tree | 711a5a80b710d3d21c0d669b351d066757f3495d /Master/texmf-dist/scripts/epspdf | |
parent | 34f25ba917e3cbf44054fa84bbd0ab97b1ffc843 (diff) |
epspdf 0.6.3 compatibility fixes for luatex 0.95
git-svn-id: svn://tug.org/texlive/trunk@40917 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/scripts/epspdf')
-rw-r--r-- | Master/texmf-dist/scripts/epspdf/epspdf.help | 30 | ||||
-rwxr-xr-x | Master/texmf-dist/scripts/epspdf/epspdf.tlu | 283 | ||||
-rwxr-xr-x | Master/texmf-dist/scripts/epspdf/epspdftk.tcl | 13 |
3 files changed, 133 insertions, 193 deletions
diff --git a/Master/texmf-dist/scripts/epspdf/epspdf.help b/Master/texmf-dist/scripts/epspdf/epspdf.help index d7653c13576..60987a216d0 100644 --- a/Master/texmf-dist/scripts/epspdf/epspdf.help +++ b/Master/texmf-dist/scripts/epspdf/epspdf.help @@ -1,4 +1,4 @@ -Epspdf and epsdftk +Epspdf and epspdftk 1 Usage 1.1 Overview 1.2 Viewing @@ -33,12 +33,12 @@ Epspdf and epsdftk 6.1 Version 0.6 6.2 Version 0.5 6.3 Version 0.4 -Epspdf and epsdftk -****************** +Epspdf and epspdftk +******************* -This manual is for epspdf, version 0.6.2. +This manual is for epspdf, version 0.6.3. -Copyright (C) 2006, 2008, 2009, 2010, 2011, 2013, 2014, 2015 Siep +Copyright (C) 2006, 2008, 2009, 2010, 2011, 2013, 2014, 2015, 2016 Siep Kroonenberg. Copying and distribution of this file, with or without @@ -153,8 +153,8 @@ shapes or little bitmaps, so use pdftops if available. With newer Ghostscript versions, with an eps2write rather than an epswrite output device, Ghostscript does a much better job. -Under MikTeX, this is also the place to point the program to the -location of pdftops.exe. +Under an older MikTeX without bundled pdftops, this is also the place to +point the program to the location of pdftops.exe. 2 Command-line usage ******************** @@ -179,8 +179,8 @@ Basic usage of epspdf itself: Typing 'epspdf --help' gives you the following summary: $ epspdf --help - Epspdf version 0.6.2 - Copyright (c) 2006, 2008, 2009, 2010, 2011, 2013, 2014, 2015 Siep Kroonenberg + Epspdf version 0.6.3 + Copyright (c) 2006, 2008, 2009, 2010, 2011, 2013, 2014, 2015, 2016 Siep Kroonenberg Convert between [e]ps and pdf formats Usage: epspdf[.tlu] [options] infile [outfile] @@ -325,8 +325,9 @@ excellent alternative to epspdf. 4.3 Windows =========== -Windows is not a particularly friendly environment for PostScript or -pdf. A couple of command-line utilities try to fill the gap, _e.g._ +I know of no built-in facility for converting bitmaps to eps or pdf. +However, many image editors can convert to eps or pdf. A couple of +command-line utilities: sam2p image.png image.eps or bmeps -c image.png image.eps @@ -397,9 +398,10 @@ Logfile. The GUI has a button for viewing log output. This same output is also written to a file 'epspdf.log'. For Linux/Unix/Mac OS X this is in a subdirectory .epspdf of your home directory; for Windows it is in a subdirectory epspdf of '%APPDATA%'. This APPDATA directory may be -'c:\Documents and Settings\YOUR USER NAME\Application Data' or -'c:\Users\YOUR USER NAME\AppData\Roaming'. Type 'echo %APPDATA%' to -find out which. +'c:\Users\YOUR USER NAME\AppData\Roaming' or 'c:\Documents and +Settings\YOUR USER NAME\Application Data'. Type + echo %APPDATA% +in a Command Prompt window to find out which. The logfile lists all epspdf calls and all Ghostscript- and pdftops calls plus error information. diff --git a/Master/texmf-dist/scripts/epspdf/epspdf.tlu b/Master/texmf-dist/scripts/epspdf/epspdf.tlu index 7a7c2d78a97..709a2d9b691 100755 --- a/Master/texmf-dist/scripts/epspdf/epspdf.tlu +++ b/Master/texmf-dist/scripts/epspdf/epspdf.tlu @@ -7,9 +7,10 @@ kpse.set_program_name('texlua') -- 0.6.0: first texlua version -- 0.6.1: allow TeX installation on path with spaces -- 0.6.2: compatibility fix for luatex 0.81 +-- 0.6.3: compatibility fixes for luatex 0.9x -ep_version = '0.6.2' -ep_copyright = '2006, 2008, 2009, 2010, 2011, 2013, 2014, 2015' +ep_version = '0.6.3' +ep_copyright = '2006, 2008, 2009, 2010, 2011, 2013, 2014, 2015, 2016' --[[ @@ -58,15 +59,6 @@ POSSIBLE EXTENSIONS -- some general utilities and globals --------------------------- ---[[ - -Simple-minded error handling. At most, we call a function which -tries to write the error message to log before re-raising the error. - -When run from the Tcl/Tk gui, this gui will capture error messages. - ---]] - -- early initializations eol = false @@ -88,9 +80,12 @@ from_gui = false -- whether epspdf is run from the epspsdtk gui cwd = '' --- Windows: miktex, TL or neither +-- Windows: miktex, TL or neither. +-- Actual values determined during system-dependent initialization is_miktex = false is_tl_w32 = false +-- recent versions of miktex include pdftops +auto_psp = true -- configuration of pdftops_prog not needed or not allowed -- some global file- and directory names gs_prog = false @@ -128,6 +123,7 @@ function print_log(s) print(s) -- intercepted by the gui end end + function write_log(s) print_log(string.format('%s %s', os.date('%Y/%m/%d %H:%M:%S', os.time()), s)) @@ -139,6 +135,11 @@ end -- error- and debug ------------------------- +-- Simple-minded error handling. At most, we call a function which +-- tries to write the error message to log before re-raising the error. + +-- When run from the Tcl/Tk gui, this gui will capture error messages. + function errror(mess) if logfile then pcall(write_log, mess) end -- ignore result of pcall: we can do nothing about failure @@ -598,8 +599,8 @@ function write_settings (file) end else -- stdout to be captured by epspdftk f = io.output() - if os.type=='windows' and not is_tl_w32 then - f:write('tl_w = no', eol) + if os.type=='windows' and not auto_psp then + f:write('psp_config = yes', eol) end end for k, v in pairs(settings) do @@ -732,7 +733,7 @@ end -- boundingboxes --------------------------------------------------- --- Bb.coords names now same as those of epdf PDFRectangle +-- [HR]Bb.coords names now same as those of epdf PDFRectangle Bb = {} Bb.coords = {'x1', 'y1', 'x2', 'y2'} @@ -777,7 +778,7 @@ function Bb:from_comment(s) return Bb:from_rect(b) end ---[[ +--[[ some no-longer-used bbox functions function Bb:copy () local b = {} @@ -807,7 +808,7 @@ function Bb:expand () end end --- no longer used: gs handles this +-- gs handles this now -- call this via pcall function Bb:wrapper() local fn = mktemp('ps') @@ -1424,7 +1425,7 @@ function PsPdf:eps_crop() return psp end -- eps_crop ---[===[ real conversions involving a single call of gs or pdftops -------- +--[===[ real conversions involving a single call of gs, pdftops or texlua Each conversion fullfills all options that it can: gray, bbox and page. gray when converting to pdf, bbox when converting from eps or @@ -1458,38 +1459,43 @@ function PsPdf:pdf_crop() errror('PsPdf:pdf_crop called with non-existent page '.. options.page) end local pg = options.page or 1 - local bb, hrbb - if options.bbox then - bb, hrbb = self:bb_from_gs(pg) - else - -- dbg('about to use epdf') - -- use [Trim|Crop|Media]Box instead - -- if os.type=='windows' then waitasec() end - local dummy = epdf.open(self.path) - -- if os.type=='windows' then waitasec() end - if not dummy then + local bb, hrbb, pgbox, pgboxname + do + local pdoc, pcat, ppage + -- we already have the pages, miver and maver properties + -- but need properties of the desired page as well + pdoc = epdf.open(self.path) + if not pdoc then errror('Epdf: cannot open '..self.path) end -- dbg('about to get catalog') - dummy = dummy:getCatalog() - if not dummy then + pcat = pdoc:getCatalog() + if not pcat then errror('Cannot open catalog of '..self.path) end -- dbg('got catalog') - dummy = dummy:getPage(pg) - if not dummy then + ppage = pcat:getPage(pg) + if not ppage then errror('Epdf: cannot open page object '..tostring(pg)..' of '..self.path) end - hrbb = dummy:getTrimBox() - if not hrbb then - hrbb = dummy:getCropBox() + pgboxname = 'trimbox' + pgbox = ppage:getTrimBox() + if not pgbox then + pgboxname = 'cropbox' + pgbox = ppage:getCropBox() end - if not hrbb then - hrbb = dummy:getMediaBox() + if not pgbox then + pgboxname = 'mediabox' + pgbox = ppage:getMediaBox() end - -- further checks, including for non-nil, by Bb:from_rect, - -- which errors out on failures - hrbb = HRBb:from_rect(hrbb) + -- normalization and further checks, including for non-nil, + -- by Bb:from_rect, which errors out on failures + pgbox = HRBb:from_rect(pgbox) + end + if options.bbox then + bb, hrbb = self:bb_from_gs(pg) + else + hrbb = pgbox end -- luatex on searchpath @@ -1497,115 +1503,53 @@ function PsPdf:pdf_crop() -- write TeX file which includes cropped pdf page -- adapted from Heiko Oberdiek's pdfcrop utility. - -- first, create a table with the component strings for the tex source - dummy = {} - dummy[1] = [[ -\catcode37 14 % percent -\catcode33 12 % exclam -\catcode34 12 % quote -\catcode35 6 % hash -\catcode39 12 % apostrophe -\catcode40 12 % left parenthesis -\catcode41 12 % right parenthesis -\catcode45 12 % minus -\catcode46 12 % period -\catcode60 12 % less -\catcode61 12 % equals -\catcode62 12 % greater -\catcode64 12 % at -\catcode91 12 % left square -\catcode93 12 % right square -\catcode96 12 % back tick -\catcode123 1 % left curly brace -\catcode125 2 % right curly brace -\catcode126 12 % tilde -\catcode`\#=6 % -\escapechar=92 % -\def\IfUndefined#1#2#3{% - \begingroup\expandafter\expandafter\expandafter\endgroup - \expandafter\ifx\csname#1\endcsname\relax - #2% - \else - #3% - \fi -} - -% future modification: \pdfoutput => \outputmode -\begingroup\expandafter\expandafter\expandafter\endgroup - \expandafter\ifx\csname pdfoutput\endcsname\relax - \let\pdfoutput \outputmode -\fi - -\begingroup - \newlinechar=10 % - \endlinechar=\newlinechar % - \ifnum0% - \directlua{% - if tex.enableprimitives then - tex.enableprimitives('TEST', { - 'luatexversion', - 'pdfoutput', - 'pdfcompresslevel', - 'pdfhorigin', - 'pdfvorigin', - 'pagewidth', - 'pageheight', - 'pdfmapfile', - 'pdfximage', - 'pdflastximage', - 'pdfrefximage', - 'pdfminorversion', - 'pdfobjcompresslevel', - }) - tex.print('1') - end - }% - \ifx\TESTluatexversion\UnDeFiNeD\else 1\fi % - =11 % - \global\let\luatexversion\luatexversion % - \global\let\pdfoutput\TESTpdfoutput % - \global\let\pdfcompresslevel\TESTpdfcompresslevel % - \global\let\pdfhorigin\TESTpdfhorigin % - \global\let\pdfvorigin\TESTpdfvorigin % - \global\let\pagewidth\TESTpagewidth % - \global\let\pageheight\TESTpageheight % - \global\let\pdfmapfile\TESTpdfmapfile % - \global\let\pdfximage\TESTpdfximage % - \global\let\pdflastximage\TESTpdflastximage % - \global\let\pdfrefximage\TESTpdfrefximage % - \global\let\pdfminorversion\TESTpdfminorversion % - \global\let\pdfobjcompresslevel\TESTpdfobjcompresslevel % - \else % - \errmessage{% - Missing \string\luatexversion % - }% - \fi % -\endgroup % - -\pdfoutput=1 % -\pdfcompresslevel=9 % -\csname pdfmapfile\endcsname{} -\def\setpdfversion#1#2{% - \ifnum#2>1 % - \pdfobjcompresslevel=2 % - % including unsupported pdf version! - \pdfinclusionerrorlevel=0 - \pdfminorversion=9\relax - \else - \ifnum#1>4 % - \pdfobjcompresslevel=2 % - \else - \pdfobjcompresslevel=0 % - \fi - \pdfminorversion=#1\relax - \fi -} + -- the table `pieces' will contain the component strings for the tex source + -- first, for texlua <= 0.81 + local pieces = {} + if status.luatex_version <= 80 then + pieces[1] = '\\pdfoutput=1\n' + else + pieces[1] = [[ +\edef\pdfminorversion {\pdfvariable minorversion} +\edef\pdfcompresslevel {\pdfvariable compresslevel} +\edef\pdfobjcompresslevel {\pdfvariable objcompresslevel} +\edef\pdfdecimaldigits {\pdfvariable decimaldigits} +\edef\pdfhorigin {\pdfvariable horigin} +\edef\pdfvorigin {\pdfvariable vorigin} +\let\pdfpagewidth\pagewidth +\let\pdfpageheight\pageheight +\let\pdfximage\saveimageresource +\let\pdfrefximage\useimageresource +\let\pdflastximage\lastsavedimageresourceindex + +\outputmode=1 +]] + end + if self.maver > 1 then + pieces[2] = '\\pdfminorversion=9\n' + else + pieces[2] = '\\pdfminorversion=' .. self.miver .. '\n' + end + if self.maver > 1 or self.miver > 4 then + pieces[3] = [[ +\pdfcompresslevel=9 +\pdfobjcompresslevel=2 +\pdfdecimaldigits=4 +]] + else + pieces[3] = [[ +\pdfcompresslevel=9 +\pdfobjcompresslevel=0 +\pdfdecimaldigits=4 +]] + end + pieces[4] = [[ \def\page #1 [#2 #3 #4 #5]{% \count0=#1\relax \setbox0=\hbox{% \pdfximage page #1 mediabox{]] - dummy[2] = self.path - dummy[3] = [[}% + pieces[5] = self.path + pieces[6] = [[}% \pdfrefximage\pdflastximage }% \pdfhorigin=-#2bp\relax @@ -1618,33 +1562,19 @@ function PsPdf:pdf_crop() \shipout\box0\relax } ]] - -- pdf minor version to write to tex header - local tex_miver = false - if settings.pdf_version=='default' then - tex_miver = self.miver - else - -- in this case, gs should already have converted to - -- a sufficiently low version - tex_miver = tonumber(settings.pdf_version) - if tex_miver>self.miver then - errror('Pdf_crop: forgot to reduce pdf version') - end - end - dummy[4] = string.format([[ -\setpdfversion{%d}{%d} + pieces[7] = string.format([[ \page %d [%f %f %f %f] \csname @@end\endcsname \end ]], - tex_miver, self.maver, options.page or 1, - hrbb.x1, hrbb.y1, hrbb.x2, hrbb.y2) + options.page or 1, hrbb.x1, hrbb.y1, hrbb.x2, hrbb.y2) - local textemp = mktemp('tex') -- this also takes care of pdf: + local textemp = mktemp('tex') -- this also took care of pdf: local pdftemp = string.gsub(textemp, 'tex$', 'pdf') -- if os.type=='windows' then waitasec() end local f = io.open(textemp, 'w') -- if os.type=='windows' then waitasec() end - f:write(table.concat(dummy, '')) + f:write(table.concat(pieces, '')) f:close() local cmd, res, psp if os.type=='unix' then @@ -2137,10 +2067,12 @@ if os.type == 'windows' then cwd = string.gsub(cwd, '\\', '/') end -- prepend (lua)tex directory to searchpath, if not already there maybe_add_path(os.selfdir, false) --- Windows: miktex, TL or neither +-- Windows: miktex, TL or neither. is_miktex, is_tl_w32, auto_psp -- no support yet for separate ghostscript is_miktex = false is_tl_w32 = false +auto_psp = true -- only false for old miktex without included pdftops + if os.type == 'windows' then if string.find (string.lower(kpse.version()), 'miktex') then is_miktex = true @@ -2164,6 +2096,10 @@ if os.type == 'windows' then '/release-texlive.txt; TeX installation not supported.', 0) end -- if isfile end -- if not miktex + -- recent miktex and any windows tl include pdftops + if not lfs.isfile(string.gsub(os.selfdir, '\\', '/') .. '/pdftops.exe') then + auto_psp = false + end end -- if windows -- without Ghostscript we are dead in the water. @@ -2275,7 +2211,8 @@ settings.use_hires_bb = false -- it will not be used for TeX Live and only be read and written on Windows. settings.pdftops_prog = false -descriptions.pdftops_prog = 'Full path to pdftops.exe (not used with TeX Live)' +descriptions.pdftops_prog = + 'Full path to pdftops.exe (not used if TeX bin dir contains pdftops)' settings.use_pdftops = true descriptions.use_pdftops = 'Use pdftops if available' @@ -2408,7 +2345,7 @@ do -- main program help = descriptions.pdf_version } - if os.type=='windows' and not is_tl_w32 then + if os.type=='windows' and not auto_psp then opts.pdftops_prog = { type = 'string', val = nil, forms = {'--pdftops'}, @@ -2497,7 +2434,7 @@ do -- main program 'pdftops_prog', 'use_pdftops', 'save', 'info', 'debug', 'version', 'help'}) do local v = opts[o] - if v~='pdftops_prog' or is_miktex then + if v~='pdftops_prog' or not auto_psp then if v and v.help then local synt = join(v.forms, ', ') if v.type ~= 'boolean' then synt = synt .. ' ' .. v.placeholder end @@ -2518,7 +2455,7 @@ do -- main program end end end - end -- ~=pdftops_prog or is_miktex + end -- ~=pdftops_prog or not auto_psp end -- for if mess then os.exit(1) else os.exit() end end -- help @@ -2660,13 +2597,13 @@ do -- main program -- pdftops program; pdftops has already been been initialized to false -- pdftops_prog as command-line option - if os.type=='windows' and not is_tl_w32 and opts.pdftops_prog.val then + if os.type=='windows' and not auto_psp and + opts.pdftops_prog.val then settings.pdftops_prog = is_prog(opts.pdftops_prog.val) end - -- pdftops should be on the path. - -- for miktex, make it so if possible. - if os.type=='windows' and not is_tl_w32 then + -- pdftops should be on the path. otherwise, make it so if possible. + if os.type=='windows' and not auto_psp then if settings.use_pdftops then pdftops = is_prog(settings.pdftops_prog) if pdftops then @@ -2700,7 +2637,7 @@ do -- main program help() end - -- opts.info.val: need to get infile first + -- opts.info.val: do later; need to get infile first if opts.version.val then show_version() diff --git a/Master/texmf-dist/scripts/epspdf/epspdftk.tcl b/Master/texmf-dist/scripts/epspdf/epspdftk.tcl index e28118853f3..7e4a7bc4c3c 100755 --- a/Master/texmf-dist/scripts/epspdf/epspdftk.tcl +++ b/Master/texmf-dist/scripts/epspdf/epspdftk.tcl @@ -3,7 +3,7 @@ # epspdf conversion utility, GUI frontend ##### -# Copyright (C) 2006, 2008, 2009, 2010, 2011, 2013, 2014, 2015 Siep Kroonenberg +# Copyright (C) 2006, 2008, 2009, 2010, 2011, 2013, 2014, 2015, 2016 Siep Kroonenberg # n dot s dot kroonenberg at rug dot nl # # This program is free software, licensed under the GNU GPL, >=2.0. @@ -95,7 +95,8 @@ proc is_prog {x} { # create a global empty settings array array set ::settings [list] -set ::is_tl 1 +# windows: pdftops from tex distro? +set ::psp_config 0 # ask epspdf.tlu for currently configured settings. # this does not include automatically configured or transient settings. @@ -107,7 +108,7 @@ proc getsettings {} { # write_log "settings from epspdf.tlu:\n$set_str\n" set l [split $set_str "\r\n"] if {$::tcl_platform(platform) eq "windows"} { - set ::is_tl 1 + set ::psp_config 0 set settings(pdftops_prog) "" } foreach e $l { @@ -121,8 +122,8 @@ proc getsettings {} { set val [string trim [string range $e [expr $i+1] end]] if {$val eq "true"} {set val 1} if {$val eq "false"} {set val 0} - if {$para eq "tl_w"} { - set ::is_tl 0 + if {$para eq "psp_config"} { + set ::psp_config 1 write_log "TL for Windows not detected by epspdf" } else { set ::settings($para) $val @@ -503,7 +504,7 @@ spacing .config_t packf [frame .config_t.psf] -ipadx 4 -fill x pack [label .config_t.psf.l_ps -text "Conversion to EPS and PostScript" \ -font boldfont] -anchor w -if {! $::is_tl} { +if { $::psp_config} { if {[string tolower [string range $::settings(pdftops_prog) end-3 end]] ne \ ".exe"} {set ::settings(pdftops_prog) ""} pack [label .config_t.psf.l_pdftops -text "Find pdftops"] -anchor w |