convert images to pdf

use*_*880 79 imagemagick

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
Run Code Online (Sandbox Code Playgroud)

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
Run Code Online (Sandbox Code Playgroud)

αғs*_*нιη 114

使用convert程序(它是作为Imagemagick工具套件的一部分安装的可执行文件):

convert "*.{png,jpeg}" -quality 100 outfile.pdf
Run Code Online (Sandbox Code Playgroud)

在一般情况下,您可以将多个文件合并到一个 pdf 文件中,并将它们包含在其中{}并用一个逗号分隔它们。

添加-quality VALUE以保持转换后的质量。

convert "*.{ext1,ext2,ext3,...}" -quality 100 outfile.pdf
Run Code Online (Sandbox Code Playgroud)

  • @holzkohlengrill 它与 IM 命令无关,[这取决于您正在使用的 shell 和区域设置](https://unix.stackexchange.com/a/368507/72456)。 (2认同)

bob*_*bob 15

我使用了您提供的两个示例页面,并使用cups-pdf 打印机打印了它们,从而生成了两个 pdf 文件。

然后我使用pdfsam将 pdf 文件合二为一。我认为结果没有问题。

编辑:我刚刚看到您有很多文件要处理,您可以使用此处描述的 Nautilus 中的打印选择脚本

  • 命令行方式 - 重命名文件:`mv books.png 1.png`,`mv books.jpg 2.jpg` - 将它们打印为 PDF:`lpr -P 'Cups-PDF' 1.png`, `lpr -P 'Cups-PDF' 2.jpg` - 合并 PDF 文件:`pdfunite ~/Desktop/1.pdf ~/Desktop/2.pdf complete.pdf`。Cup 的 PDF 打印机使用原始文件的名称将文件输出到 ~/Desktop - 因此它们不能称为“books.*”,否则它们只是相互替换。您可以使用 `lpstat -p` 列出打印机及其名称。 (7认同)

To *_* Do 12

如果所有图像都在同一个文件夹中并且具有相同的扩展名,您可以执行以下操作:

将图像转换为 pdf:

ls *.tif | xargs -I% convert % %.pdf
Run Code Online (Sandbox Code Playgroud)

注意:请注意,如果它们被命名为 1...tif; 2...tif; 10...tif dols -1v用于编号文件

将 pdf 文件合并为一个 pdf 并删除单页 pdf:

pdftk *.pdf cat output merged.pdf && rm *.tif.pdf
Run Code Online (Sandbox Code Playgroud)