STEP 0 : Install

Install program pdftk and imagemagick :

sudo apt-get install pdftk imagemagick

STEP 1 : Convert

Input is :
/image/topic-01/01-01.jpg
/image/topic-02/02-01.jpg
/image/topic-02/02-02.jpg
/image/topic-03/03-01.jpg

Output is :
- topic-01.pdf (1 pages)
- topic-02.pdf (2 pages)
- topic-03.pdf (1 pages)

Basic convert :

find /image -type d | while read d; do convert "${d}"/.jpg ./"${d##/}.pdf"; done

Option resize convert(Reduced quality) :

find /image -type d | while read d; do convert -density 150 -quality 50 "${d}"/.jpg ./"${d##/}.pdf"; done

STEP 2 : Combine

Input is :
*pdf

Output is :
onefile.pdf

Combine pdf files :

pdftk *pdf cat output onefile.pdf

You can also use /usr/bin/pdfunite to merge several pdf into one (in ubuntu, install package poppler-utils for this)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.