Your Ad Here

Posted By

willcodeforfood on 09/04/07


Tagged


Versions (?)

PDF to Tinybook


 / Published in: Bash
 

URL: http://weblog.bignerdranch.com/?p=23

Here’s how to do it from Linux for A4 paper. If you want to use US letter paper, replace the word a4paper with letterpaper.

I named the script pdf2tinybk, and made it executable using chmod 755 pdf2tinybk. It takes the name of an eight page pdf file for its input and produces a file named book.pdf for its output.

( source: http://weblog.bignerdranch.com/?p=23 )

  1. ./pdf2tinybk foo.pdf
  2.  
  3. Enjoy!
  4.  
  5. #!/bin/bash
  6.  
  7. # program to produce folded mini books
  8.  
  9. pdflatex=/usr/bin/pdflatex
  10.  
  11. infile=”$1
  12.  
  13. tmpdir=”/tmp/$$
  14.  
  15. mkdir$tmpdir
  16. cp$infile” “$tmpdir/in.pdf”
  17. cd$tmpdir
  18.  
  19. # invert pages on top half
  20.  
  21. $pdflatex \\batchmode \
  22. ‘\documentclass[a4paper,portrate]{book}\
  23. \usepackage{pdfpages}\
  24. \begin{document}\
  25. \includepdf[pages=1, angle=180]{in.pdf}\
  26. \includepdf[pages=2-5]{in.pdf}\
  27. \includepdf[pages=6-8, angle=180]{in.pdf}\
  28. \end{document}
  29.  
  30. mv book.pdf in.pdf
  31.  
  32. # impose pages into mini booklet
  33.  
  34. $pdflatex \\batchmode \
  35. ‘\documentclass[a4paper,landscape]{book}\
  36. \usepackage{pdfpages}\
  37. \begin{document}\
  38. \includepdf[nup=4×2, pages={1,8-6,2-5}, trim=24mm 10mm 24mm 10mm, cut, frame]{in.pdf}\
  39. \end{document}
  40.  
  41. mv book.pdf $OLDPWD
  42.  
  43. rm -rf$tmpdir

Report this snippet  

You need to login to post a comment.