Created
May 25, 2017 07:39
-
-
Save tenomoto/bffd8896a1ec10205ec86aab01127327 to your computer and use it in GitHub Desktop.
Add page to PDF files and generate table of contents
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/bin/sh | |
in=$1 | |
n=$2 | |
sed -e " | |
s|N|${n}| | |
s|PDF|${in}| | |
" template.tex > foo.tex | |
pdflatex foo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BEGIN{FS=","} | |
{ printf("%s%s%s\n","\\includepdf[pages=-,pagecommand=\{\\thispagestyle\{plain\}\}]\{../pdf_out/",$1,"\}")} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%!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} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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