开发者

Splitting PDF to png

I'm using paperclip to upload a pdf. Once the file is uploaded I need to split every page into a png. This is the command I think I need to use

convert -size 640x300 fileName.pdf slide.png

Now if I run that command 开发者_运维技巧from terminal it works fine, but I need a way of getting each slides name so I can add it into a model.

What's the best way to achieve this?


You should be able to have Paperclip do this conversion for you at the time of the upload, like this:

has_attached_file :pdfupload, :styles => { :pinged => ["640x300", :png] }

Then you can show the PNG version like so:

<%= image_tag @mymodel.pdfupload.url(:pinged) %>

(Obviously the name of the model and file will need to be changed to match yours.)


use `command` to execute system commads (`-quotes)

`convert -size 640x300 fileName.pdf slide.png`

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜