Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have a few books as PDFs, and I'd like to split them by chapter for easier consumption on a mobile phone. Is there any tool (or sequence of tools) I can use to easily split the book into different PDF files by chapter?

share|improve this question

4 Answers 4

up vote 5 down vote accepted

This would be hard to do automatically, as there is no standard chapter label in a PDF file. However, if you do not mind some manual work, write down the pages for each chapter, and use pdftk to select the pages and save them into a new pdf file. For example, if chapter 2 is pages 23-45, do

pdftk A=input.pdf cat A23-45 output chapter_2.pdf

You need to install pdftk first:

sudo apt-get install pdftk

You can also use ghostscript (which comes preinstalled) directly:

gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dSAFER -dFirstPage=23 -dLastPage=45 -sOutputFile=chapter_2.pdf input.pdf

This is quite easy to convert a script that runs things semi-automatically. First, create an input file; on each line, put the desired output pdf file title, the starting page, the ending page -- like that:

chapter1 1 23
chapter2 24 56

Save this, using a text editor, to file pdfchaps.in.

Now, create a script -- save the following to a file called pdfchaps.sh:

#!/bin/bash

function pdfextr() { 
  echo "Chapter $2"
  pdftk A=$1 cat A$3-$4 output $2.pdf 
}

chapters=$1
pdffile=$2

echo "Splitting pdf file $pdffile by chapters from $chapters"
cat $chapters | while read line ; do  pdfextr $pdffile $line ; done

Make the script executable:

chmod a+x pdfchaps.sh

And run it:

pdfchaps chaps.in mybook.pdf
share|improve this answer

You have many choices for that:

1. flpsed

 sudo apt-get install flpsed

2. Pdftk

sudo apt-get install pdftk

3. Pdfedit

sudo apt-get install pdfedit

4. Using GIMP

Install krita using the following command

sudo apt-get install krita

Open the Gimp, and open the PDF document you wish to edit. For multiple page documents, it is easier on your computer to edit them one page at a time. If you choose more than one page, they will open in individual windows.

Make the necessary changes to the document.Save the document as a Gimp XCF file (you'll have to save several different pages if it is a multi-page document). Close the document, then open the resulting image in Krita.

Printing to PDF with Krita Go to File>Print, then choose Print to PDF. In the same dialogue box, choose the destination folder and name of the output document (such as file1.pdf).

5. PdfMod

6. Inkscape

An Open Source vector graphics editor, with capabilities similar to Illustrator, CorelDraw, or Xara X, using the W3C standard Scalable Vector Graphics (SVG) file format. Inkscape supports many advanced SVG features (markers, clones, alpha blending, etc.) and great care is taken in designing a streamlined interface. It is very easy to edit nodes, perform complex path operations, trace bitmaps and much more. We also aim to maintain a thriving user and developer community by using open, community-oriented development.

Install inkscape in Ubuntu

sudo apt-get install inkscape

7. PDF-Shuffler

PDF-Shuffler is a small python-gtk application, which helps the user to merge or split pdf documents and rotate, crop and rearrange their pages using an interactive and intuitive graphical interface. It is a frontend for python-pyPdf.

share|improve this answer
    
apt-cache search pdfedit comes up empty for me (Lubuntu 13.04). –  user25656 Jun 21 '13 at 7:01

You could try pdfsam (pdf-split-and-merge) but you have to manually select the beginning of each chapter.

share|improve this answer

I was looking now for hours for the perfect tool for the same reason and indeed pdfsam Install pdfsam is the way to go.

The split by chapter worked for me, it was not necessary to select the pages manually, there is a function provided and you can even select the "depth" -- like e.g. on section, or subsection level.

What took me some time to find out: How to give the output files the name of the chapters instead of the regular naming (user defineable prefix + number of starting page + original document name). After hours of searching I found the solution: One can use "complex prefix(es)" as described here. This solved all of my problems and should help you as well.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.