Printing two pages per sheet from the command line

147

Solution 1

There is the pdfnup (or pdfjam) command line tool. You can install it from the repositories of your distribution (sudo apt-get install pdfjam for Debian-based distributions, yaourt -S pdfnup on Arch etc).

The default options will take the input PDF file and produce an output PDF with two input pages per page:

pdfnup -o output.pdf input.pdf

Solution 2

To expand on the accepted answer:

Using pdfjam you will need to pass the landscape option as well. The usage is:

pdfjam input.pdf -o output.pdf --nup 2x1 --landscape

Note that the extra --angle 90 might save your day, depending on the orientation of the pages in the original PDF.

Share:
147

Related videos on Youtube

lolnoobhax
Author by

lolnoobhax

Updated on September 18, 2022

Comments

  • lolnoobhax
    lolnoobhax almost 2 years

    I'm studying C++ atm but i stumbled on something i just can't declare why it is happening. For no reason i am looking here for the exact solution of what i'm trying to do, just a explanation will be much appreciated!

    It's about his piece of code here:

    int Factorial(int x) {
        if (x = 0) {
            x = 1;
        } else {        
            int sum = 1;
            for (int counter = 1; counter <= x; ++counter) {
                sum *= counter;
            }
            x = sum;
        }
        return x;
    }
    

    So let us assume i call Factorial() with the int 5 (Factorial(5)). Somehow as soon the program goes passed the if (x = 0) statement it resets it(x) to 0, atleast this is all i can see in Visual Studio since it hops from the if statement straight too the declaration of the sum integer.

    I hope some can clarify me what the heck has happened here.

    Thank you in advance!

    • Almo
      Almo almost 10 years
      this has to be a duplicate.
    • martin
      martin almost 10 years
      At least he used a debugger!
    • Mike Seymour
      Mike Seymour almost 10 years
      You forgot to enable compiler warnings. That would tell you exactly what's wrong.
    • lolnoobhax
      lolnoobhax almost 10 years
      @MikeSeymour Yeah, i forgot since thats in every programming course, right...
  • 101010
    101010 almost 10 years
    x == 0 .........................!!!!!!!!!#####^^^^&&*&* now you have a clue.
  • lolnoobhax
    lolnoobhax almost 10 years
    lol, omg i must be so sleepy :D I also just noticed i'm asking for counter = 1 to eliminate the 0 factor of returning 0 and that fixed it too (since the if statement is eliminated) I obviously should take a break :/ thank you for your help!!!
  • lolnoobhax
    lolnoobhax almost 10 years
    Hah thanks!! sleepyhead :/
  • scohe001
    scohe001 almost 10 years
    @lolnoobhax please also see my edit.
  • Hanky Panky
    Hanky Panky almost 10 years
    Very interesting reason:)
  • scohe001
    scohe001 almost 10 years
    This is clever, but I'm iffy about it...if(0 == x) just looks weird.
  • lolnoobhax
    lolnoobhax almost 10 years
    Thx again, and thx for not beeing so small minded! :p I know its a stupid mistake and all but going by the comments lol... Everyone was born pro, i forgot that bit.
  • TRKemp
    TRKemp almost 10 years
    @Josh It does take some getting used to, but I've made a habit of putting immutable objects on the left for many years. It makes code much more maintainable.
  • atkins
    atkins almost 10 years
    "Also, it is bad practice to modify the parameter variables." - and this would also allow you to declare int Factorial(int const x), which would have failed to compile if you accidentally tried to assign to x.
  • XavierStuvw
    XavierStuvw over 8 years
    Hi. This answer bumps against the limitation that, if I launch lpr -P PDF -p 2 the quality of the result is way too raw. It is useful if that is not a requirement.
  • XavierStuvw
    XavierStuvw over 8 years
    This produces the desired result ahead of engaging with printing commands. Man pages are available on-line from Linux.die.net
  • comfreak
    comfreak over 2 years
    For pdfjam you need to add the option --nup 2x1, otherwise it just pipes the document as-is.