Printing two pages per sheet from the command line
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.
Related videos on Youtube
lolnoobhax
Updated on September 18, 2022Comments
-
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 almost 10 yearsthis has to be a duplicate.
-
martin almost 10 yearsAt least he used a debugger!
-
Mike Seymour almost 10 yearsYou forgot to enable compiler warnings. That would tell you exactly what's wrong.
-
lolnoobhax almost 10 years@MikeSeymour Yeah, i forgot since thats in every programming course, right...
-
-
101010 almost 10 years
x == 0
.........................!!!!!!!!!#####^^^^&&*&* now you have a clue. -
lolnoobhax almost 10 yearslol, 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 almost 10 yearsHah thanks!! sleepyhead :/
-
scohe001 almost 10 years@lolnoobhax please also see my edit.
-
Hanky Panky almost 10 yearsVery interesting reason:)
-
scohe001 almost 10 yearsThis is clever, but I'm iffy about it...
if(0 == x)
just looks weird. -
lolnoobhax almost 10 yearsThx 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 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 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 tox
. -
XavierStuvw over 8 yearsHi. 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 over 8 yearsThis produces the desired result ahead of engaging with printing commands. Man pages are available on-line from Linux.die.net
-
comfreak over 2 yearsFor
pdfjam
you need to add the option--nup 2x1
, otherwise it just pipes the document as-is.