如何将ppt转换为Ruby中的图像?
我使用Ruby在网页中显示powerpoint文件的内容。我已经找到了使用win32ole的解决方案,但我在linux环境中,它不起作用。我认为该应用程序可以触发一个openoffice命令进行转换 您可以使用和将powerpoint导出到flash(或) 下面是一段代码:如何将ppt转换为Ruby中的图像?,ruby,openoffice.org,powerpoint,Ruby,Openoffice.org,Powerpoint,我使用Ruby在网页中显示powerpoint文件的内容。我已经找到了使用win32ole的解决方案,但我在linux环境中,它不起作用。我认为该应用程序可以触发一个openoffice命令进行转换 您可以使用和将powerpoint导出到flash(或) 下面是一段代码: require 'rubygems' require 'rjb' classpath = nil Rjb::load( classpath, ['-Djava.awt.headless=true'] ) jFile =
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()
您需要启动OOo.org服务器:
soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard
要向类路径添加jodconverter-cli-X.X.X.jar
,我建议使用
安装gem,然后您可以执行以下操作:
Docsplit.extract_images(filename, :size => '920x', :format => [:png])