Imagine you have clicked pictures of your notebook and saved them as pdf file. You find that it is oriented in the wrong direction and you rotate it using your pdf viewer. But when you are trying to email them to your friend, you will find that it is still misoriented. Are you confused what is happening? Do you want to know how to rotate pdf files permanently?
When you rotate a pdf file, it gets rotated only in the viewer but not in the actual file. If you want to permanently rotate a pdf file then you have to look for some software. Although you can rotate a pdf file using online tools but the security of your pdf document may get compromised. So, it’s always advisable to use offline software to rotate or merge your pdf files. Not all software have their counterpart in Linux. In this article, I am going to explain you, how to rotate pdf files permanently and how to merge pdf files using PDFtk software.
PDFtk is command based software which you can run using terminal in Linux. You can also download GUI based PDFtk software for windows. The terminal commands may not be intuitive compared to GUI based software but commands can help you handle large number of files. For example, you have generated hundreds of graphs and want to combine them into a single file and some of which need to be rotated. You can download the source file of PDFtk from their website. However if you use Ubuntu you can install PDFtk using Ubuntu Software.
Permanently Rotate Pdf Files
How to rotate pdf files
Suppose you have a file named example.pdf and you want to rotate left (west) all the pages and want to create a new file called example_out.pdf then you should type following command in the terminal.
pdftk example.pdf rotate 1-endwest output example_out.pdf
In this command, rotate is operation and 1-endwest is its value where 1-end specifies the page range from first page to last page ane west specifies the direction of rotation. You can mention direction as north, south, east, west, left, right, or down. After that output is operation and its value is example_out.pdf which is the name of our ouput file.
How to rotate selected pages
If you want to rotate first page to right (east), second and third page to left (west) and leave the remaining pages unchanged, then you can used the following command.
pdftk example.pdf rotate 1east 2-3west output example_out.pdf
For single pages, the range can either be number (like 1) or range (like 1-1), it will work both ways.
How to rotate all odd pages
If you want to rotate all the odd pages of a pdf to left (west) then you should mention odd before west.
pdftk example.pdf rotate oddwest output example_out.pdf
For rotating even pages, you should replace odd by even and other things will remain same.
How to rotate all odd pages in a selected range
If you want to rotate only odd pages in a selected range say (page 2 to 4) then you can mention range before oddwest.
pdftk example.pdf rotate 2-4oddwest output example_out.pdf
How to rotate some pages and save as a separate file
Suppose you want to rotate page 1 (left) and 3 (right) and save them as a separate file which will contain only these two pages.
pdftk example.pdf cat 1-1west 3east output example_out.pdf
This cat operation will help you select out only few pages out of a big pdf file and save them as a separate file. If you don’t want to rotate some pages then you can either leave direction or mention north and it will save as a unrotated separate file.
pdftk example.pdf cat 1-1west 3 output example_out.pdf
You can use the above commands in combination to achieve your desired pdf file in all possible rotations. Now, we will look, how to merge these rotated pdf files.
How to Change Page Ordering
If you want to reverse the page ordering from last to first page then you should write range in reverse order.
pdftk example1.pdf cat end-1 output example_out.pdf
How to Merge Rotated Pdf Files
How to merge pdf files
Suppose you want to combine pdf files named example1.pdf and example2.pdf into a single file names example_out.pdf.
pdftk A=example1.pdf B=example2.pdf output example_out.pdf
How to merging rotated files in different order
Suppose you want to put pages of second file first and then that of first file. You also want to rotate pages of first file to left.
pdftk A=example1.pdf B=example2.pdf cat B Aleft output example_out.pdf
How to Shuffle while merging files
Suppose you want to put pages of first file as odd pages and that of second file as even pages then you can use shuffle operation as shown below.
pdftk A=example1.pdf B=example2.pdf shuffle A B output example_out.pdf
Similarly you can use more than two file to put them in alternate way.
There are many other operations which you can do using PDFtk software like applying watermark, password, encryption and compression etc. You can get more information about these operations by using help command.
I hope this articles helped you in knowing, how to rotate pdf files and how to merge pdf files using PDFtk in Linux. If you like this tutorial, please share with someone who is interested. You can follow us on facebook and twitter. You can subscribe us for Email Notification also to get an email whenever we publish a new post.