问题描述
我想拍一张pdf并将其转换为图片...每个pdf页面都会成为一个单独的图片。
I'd like to take a pdf and convert it to images...each pdf page becoming a separate image.
这里有类似的帖子:
但它没有涵盖如何为每个页面制作单独的图像。
There's a similar post here: Convert a .doc or .pdf to an image and display a thumbnail in Ruby?But it doesn't cover how to make separate images for each page.
推荐答案
可以用PDF来实现。据推测,也可以这样做,但我不熟悉它。
ImageMagick can do that with PDFs. Presumably RMagick can do it too, but I'm not familiar with it.
编辑:
您链接到的帖子中的代码:
The code from the post you linked to:
require 'RMagick'
pdf = Magick::ImageList.new("doc.pdf")
pdf
是一个 ImageList
对象,根据将其许多方法委托给 Array
。您应该能够遍历 pdf
并调用写
将单个图像写入文件。
pdf
is an ImageList
object, which according to the documentation delegates many of its methods to Array
. You should be able to iterate over pdf
and call write
to write the individual images to files.
这篇关于使用RMagick& amp;将.pdf转换为图像红宝石的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!