How to Split PDF File on Ubuntu 18.04

Splitting PDF file into one PDF file per page or selecting specific pages into one PDF file can be done in Ubuntu in 2 ways, first with the default PDF reader application in Ubuntu, Document Viewer (Evince), and the second by using command line based application PDFtk (PDF toolkit).

*Document Viewer*

Splitting PDF file using the Document Viewer

1. Open PDF file 2. Click Print… or CTRL+P 3. Choose Print to File 4. Click File for output file name 5. Choose Pages then enter the page number you want to split. For example page 10 enter 10, pages 5 to 10 enter 5-10 6. Click Print

Document Viewer – Print

The drawback of Document Viewer is that when you want to split each page into one PDF file it will take a long time because you have to do it repeatedly. For example split PDF file containing 100 pages, must do Print to File up to 100 times.

*PDFtk (PDF toolkit)*

Splitting PDF files using command line based PDFtk

Install PDFtk on Ubuntu 18.04

[INPUT]

1 sudo snap install pdftk

Create a pdftk symlink

[INPUT]

1 sudo ln -s /snap/pdftk/current/usr/bin/pdftk /usr/bin/pdftk

Split one page (page 10) from a PDF file (fullpage.pdf)

[INPUT]

1 pdftk fullpage.pdf cat 10 output page10.pdf

Split pages 5 to 10 of the PDF file

[INPUT]

1 pdftk fullpage.pdf cat 5-10 output page5-10.pdf

If you want to split each page, create a simple bash script to run PDFtk repeatedly.

Create a bash script file

[INPUT]

1 nano split.sh

Script to split each page of a PDF file with the name file fullpage.pdf which contains 100 pages.

[INPUT]

1 2 3 4 5 6 #!/bin/bash   for page in {1..100} do    pdftk fullpage.pdf cat $page output $page.pdf done    

Give execute privileges then run the script

[INPUT]

1 2 chmod u+x split.sh ./split.sh  

PDFtk can also be used to merge PDF files

[INPUT]

1 pdftk file1.pdf file2.pdf file3.pdf cat output output.pdf

Good luck 🙂

Leave a Reply

Your email address will not be published.