Skip to content

Instantly share code, notes, and snippets.

@tenomoto
Created May 25, 2017 07:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tenomoto/bffd8896a1ec10205ec86aab01127327 to your computer and use it in GitHub Desktop.
Save tenomoto/bffd8896a1ec10205ec86aab01127327 to your computer and use it in GitHub Desktop.
Add page to PDF files and generate table of contents
#/bin/sh
in=$1
n=$2
sed -e "
s|N|${n}|
s|PDF|${in}|
" template.tex > foo.tex
pdflatex foo
BEGIN{FS=","}
{ printf("%s%s%s\n","\\includepdf[pages=-,pagecommand=\{\\thispagestyle\{plain\}\}]\{../pdf_out/",$1,"\}")}
#!/bin/sh
paste -d ',' pages.txt title-author.txt > agenda.txt
if [ ! -d toc ]; then
mkdir toc
fi
awk -f toc.awk agenda.txt > toc/toc.toc
if [ ! -d all ]; then
mkdir all
fi
awk -f all.awk agenda.txt > all/includepdf.tex
#!/bin/sh
if [ ! -d pdf_out ]; then
mkdir pdf_out
fi
n=1
for f in pdf/*.pdf; do
echo "${f#pdf/},${n}"
i=$(pdfinfo ${f} | awk -F ':' '$1 ~ "Pages" {print $2}')
./addpage.sh ${f} ${n}
n=`expr ${i} + ${n}`
mv -f foo.pdf pdf_out/${f#pdf/}
rm foo.*
done
#!/bin/sh
if [ ! -d pdf ]; then
echo "put PDF in pdf"
fi
if [ ! -d pdf_not_embedded ]; then
mkdir pdf_not_embedded
fi
cd pdf
for f in *.pdf; do
isEmb=`pdffonts ${f} | awk '$4=="no" {print "no"}'`
if [ "${isEmb}" ]; then
echo ${f}
mv ${f} ../pdf_not_embedded/
fi
done
cd ${OLDPWD}
%!TEX TS-program = pdflatex
\documentclass[11pt]{article}
\usepackage{pdfpages}
\begin{document}
\setcounter{page}{N}
\setlength{\footskip}{3cm}
\includepdf[pages=-,pagecommand={\thispagestyle{plain}}]{PDF}
\end{document}
BEGIN{FS=","}
{print "\\contentsline\{section\}\{"NR". "$3 "\\\\"$4 "\}\{"$2"\}"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment