14

Let us say I want slides.pdf to contain 4 slides per page.

I can open a slides.pdf document under evince (the default Ubuntu document viewer)

evince slides.pdf-->Print-->Page Setup--> Pages per Side --> 4 (or some other number)

Then, I can indicate I want to print to a file, and print. The result is an output.pdf file with the desired number of slides per sheet.

I want to achieve this same functionality through the command line (as I need to incorporate this into a script). All I have found some far are solutions relying on external tools. For example, I tried installing pdfjam (which required me to install 88.1 MB worth of packages from texlive-latex-base in order to achieve a functionality that I already have!), The result was only failure with pdfjam ERROR: LaTeX package pdfpages.sty is not installed.

I would rather avoid external packages.

How do I achieve this through the command line?

user84207
  • 423
  • 1
  • 4
  • 11

4 Answers4

22

You can also use pdfnup:

pdfnup --nup 2x2 --no-landscape file.pdf

where 2x2 refers to 2 rows by 2 columns (or the reverse--I'm not sure). See man pdfnup for more options.

Paul Robert
  • 221
  • 1
  • 2
  • 4
    `pdfnup` works fine. A note for people who want to put the same one page PDF four times on one page: You need to list the input pdf file four times: `pdfnup --no-landscape --a4paper --nup 2x2 input.pdf input.pdf input.pdf input.pdf` – guettli Dec 20 '14 at 17:16
  • 2
    An addition to above answer + comment: `pdfnup --nup 2x2 --frame true --noautoscale false --delta "0.2cm 0.3cm" --scale 0.90 your.pdf` will print 4 slides on one page of a pdf file named "your-nup.pdf" using content of "your.pdf" as input pages. `--frame true` prints a frame around each slides, `--delta...` specifies a margin between frames, and `--scale ...` ensures that a sheet margin is introduced so your printer handles the job well without cutting off content. All options at http://www2.warwick.ac.uk/fac/sci/statistics/staff/academic-research/firth/software/pdfjam/#using. – Cbhihe Feb 14 '17 at 17:20
  • Paul Robert: I know yr answer is old but feel free to incorporate my comment in yr answer. I can't speak for @guettli. Everything works well for Ubuntu up to 16.04 at least. (I have not tested it on a rolling distribution with the latest of kernel images and packages.) Cheers. – Cbhihe Feb 14 '17 at 17:22
  • BTW, pdfnup uses internally the pdfpages.sty package, which the op did not want to use. I have the opposite feeling: I will use the pdfpages.sty package in TexStudio to do the job. – Dominic108 Jun 19 '19 at 23:04
6

For me pdfnup was not available, and whilepdfxup did not work, pdfjam did:

pdfjam --nup 2x2 <infile>

To specify the output file name (in place of the autogenerated one) use the option --outfile

pdfjam --nup 2x2 <infile> --outfile <outfile>
Antonio
  • 397
  • 1
  • 7
  • 23
  • `pdfnup` was a simple wrapper to `pdfjam`, but was [discontinued](https://github.com/rrthomas/pdfjam#-wrapper-scripts-no-longer-included-here), although it remains available in [a separate repository](https://github.com/rrthomas/pdfjam-extras) – husB Jan 05 '23 at 16:52
  • `pdfjam` is incredible! If you want the equivalent of adobe reader's custom number of pages per sheet + auto rotate: `pdfjam --nup 3x1 --landscape --frame true combined.pdf --noautoscale false --rotateoversize=true --letterpaper --outfile combined-3x1.pdf` – Sparkler Jun 10 '23 at 20:26
2

to perform an IMPOSITION, nothing is better than Multivalent.jar (latest free version with tools inside, latest Multivalent build currently hosted on sourceforge - 2009 - has no more pdf tools)

you can download the Multivalent.jar build with tools from:

online man - http://multivalent.sourceforge.net/Tools/pdf/Impose.html

use:

java -cp path...to/Multivalent.jar tool.pdf.Impose -dim (rowsxcols) -paper (paper sizes where pages will be imposed) file.pdf
Dingo
  • 974
  • 1
  • 9
  • 11
  • Thank you! I have used your solution. It is simple, not bloated, self-contained, cross-platform. Perfect. – user84207 May 15 '13 at 21:47
  • On source forge the PDF tools were removed due to copyright issues: https://sourceforge.net/p/multivalent/discussion/252478/thread/e7850c31/#f290 – Loren Dec 07 '19 at 22:41
0

The only tool I've found that can do this and is maintained is PyPDF2 https://pythonhosted.org/PyPDF2/index.html

You can see some example code at: https://superuser.com/a/1508283/590044

Loren
  • 111
  • 4