How to convert ppt to images in Ruby?

六眼飞鱼酱① 提交于 2019-11-27 21:56:27

问题


I'm using Ruby for displaying the contents of powerpoint files in a webpage. I've found solutions using the win32ole but I'm in the linux environment and it doesn't work. I think the application could trigger a openoffice command for conversion.


回答1:


I recommend using Docsplit.

Install the gem, and then you can do something like:

Docsplit.extract_images(filename, :size => '920x', :format => [:png])



回答2:


You can use Rjb and JODConverter to export your powerpoint to flash (or any other format).

Here is a pice of code to do it :

require 'rubygems'
require 'rjb'

classpath = nil

Rjb::load( classpath, ['-Djava.awt.headless=true'] )

jFile = Rjb::import( 'java.io.File' )
jSocketOpenOfficeConnection = Rjb::import( 'com.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection' )
jOpenOfficeDocumentConverter = Rjb::import( 'com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter' )

input = jFile.new( "your-doc.ppt" )
output = jFile.new( "your-doc.swf" )

# connect to an OpenOffice.org instance running on port 8100
connection = jSocketOpenOfficeConnection.new( 8100 )
connection.connect()

# convert
converter = jOpenOfficeDocumentConverter.new( connection )
converter.convert( input, output )

# close the connection
connection.disconnect()

You need to start an OOo.org server :

soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard

And to add jodconverter-cli-X.X.X.jar to your CLASSPATH



来源:https://stackoverflow.com/questions/3327441/how-to-convert-ppt-to-images-in-ruby

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!