Merge Split PDF Ubuntu Using Terminal Command

Merge Split PDF Ubuntu Using Terminal

PDFtk Command

In this article I created a guide how to combine, joint, merge multiple and split pdf in ubuntu using terminal with simple commands. The small software that we can use is PDFtk.

Install PDFtk Ubuntu

To be able to use the PDFtk command in the Ubuntu terminal, we must install it with the command:

sudo apt install pdftk

If successful you will get output like this:

neon@linux:~$ sudo apt install pdftk
Reading package lists… Done
Building dependency tree… Done
Reading state information… Done
The following additional packages will be installed:
libapache-pom-java libbcprov-java libcommons-lang3-java
libcommons-parent-java pdftk-java
Suggested packages:
libbcprov-java-doc libcommons-lang3-java-doc
The following NEW packages will be installed:
libapache-pom-java libbcprov-java libcommons-lang3-java
libcommons-parent-java pdftk pdftk-java
0 upgraded, 6 newly installed, 0 to remove and 23 not upgraded.
Need to get 949 kB/4,947 kB of archives.
After this operation, 6,024 kB of additional disk space will be used.
Do you want to continue? [Y/n]
Get:1 jammy/universe amd64 pdftk-java all 3.2.2-1 [942 kB]
Get:2 jammy/universe amd64 pdftk amd64 2.02-5 [6,228 B]
Fetched 949 kB in 1s (771 kB/s)
Selecting previously unselected package libapache-pom-java.
(Reading database … 310192 files and directories currently
Preparing to unpack …/0-libapache-pom-java_18-1_all.deb …
Unpacking libapache-pom-java (18-1) …
Selecting previously unselected package libbcprov-java.
Preparing to unpack …/1-libbcprov-java_1.68-5_all.deb …
Unpacking libbcprov-java (1.68-5) …
Selecting previously unselected package libcommons-parent-jav
Preparing to unpack …/2-libcommons-parent-java_43-1_all.deb
Unpacking libcommons-parent-java (43-1) …
Selecting previously unselected package libcommons-lang3-java
Preparing to unpack …/
b …
Unpacking libcommons-lang3-java (3.11-1) …
Selecting previously unselected package pdftk-java.
Preparing to unpack …/4-pdftk-java_3.2.2-1_all.deb …
Unpacking pdftk-java (3.2.2-1) …
Selecting previously unselected package pdftk.
Preparing to unpack …/5-pdftk_2.02-5_amd64.deb …
Unpacking pdftk (2.02-5) …
Setting up libbcprov-java (1.68-5) …
Setting up libapache-pom-java (18-1) …
Setting up libcommons-parent-java (43-1) …
Setting up libcommons-lang3-java (3.11-1) …
Setting up pdftk-java (3.2.2-1) …
update-alternatives: using /usr/bin/pdftk.pdftk-java to provi
de /usr/bin/pdftk (pdftk) in auto mode
Setting up pdftk (2.02-5) …
Processing triggers for man-db (2.10.2-1) …

Install Another Distros

If you want to install it to a distro other than ubuntu, here are the commands:

ArchRed Hat, Fedora & CentOS
paru -S pdftk

## or ##

yay -S pdftk
sudo yum install epel-release
sudo yum install pdftk

## or ##

sudo dnf install epel-release
sudo dnf install pdftk

Merge or Join PDF Command

To make things easier, let’s try to merge several pdfs. I have 2 pdf with name test1.pdf and test2.pdf. To merge the both use the command:

pdftk test1.pdf test2.pdf cat output mergetest.pdf

You will get the result of merged pdf with name mergetest.pdf. If you want to merge all existing pdfs, the command to use is:

pdftk *.pdf cat output mergeall.pdf

You will get the mergeall.pdf of all existing pdfs. The naming of the output pdf can be changed as desired.

Split PDF Command

Then how to split the pdf using pdftk? For example we have a mergeall.pdf file which consists of two pages and we want to split it into 2 files. The command is:

pdftk mergeall.pdf burst

So, pdftk will divide into several pages according to the number of pages in the combined file. If you want to see more of the available commands, please read man.

I hope this article Merge Split PDF Ubuntu Using Terminal PDFtk Command can help you solve pdf problems that exist on your Ubuntu Linux Distro.

Read more:
> Special Character Code Table For Web Development
> Install phpMyAdmin Ubuntu Linux Easy Terminal
> Install Laravel First Time In Ubuntu Linux

Similar Posts