如何将图片转换为pdf文件_将多页PDF文件转换为多个图像文件

如何将图片转换为pdf文件

In three previous articles here at Experts Exchange, I discussed the excellent (

在Experts Exchange的前三篇文章中,我讨论了出色的(

free!) GraphicsMagick package. The first article, Reduce the file size of many JPG files in many folders via an automated, mass, batch compression method, explains how to download and install GraphicsMagick, which is required for the solution presented in this new, fourth article utilizing GraphicsMagick. So if you don't already have GraphicsMagick installed, please read that article.

自由!通过自动批量批量压缩方法减少许多文件夹中许多JPG文件的文件大小”介绍了如何下载和安装GraphicsMagick,这是第四篇利用GraphicsMagick提出的解决方案所必需的。 因此,如果尚未安装GraphicsMagick,请阅读该文章。

The second article in the series, Create a PDF file with Contact Sheets (montage of thumbnails) for all JPG files in a folder and each of its subfolders using an automated, batch method, provides a solution to the question of creating a multi-page PDF file from many JPG files, while the third article, Create an image (BMP, GIF, JPG, PNG, TIF, etc.) from a multi-page PDF, provides a solution for creating a JPG file from a multi-page PDF file. This new article addresses a similar, yet different, requirement from a recent question here at EE, namely, conversion of a multi-page PDF into multiple image files — one image file for each page of the PDF.

该系列的第二篇文章, 使用自动批处理方法为文件夹及其每个子文件夹中的所有JPG文件创建带有联系表(缩略图的蒙太奇)的PDF文件,为创建多页问题提供了解决方案来自许多JPG文件的PDF文件,而第三篇文章, 从多页PDF创建图像(BMP,GIF,JPG,PNG,TIF等)提供了一种从多页PDF创建JPG文件的解决方案文件。 这篇新文章提出了与EE近期的一个问题类似但又不同的要求,即将多页PDF转换为多个图像文件-PDF的每一页一个图像文件。

As with the other solutions, this one is amazingly simple — a single command line call to GraphicsMagick! Here's an example of what the solution looks like:

与其他解决方案一样,这个解决方案非常简单-对GraphicsMagick的单个命令行调用! 这是解决方案的示例:

gm.exe convert input.pdf +adjoin output%02d.jpg

The key to the solution is the +adjoin option, with the "+" being crucial. This tells GraphicsMagick to convert the input file into multiple, numbered output files. Because of this, the output file name must include a printf style formatting specification for the numeric part of the output file name (it may have any string for the leading part of the file name). There are many options in specifying the printf formats, and a complete explanation of printf is beyond the scope of this article. However, for the sake of completeness, let's take a look at the options used in the line of code above:

解决方案的关键是+ adjoin选项,其中“ + ”至关重要。 这告诉GraphicsMagick将输入文件转换为多个编号的输出文件。 因此,输出文件名必须包含针对输出文件名的数字部分的printf样式格式规范(文件名的开头部分可以具有任何字符串)。 还有在指定printf格式的多种选择,和printf的完整解释超出了本文的范围。 但是,为了完整起见,让我们看一下上面的代码行中使用的选项:

%02d

%02d

The "%" is always the beginning character of a printf format. The "d" means that the generated value is a decimal integer and the "02" means that it should be two digits in length, padded with a "0" on the left when necessary. With this explanation, the printf format used in the code sample above will result in these files:

“%”始终是printf格式的开始字符。 “ d”表示生成的值是十进制整数,“ 02”表示长度应为两位数,必要时在其左侧填充“ 0”。 有了这个解释,以上代码示例中使用的printf格式将产生以下文件:

output00.jpg

output00.jpg

output01.jpg

output01.jpg

output02.jpg

output02.jpg

Likewise, if the line of code above ended in...

同样,如果上面的代码行以...结尾

image_%03d.jpg

image_%03d.jpg

...the resulting files would be:

...结果文件将是:

image_000.jpg

image_000.jpg

image_001.jpg

image_001.jpg

image_002.jpg

image_002.jpg

If you'd like to learn more about printf, a web search will provide much to study.

如果您想了解有关printf的更多信息,则网络搜索将为您提供很多学习机会。

Here's another example, shown by a screenshot of the results in a Command Prompt window before and after running the gm.exe command on the six-page PDF file attached to my previous GraphicsMagick article:

这是另一个示例,通过在我之前的GraphicsMagick文章附带的六页PDF文件上运行gm.exe命令前后,在命令提示符窗口中显示了结果的屏幕截图:

GM-command-prompt-results.jpg

The screenshot shows that there was a single PDF file in the folder before issuing the command (input.pdf) and six JPG files after it ran.

屏幕截图显示,在发出命令(input.pdf)之前,文件夹中只有一个PDF文件,而在运行之后,有六个JPG文件。

There are many more options in the convert sub-command, such as those mentioned in my other three articles, as well as in the documentation at the GraphicsMagick website. If you need more control over the output images, I recommend experimenting with the numerous options.

convert子命令中还有更多选项,例如我的其他三篇文章以及GraphicsMagick网站上文档中提到的选项。 如果您需要对输出图像的更多控制,建议您尝试多种选择。

If you find this article to be helpful, please click the thumbs-up icon below. This lets me know what is valuable for EE members and provides direction for future articles. Thanks very much! Regards, Joe

如果您发现本文有帮助,请单击下面的大拇指图标。 这使我知道什么对EE成员有价值,并为以后的文章提供了指导。 非常感谢! 问候乔

翻译自: https://www.experts-exchange.com/articles/23019/Convert-a-multi-page-PDF-file-into-multiple-image-files.html

如何将图片转换为pdf文件

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值