Wojciech M. Zabołotny
2018-05-13 15:30:01 UTC
To prepare presentations in beamer, I often use IPE editor
( http://ipe.otfried.org ) to prepare animated (i.e., incrementally
displayed on subsequent slides) drawings.
IPE offers the "iperender" tool, that allows to export a single
"view". However I need an automatic tool, that is able
to export all the views in the separate files, located in another
directory. That allows me to use it in a Makefile used to convert
the figures, as shown below:
[...]
.ipe.pdf: *.ipe
ipescript expallviews $*.ipe ../figures_processed
[...]
If I have a figure "my_figure.ipe", that contains a few views in the
page 1, I can then include it in my presentation as shown below
\usepackage{xmpmulti}
\graphicspath{{./figures_processed/}}
[...]
\multiinclude[format=pdf,start=1,graphics={width=0.9\linewidth}]{my_figure-p-1-v}
The code is published as PUBLIC DOMAIN or under Creative Commons
CC0 license, whatever better suits your needs.
The code is published without any warranty. You use it on your own risk.
With best regards,
Wojtek
#!/bin/sh
# This is a shell archive (produced by GNU sharutils 4.15.2).
# To extract the files from this archive, save it to some FILE, remove
# everything before the '#!/bin/sh' line above, then type 'sh FILE'.
#
lock_dir=_sh05256
# Made on 2018-05-13 17:22 CEST by <***@wzab>.
# Source directory was '/tmp/eav'.
#
# Existing files will *not* be overwritten, unless '-c' is specified.
#
# This shar contains:
# length mode name
# ------ ---------- ------------------------------------------
# 1528 -rw-r--r-- expallviews.lua
#
MD5SUM=${MD5SUM-md5sum}
f=`${MD5SUM} --version | egrep '^md5sum .*(core|text)utils'`
test -n "${f}" && md5check=true || md5check=false
${md5check} || \
echo 'Note: not verifying md5sums. Consider installing GNU coreutils.'
if test "X$1" = "X-c"
then keep_file=''
else keep_file=true
fi
echo=echo
save_IFS="${IFS}"
IFS="${IFS}:"
gettext_dir=
locale_dir=
set_echo=false
for dir in $PATH
do
if test -f $dir/gettext \
&& ($dir/gettext --version >/dev/null 2>&1)
then
case `$dir/gettext --version 2>&1 | sed 1q` in
*GNU*) gettext_dir=$dir
set_echo=true
break ;;
esac
fi
done
if ${set_echo}
then
set_echo=false
for dir in $PATH
do
if test -f $dir/shar \
&& ($dir/shar --print-text-domain-dir >/dev/null 2>&1)
then
locale_dir=`$dir/shar --print-text-domain-dir`
set_echo=true
break
fi
done
if ${set_echo}
then
TEXTDOMAINDIR=$locale_dir
export TEXTDOMAINDIR
TEXTDOMAIN=sharutils
export TEXTDOMAIN
echo="$gettext_dir/gettext -s"
fi
fi
IFS="$save_IFS"
if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null
then if (echo -n test; echo 1,2,3) | grep n >/dev/null
then shar_n= shar_c='
'
else shar_n=-n shar_c= ; fi
else shar_n= shar_c='\c' ; fi
f=shar-touch.$$
st1=200112312359.59
st2=123123592001.59
st2tr=123123592001.5 # old SysV 14-char limit
st3=1231235901
if touch -am -t ${st1} ${f} >/dev/null 2>&1 && \
test ! -f ${st1} && test -f ${f}; then
shar_touch='touch -am -t $1$2$3$4$5$6.$7 "$8"'
elif touch -am ${st2} ${f} >/dev/null 2>&1 && \
test ! -f ${st2} && test ! -f ${st2tr} && test -f ${f}; then
shar_touch='touch -am $3$4$5$6$1$2.$7 "$8"'
elif touch -am ${st3} ${f} >/dev/null 2>&1 && \
test ! -f ${st3} && test -f ${f}; then
shar_touch='touch -am $3$4$5$6$2 "$8"'
else
shar_touch=:
echo
${echo} 'WARNING: not restoring timestamps. Consider getting and
installing GNU '\''touch'\'', distributed in GNU coreutils...'
echo
fi
rm -f ${st1} ${st2} ${st2tr} ${st3} ${f}
#
if test ! -d ${lock_dir} ; then :
else ${echo} "lock directory ${lock_dir} exists"
exit 1
fi
if mkdir ${lock_dir}
then ${echo} "x - created lock directory ${lock_dir}."
else ${echo} "x - failed to create lock directory ${lock_dir}."
exit 1
fi
# ============= expallviews.lua ==============
if test -n "${keep_file}" && test -f 'expallviews.lua'
then
${echo} "x - SKIPPING expallviews.lua (file already exists)"
else
${echo} "x - extracting expallviews.lua (text)"
sed 's/^X//' << 'SHAR_EOF' > 'expallviews.lua' &&
-- This is the script for exporting all views from all pages
-- in the IPE drawing.
-- I use it to export animated figures for beamer presentations.
-- Based on the information from
-- http://ipe.otfried.org/manual/luapage.html
-- This script was written by Wojciech M. Zabolotny
-- ( wzab01<at>gmail.com )
-- and is published as Public Domain or under
-- Creative Commons CC0 license, whatever better suits your needs.
--
-- Problems:
-- At the moment I can only epxort figures in PDF 1.4 format.
-- (iperender exports in PDF 1.5, but exportView in PDF 1.4)
if #argv ~= 2 then
X io.stderr:write("Usage: ipescript expallviews <inputfile> <outputdir>\n")
X return
end
fname=argv[1]
print(fname)
doc = ipe.Document(fname)
-- Prepare the base file name for the output files
-- Remove the directory part (if exists)
fbase=fname:reverse()
-- reverse the string. to make searching for last "/" and "." easier
i = fbase:find("/",1,"plain")
if (i) then
X fbase=fbase:sub(1,i-1)
end
i = fbase:find(".",1,"plain")
if (i) then
X fbase=fbase:sub(i+1)
end
fbase=fbase:reverse()
-- Add the output directory to the base filename
fbase=argv[2] .. "/" .. fbase
-- Now we can convert all the views from all pages
np=#doc
--print(fname .. " contains " .. np )
for p=1,np,1
do
X pg=doc[p]
X nv = pg:countViews()
X --print(fname .. " page " .. p .. " contains " .. nv .. " views")
X for v=1,nv,1
X do
X fout=fbase .. "-p-" .. p .. "-v-" .. v .. ".pdf"
X --print("exporting to: " .. fout)
X doc:exportView(fout,nil,nil,p,v)
X end
end
X
SHAR_EOF
(set 20 18 05 13 17 21 35 'expallviews.lua'
eval "${shar_touch}") && \
chmod 0644 'expallviews.lua'
if test $? -ne 0
then ${echo} "restore of expallviews.lua failed"
fi
if ${md5check}
then (
${MD5SUM} -c >/dev/null 2>&1 || ${echo} 'expallviews.lua': 'MD5 check failed'
) << \SHAR_EOF
e042b3f5eddd3df5d54c32e31eb36822 expallviews.lua
SHAR_EOF
else
test `LC_ALL=C wc -c < 'expallviews.lua'` -ne 1528 && \
${echo} "restoration warning: size of 'expallviews.lua' is not 1528"
fi
fi
if rm -fr ${lock_dir}
then ${echo} "x - removed lock directory ${lock_dir}."
else ${echo} "x - failed to remove lock directory ${lock_dir}."
exit 1
fi
exit 0
( http://ipe.otfried.org ) to prepare animated (i.e., incrementally
displayed on subsequent slides) drawings.
IPE offers the "iperender" tool, that allows to export a single
"view". However I need an automatic tool, that is able
to export all the views in the separate files, located in another
directory. That allows me to use it in a Makefile used to convert
the figures, as shown below:
[...]
.ipe.pdf: *.ipe
ipescript expallviews $*.ipe ../figures_processed
[...]
If I have a figure "my_figure.ipe", that contains a few views in the
page 1, I can then include it in my presentation as shown below
\usepackage{xmpmulti}
\graphicspath{{./figures_processed/}}
[...]
\multiinclude[format=pdf,start=1,graphics={width=0.9\linewidth}]{my_figure-p-1-v}
The code is published as PUBLIC DOMAIN or under Creative Commons
CC0 license, whatever better suits your needs.
The code is published without any warranty. You use it on your own risk.
With best regards,
Wojtek
#!/bin/sh
# This is a shell archive (produced by GNU sharutils 4.15.2).
# To extract the files from this archive, save it to some FILE, remove
# everything before the '#!/bin/sh' line above, then type 'sh FILE'.
#
lock_dir=_sh05256
# Made on 2018-05-13 17:22 CEST by <***@wzab>.
# Source directory was '/tmp/eav'.
#
# Existing files will *not* be overwritten, unless '-c' is specified.
#
# This shar contains:
# length mode name
# ------ ---------- ------------------------------------------
# 1528 -rw-r--r-- expallviews.lua
#
MD5SUM=${MD5SUM-md5sum}
f=`${MD5SUM} --version | egrep '^md5sum .*(core|text)utils'`
test -n "${f}" && md5check=true || md5check=false
${md5check} || \
echo 'Note: not verifying md5sums. Consider installing GNU coreutils.'
if test "X$1" = "X-c"
then keep_file=''
else keep_file=true
fi
echo=echo
save_IFS="${IFS}"
IFS="${IFS}:"
gettext_dir=
locale_dir=
set_echo=false
for dir in $PATH
do
if test -f $dir/gettext \
&& ($dir/gettext --version >/dev/null 2>&1)
then
case `$dir/gettext --version 2>&1 | sed 1q` in
*GNU*) gettext_dir=$dir
set_echo=true
break ;;
esac
fi
done
if ${set_echo}
then
set_echo=false
for dir in $PATH
do
if test -f $dir/shar \
&& ($dir/shar --print-text-domain-dir >/dev/null 2>&1)
then
locale_dir=`$dir/shar --print-text-domain-dir`
set_echo=true
break
fi
done
if ${set_echo}
then
TEXTDOMAINDIR=$locale_dir
export TEXTDOMAINDIR
TEXTDOMAIN=sharutils
export TEXTDOMAIN
echo="$gettext_dir/gettext -s"
fi
fi
IFS="$save_IFS"
if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null
then if (echo -n test; echo 1,2,3) | grep n >/dev/null
then shar_n= shar_c='
'
else shar_n=-n shar_c= ; fi
else shar_n= shar_c='\c' ; fi
f=shar-touch.$$
st1=200112312359.59
st2=123123592001.59
st2tr=123123592001.5 # old SysV 14-char limit
st3=1231235901
if touch -am -t ${st1} ${f} >/dev/null 2>&1 && \
test ! -f ${st1} && test -f ${f}; then
shar_touch='touch -am -t $1$2$3$4$5$6.$7 "$8"'
elif touch -am ${st2} ${f} >/dev/null 2>&1 && \
test ! -f ${st2} && test ! -f ${st2tr} && test -f ${f}; then
shar_touch='touch -am $3$4$5$6$1$2.$7 "$8"'
elif touch -am ${st3} ${f} >/dev/null 2>&1 && \
test ! -f ${st3} && test -f ${f}; then
shar_touch='touch -am $3$4$5$6$2 "$8"'
else
shar_touch=:
echo
${echo} 'WARNING: not restoring timestamps. Consider getting and
installing GNU '\''touch'\'', distributed in GNU coreutils...'
echo
fi
rm -f ${st1} ${st2} ${st2tr} ${st3} ${f}
#
if test ! -d ${lock_dir} ; then :
else ${echo} "lock directory ${lock_dir} exists"
exit 1
fi
if mkdir ${lock_dir}
then ${echo} "x - created lock directory ${lock_dir}."
else ${echo} "x - failed to create lock directory ${lock_dir}."
exit 1
fi
# ============= expallviews.lua ==============
if test -n "${keep_file}" && test -f 'expallviews.lua'
then
${echo} "x - SKIPPING expallviews.lua (file already exists)"
else
${echo} "x - extracting expallviews.lua (text)"
sed 's/^X//' << 'SHAR_EOF' > 'expallviews.lua' &&
-- This is the script for exporting all views from all pages
-- in the IPE drawing.
-- I use it to export animated figures for beamer presentations.
-- Based on the information from
-- http://ipe.otfried.org/manual/luapage.html
-- This script was written by Wojciech M. Zabolotny
-- ( wzab01<at>gmail.com )
-- and is published as Public Domain or under
-- Creative Commons CC0 license, whatever better suits your needs.
--
-- Problems:
-- At the moment I can only epxort figures in PDF 1.4 format.
-- (iperender exports in PDF 1.5, but exportView in PDF 1.4)
if #argv ~= 2 then
X io.stderr:write("Usage: ipescript expallviews <inputfile> <outputdir>\n")
X return
end
fname=argv[1]
print(fname)
doc = ipe.Document(fname)
-- Prepare the base file name for the output files
-- Remove the directory part (if exists)
fbase=fname:reverse()
-- reverse the string. to make searching for last "/" and "." easier
i = fbase:find("/",1,"plain")
if (i) then
X fbase=fbase:sub(1,i-1)
end
i = fbase:find(".",1,"plain")
if (i) then
X fbase=fbase:sub(i+1)
end
fbase=fbase:reverse()
-- Add the output directory to the base filename
fbase=argv[2] .. "/" .. fbase
-- Now we can convert all the views from all pages
np=#doc
--print(fname .. " contains " .. np )
for p=1,np,1
do
X pg=doc[p]
X nv = pg:countViews()
X --print(fname .. " page " .. p .. " contains " .. nv .. " views")
X for v=1,nv,1
X do
X fout=fbase .. "-p-" .. p .. "-v-" .. v .. ".pdf"
X --print("exporting to: " .. fout)
X doc:exportView(fout,nil,nil,p,v)
X end
end
X
SHAR_EOF
(set 20 18 05 13 17 21 35 'expallviews.lua'
eval "${shar_touch}") && \
chmod 0644 'expallviews.lua'
if test $? -ne 0
then ${echo} "restore of expallviews.lua failed"
fi
if ${md5check}
then (
${MD5SUM} -c >/dev/null 2>&1 || ${echo} 'expallviews.lua': 'MD5 check failed'
) << \SHAR_EOF
e042b3f5eddd3df5d54c32e31eb36822 expallviews.lua
SHAR_EOF
else
test `LC_ALL=C wc -c < 'expallviews.lua'` -ne 1528 && \
${echo} "restoration warning: size of 'expallviews.lua' is not 1528"
fi
fi
if rm -fr ${lock_dir}
then ${echo} "x - removed lock directory ${lock_dir}."
else ${echo} "x - failed to remove lock directory ${lock_dir}."
exit 1
fi
exit 0