#!/bin/bash # Script rédigé par Pieds-Nus au février 2025 pour concaténer des plans pdf et insérer les numéros de page # fournir en argument la liste des fichiers pdf à assembler, dans l'ordre. # le résultat sera enregistré dans le dossier courant, sous le nom "output.pdf" # # Dependencies : # bash # grep # mutool, from package mupdf-tools : https://mupdf.com/ # a functionning texlive installation, for instance the texlive-base package in debian # pdfjam (should be included in texlive-extra-utils, or can be retrieved here : https://ctan.org/pkg/pdfjam) # eso-pic (should be included in texlive, or can be retrieved here : https://ctan.org/pkg/eso-pic) # open-sans font (should be included in texlive-fonts-extra, or can be retrieved here : https://ctan.org/pkg/opensans) pagecount=$(mutool pages $@ | grep -c "pagenum" ) echo "Page count: ${pagecount}" pre="\documentclass[a3paper,landscape]{minimal} \usepackage{eso-pic} \usepackage[default,scale=1.35]{opensans}" #edit the values in this line to adjust position of the page numbers : #cartouche AtelierPaysan : pagecommand="{\AddToShipoutPictureFG{\AtPageUpperLeft{\raisebox{-21.1mm}{\hspace{93.25mm}\colorbox{white}{\makebox[37.3mm][r]{\textcolor[gray]{0.5}{\thepage\}\raisebox{-0.35mm}{\strut}}}}}}}" pagecommand="{\AddToShipoutPictureFG{\AtPageUpperLeft{\raisebox{-190mm}{\hspace{90mm}\colorbox{white}{\makebox[37.3mm][r]{\textcolor[gray]{0.5}{\thepage\}\raisebox{-0.35mm}{\strut}}}}}}}" pdfjam --no-tidy --a3paper --landscape --preamble "${pre}" --pagecommand "${pagecommand}" -o outfile.pdf $@ dir="/tmp/$(ls -t /tmp/ | grep "pdfjam-*" | head -n 1)" cd "${dir}" sed -i -E "s/\\documentclass\[a3paper,landscape\]\{article\}/\\documentclass\[a3paper,landscape\]\{minimal\}/" a.tex pdflatex -no-shell-escape a.tex cd - mv "${dir}/a.pdf" outfile.pdf mutool clean -gggg -l -zfism outfile.pdf outfile_clean.pdf mupdf outfile_clean.pdf && rm -rf "${dir}"