Merge multiple jpg into single pdf in Linux

后端 未结 6 1839
南旧
南旧 2021-01-30 02:25

I used the following command to convert and merge all the jpg files in a directory to a single pdf file.

convert *.jpg file.pdf

Th

6条回答
  •  遥遥无期
    2021-01-30 02:42

    This is how I do it:
    First line convert all jpg files to pdf it is using convert command.
    Second line is merging all pdf files to one single as pdf per page. This is using gs ((PostScript and PDF language interpreter and previewer))

    for i in $(find . -maxdepth 1 -name "*.jpg" -print); do convert $i ${i//jpg/pdf}; done
    gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=merged_file.pdf -dBATCH `find . -maxdepth 1 -name "*.pdf" -print"`
    

提交回复
热议问题