将.doc或.pdf转换为图像并在Ruby中显示缩略图? [英] Convert a .doc or .pdf to an image and display a thumbnail in Ruby?

查看:85
本文介绍了将.doc或.pdf转换为图像并在Ruby中显示缩略图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将.doc或.pdf转换为图像并在Ruby中显示缩略图吗?
有谁知道如何在Ruby中生成文档缩略图(或C,python ...)

Convert a .doc or .pdf to an image and display a thumbnail in Ruby?
Does anyone know how to generate document thumbnails in Ruby (or C, python...)

推荐答案

将PDF转换为PNG的简单RMagick示例为:

A simple RMagick example to convert a PDF to a PNG would be:

require 'RMagick'
pdf = Magick::ImageList.new("doc.pdf")
thumb = pdf.scale(300, 300)
thumb.write "doc.png"

要转换MS Word文档,将不会那么容易.最好的选择可能是先将其转换为PDF,然后再生成缩略图.生成PDF的选项在很大程度上取决于您所运行的操作系统.一种可能是使用OpenOffice和 Python Open Document Converter .您还可以尝试在线转换服务,包括 http://Zamzar.com .

To convert a MS Word document, it won't be as easy. Your best option may be to first convert it to a PDF before generating the thumbnail. Your options for generating the PDF depend heavily on the OS you're running on. One might be to use OpenOffice and the Python Open Document Converter. There are also online conversion services you could try, including http://Zamzar.com.

这篇关于将.doc或.pdf转换为图像并在Ruby中显示缩略图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆