summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/scripts/pfarrei
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2013-03-11 23:37:16 +0000
committerKarl Berry <karl@freefriends.org>2013-03-11 23:37:16 +0000
commitba010cadf18382da1fa1ad0567552261171c4c63 (patch)
tree5ca8649dcec7199d091f73831a747c6f1bdb4db2 /Master/texmf-dist/scripts/pfarrei
parent6dbb8dfbb59d7e98e7addb0feae7ff9306c49b0e (diff)
pfarrei (11mar13)
git-svn-id: svn://tug.org/texlive/trunk@29348 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/scripts/pfarrei')
-rwxr-xr-xMaster/texmf-dist/scripts/pfarrei/a5toa4.tlu37
-rwxr-xr-xMaster/texmf-dist/scripts/pfarrei/pfarrei.tlu144
2 files changed, 181 insertions, 0 deletions
diff --git a/Master/texmf-dist/scripts/pfarrei/a5toa4.tlu b/Master/texmf-dist/scripts/pfarrei/a5toa4.tlu
new file mode 100755
index 00000000000..25c7de5986e
--- /dev/null
+++ b/Master/texmf-dist/scripts/pfarrei/a5toa4.tlu
@@ -0,0 +1,37 @@
+#!/usr/bin/env texlua
+
+--
+-- This is file `a5toa4.tlu',
+-- generated with the docstrip utility.
+--
+-- The original source files were:
+--
+-- pfarrei.dtx (with options: `a5toa4,lua')
+--
+-- Copyright (c) 2013 Markus Kohm
+-- komascript at gmx info
+--
+-- This file was generated from file(s) of the work `pfarrei'.
+-- ------------------------------------------------------------------
+--
+-- It may be distributed under the conditions of the
+-- LaTeX Project Public License in the version distributed together
+-- with the work `pfarrei'. You may however distribute the work
+-- `pfarrei' without all such generated files. See also
+-- <http://www.latex-project.org/lppl.txt> for additional
+-- information.
+--
+-- This work has the LPPL maintenance status `maintained'.
+--
+-- The Current Maintainer of this work is Markus Kohm.
+--
+-- The list of files belonging to the work `pfarrei' is given in
+-- the file `pfarrei.dtx'.
+--
+-- $Id: pfarrei.dtx 20 2013-03-10 14:19:06Z mjk $
+
+kpse.set_program_name(arg[-1], 'a5toa4')
+require('pfarrei')
+--
+--
+-- End of file `a5toa4.tlu'.
diff --git a/Master/texmf-dist/scripts/pfarrei/pfarrei.tlu b/Master/texmf-dist/scripts/pfarrei/pfarrei.tlu
new file mode 100755
index 00000000000..ee5f0ed8d67
--- /dev/null
+++ b/Master/texmf-dist/scripts/pfarrei/pfarrei.tlu
@@ -0,0 +1,144 @@
+#!/usr/bin/env texlua
+
+--
+-- This is file `pfarrei.tlu',
+-- generated with the docstrip utility.
+--
+-- The original source files were:
+--
+-- pfarrei.dtx (with options: `pfarrei,lua')
+--
+-- Copyright (c) 2013 Markus Kohm
+-- komascript at gmx info
+--
+-- This file was generated from file(s) of the work `pfarrei'.
+-- ------------------------------------------------------------------
+--
+-- It may be distributed under the conditions of the
+-- LaTeX Project Public License in the version distributed together
+-- with the work `pfarrei'. You may however distribute the work
+-- `pfarrei' without all such generated files. See also
+-- <http://www.latex-project.org/lppl.txt> for additional
+-- information.
+--
+-- This work has the LPPL maintenance status `maintained'.
+--
+-- The Current Maintainer of this work is Markus Kohm.
+--
+-- The list of files belonging to the work `pfarrei' is given in
+-- the file `pfarrei.dtx'.
+--
+local version_number = string.sub( '$Revision: 20 $', 12, -2 )
+local action_version = ' r' .. version_number .. '\n' .. [[
+
+Copyright (c) 2013 Markus Kohm.
+License: lppl 1.3c or later. See <http://www.latex-project.org/lppl.txt>.
+]]
+local action_help = [[
+action options:
+
+ -h, --help Print this help message.
+ -V, --version Print the version information.
+
+processing options:
+ -b, --booklet Generate a booklet instead of only two pages side by
+ side onto one page. The whole booklet will be one
+ signature.
+ -s, --sidebyside Generate only two pages side by side onto one page
+ instead of a booklet.
+ -o, --overwrite Write the output to the <PDF file> instead of appending
+ "-sidebyside.pdf" or "--booklet.pdf" to the basename
+ of <PDF file>
+]]
+local action_opts = {
+ ['-h'] = 'help',
+ ['--help'] = 'help',
+ ['-V'] = 'version',
+ ['--version'] = 'version',
+}
+local processing_opts = {
+ ['-b'] = 'booklet',
+ ['--booklet'] = 'booklet',
+ ['-s'] = 'sidebyside',
+ ['--sidebyside'] = 'sidebyside',
+ ['-o'] = 'overwrite',
+ ['--overwrite'] = 'overwrite'
+}
+
+-- detect action options and do action
+local i = 1
+local action
+while arg[i] do
+ action = action_opts[arg[i]]
+ i = i+1
+ if action == 'help' then
+ print( arg[0]..action_version );
+ print( 'Usage: ' .. arg[0] .. ' <action option>' )
+ print( ' ' .. arg[0] .. ' [<processing options>] <PDF file> ...\n' )
+ print( action_help );
+ os.exit( 0 );
+ elseif action == 'version' then
+ print( arg[0] .. action_version );
+ os.exit( 0 );
+ end
+end
+
+-- process options and parameters
+local booklet = false
+local overwrite = false
+i = 1
+while arg[i] do
+ action = processing_opts[arg[i]]
+ if action == 'booklet' then booklet = true
+ elseif action == 'sidebyside' then booklet = false
+ elseif action == 'overwrite' then overwrite = true
+ elseif action == nil then
+ -- build the temporary tex file
+ local tmpdir = os.tmpdir("pfarrei.XXXXXX" )
+ local tmpfile = string.match( arg[i], '.*/(.*)$') or arg[i]
+ local basename = string.match( tmpfile,'(.*)%.[^.]*$') or tmpfile
+ tmpfile = tmpdir..'/'..basename..'.tex'
+ local file = assert( io.open( tmpfile, 'w' ) )
+ if booklet then assert( file:write("\\def\\Booklet{}\n") ) end
+ assert( file:write("\\def\\OriginalFile{",arg[i],"}\n") )
+ assert( file:write("\\input{a5toa4.tex}\n") )
+ assert( file:flush() )
+ file:close()
+ -- call pdflatex
+ assert( os.execute( 'pdflatex -interaction=batchmode -output-directory='..tmpdir..' '..tmpfile ) )
+ -- copy the resulting pdf file
+ local srcfile = assert( io.open( tmpdir..'/'..basename..'.pdf', 'rb' ) )
+ if overwrite
+ then
+ tmpfile = arg[i]
+ else
+ tmpfile = string.match( arg[i], '(.*)%.[^.]*$' ) or arg[i]
+ if booklet
+ then
+ tmpfile = tmpfile..'-booklet.pdf'
+ else
+ tmpfile = tmpfile..'-sidebyside.pdf'
+ end
+ end
+ local destfile = assert( io.open( tmpfile, 'wb' ) )
+ local buffer
+ while true do
+ buffer = srcfile:read(8388608)
+ if buffer==nil then break end
+ assert( destfile:write(buffer) )
+ end
+ assert( destfile:close() )
+ srcfile:close()
+ tmpfile=tmpdir..'/'..basename
+ os.remove( tmpfile..'.aux' )
+ os.remove( tmpfile..'.tex' )
+ os.remove( tmpfile..'.log' )
+ os.remove( tmpfile..'.pdf' )
+ os.remove( tmpdir )
+ overwrite = false
+ end
+ i=i+1
+end
+--
+--
+-- End of file `pfarrei.tlu'.