Last active
September 20, 2023 15:44
-
-
Save eugrus/78680461269417156f9b3068345b5f6e to your computer and use it in GitHub Desktop.
Add 1cm margins left and right to every page of a PDF using pdflatex directly
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
for INPUT_PDF_FILE in "$@"; do | |
if [ "$(file -b --mime-type "$INPUT_PDF_FILE")" == "application/pdf" ]; then | |
OUTPUT_PDF_FILE="${INPUT_PDF_FILE%.pdf}.margins" | |
pdflatex -jobname "$OUTPUT_PDF_FILE" "\documentclass{article}\usepackage{pdfpages}\begin{document}\includepdf[pages=-,trim=1cm 0cm 1cm 0cm]{$INPUT_PDF_FILE}\end{document}" | |
else | |
echo "Skipping non-PDF file: $INPUT_PDF_FILE" | |
fi | |
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
INPUT_PDF_FILE="$1" OUTPUT_PDF_FILE="${INPUT_PDF_FILE%.pdf}.margins"; pdflatex -jobname "$OUTPUT_PDF_FILE" "\documentclass{article}\usepackage{pdfpages}\begin{document}\includepdf[pages=-,trim=1cm 0cm 1cm 0cm]{$INPUT_PDF_FILE}\end{document} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment