3 ms·
There don't appear to be many hyperlinks. Assuming sequential filenames, gluing them together can be done by: mkdir out; pdftk * cat output out/topo_cat.pd
by wging 4y ago
There don't appear to be many hyperlinks. Assuming sequential filenames, gluing them together can be done by:
mkdir out; pdftk * cat output out/topo_cat.pdf
(also, this requires you to have installed pdftk)
A table of contents can be added with a little more work, if you don't care about anything below the chapter level. Assuming sequential filenames again:
chapters=(
"Preface"
"Preliminaries"
"Examples and Constructions"
"Connectedness and Compactness"
"Limits of Sequences and Filters"
"Categorical Limits and Colimits"
"Adjunctions and the Compact-Open Topology"
"Paths, Loops, Cylinders, Suspensions, . . ."
"Glossary of Symbols"
"Bibliography"
"Index"
)
page=1
chapter=0
rm bookmarks.txt
for p in *.pdf; do
datafile="$p.data"
if [ ! -f "$datafile" ]; then
echo "generating $datafile"
pdftk $p dump_data > $datafile
fi
chapter_pages=$(awk /NumberOfPages/'{print $2}' $datafile)
echo "page: $page"
echo "new pages: $chapter_pages"
echo "chapter: $chapter"
echo BookmarkBegin >> bookmarks.txt
echo "BookmarkTitle: ${chapters[$chapter]}" >> bookmarks.txt
echo "BookmarkLevel: 1" >> bookmarks.txt
echo "BookmarkPageNumber: $page" >> bookmarks.txt
((page=$page+$chapter_pages))
((chapter=$chapter+1))
done
pdftk out/topo_cat.pdf update_info bookmarks.txt output out/topo_cat_bookmarked.pdf
(credit to https://stackoverflow.com/questions/2418871/need-to-merge-multiple-pdfs-into-a-single-pdf-with-table-of-contents-sections/40222656#40222656 https://stackoverflow.com/questions/2418871/need-to-merge-mu... for the basic approach. apologies for the code dump instead of an output file; not clear to me that CC BY-NC-ND 2.0 allows distributing the result of this process, as simple as it is, whereas publishing this code is clearly fine.)