118

I have saved multiple images from google books. I wanted to convert them to a single pdf file, where in I need some inputs. The below two images(one png and one jpeg) are two continuous pages.

first page(png)

second page(jpeg)

I save them in my system. I converted them to pdf using the command below

convert books.png books.jpeg combined.pdf

However the combined.pdf is not giving me expected results, not the combination of the two.

I also tried making individual pdf files, then combining them using pdftk, with no luck

convert books.png book1.pdf
convert books.jpeg book2.pdf
pdftk book1.pdf book2.pdf cat output combined.pdf
Braiam
  • 69,112
user301880
  • 1,291

5 Answers5

175

Edit: as of 2024, convert has been deprecated and you can use 'magick' directly instead, like so:

magick "*.{png,jpeg}" -quality 100 outfile.pdf

Original answer:

Use convert program (it is an executable installed as part of Imagemagick suite of tools):

convert "*.{png,jpeg}" -quality 100 outfile.pdf

In general case you can combine more files into one pdf file with including them inside {} and separate them with a single comma.

adding -quality VALUE to keep quality after conversion.

convert "*.{ext1,ext2,ext3,...}" -quality 100 outfile.pdf
jlo
  • 225
αғsнιη
  • 36,350
17

If all the images are in the same folder and have the same extension you could do the following:

Convert images to pdf:

ls *.tif | xargs -I% convert % %.pdf

Note: Note that if they are named 1...tif; 2...tif; 10...tif do ls -1v for numbered files

Merge pdf files into one pdf and remove single page pdfs:

pdftk *.pdf cat output merged.pdf && rm *.tif.pdf
To Do
  • 15,833
15

I used the two sample pages you provided and printed them using cups-pdf printer resulting in two pdf files.

Then I used pdfsam to combine pdf files in one. I see no problem in the result.

Edit: I just saw that you have many files to process, you can use print-selected script in Nautilus described here

bob
  • 1,198
3

Use print assistant from Gwenview (KDE image viewer). Open Gwenview, then Plugins -> Images -> Print assistant. Add all the images that you want to print, reorder them as you like, choose number of images per page, other print options, etc. and print to PDF directly or with CUPS-PDF.

Sameer
  • 269
2

Recently I needed to convert my image files to pdf and I tried convert which did not work. So, instead I found img2pdf tool and used this.

Examples:

## A single image to pdf:
img2pdf --output out_single_screenshot_to_PDF.pdf Screenshot01.png
## Multiple images to pdf:
img2pdf --output out_multiple_screenshot_to_PDF.pdf Screenshot01.png Screenshot02.png
## All .jpg images in a directory to pdf:
img2pdf --output out_single_screenshot_to_PDF.pdf *.jpg
## Printable A4 size pdf with 2cm border at top/bottom and 2.5 cm left/right:
img2pdf --output out_A4.pdf --pagesize A4^T --border 2cm:2.5cm *.png
rusty
  • 16,917