110

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
  • 67,791
  • 32
  • 179
  • 269
user301880
  • 1,211
  • 2
  • 9
  • 5
  • Try changing book1.pdf and book2.pdf to be in one folder, cd to that folder and run pdftk *.pdf cat output onelargepdfile.pdf. – Tim Jul 09 '14 at 11:41
  • Tim, Thanks. That also I had tried, however still the same result. – user301880 Jul 09 '14 at 11:44
  • Thats strange. Maybe it doesn't see the image pdfs as valid pdf files? – Tim Jul 09 '14 at 11:44
  • It's quite interesting. I tried doing it on the machine and it is not working as desired. It shows the correct thumbnails though. – Vivek Kapoor Jul 09 '14 at 11:50
  • If you open the image file, and then print it to file, does it let you combine those files? – Tim Jul 09 '14 at 11:52
  • I have to try printing to a file option, however there are around 300 images, if it was using the commands, would be easy as I can do using scripts. Not sure how I would do for all images using printo file option – user301880 Jul 09 '14 at 11:57
  • I don't understand what exact problem you all tried to solve here. I have downloaded both files and convered them with simple magick first.png second.jpg output.pdf. Works for me on Windows 7 (sorry, I don't use Linux) and ImageMagick 7.0.10-6 Q16 x86 2020-04-06. The result is a 2-page pdf file where the first page is the first image and the second page is the second image. – john c. j. May 21 '22 at 15:33

4 Answers4

163

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
αғsнιη
  • 35,660
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
  • 7
    Command line way to do it - Rename the files: mv books.png 1.png, mv books.jpg 2.jpg - Print them to PDFs: lpr -P 'Cups-PDF' 1.png, lpr -P 'Cups-PDF' 2.jpg - Combine PDF files: pdfunite ~/Desktop/1.pdf ~/Desktop/2.pdf complete.pdf. Cup's PDF printer outputs the files to ~/Desktop with the names of the original files - so they both can't be called books.* otherwise they just replace each other. You can list printers and their names with lpstat -p. – Wilf Jul 09 '14 at 12:12
15

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
Philippe Gachoud
  • 5,900
  • 3
  • 43
  • 50
To Do
  • 15,502
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
  • 249
  • 1
  • 4