如何在 Ruby 中将 ppt 转换为图像?

发布于 2024-09-10 22:59:00 字数 130 浏览 2 评论 0原文

我使用 Ruby 在网页中显示 powerpoint 文件的内容。我找到了使用 win32ole 的解决方案,但我在 linux 环境中,它不起作用。我认为该应用程序可以触发 openoffice 命令进行转换。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

旧城烟雨 2024-09-17 22:59:00

我建议使用 Docsplit

安装 gem,然后你可以执行以下操作:

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

I recommend using Docsplit.

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

Docsplit.extract_images(filename, :size => '920x', :format => [:png])
静谧 2024-09-17 22:59:00

您可以使用 RjbJODConverter 将您的 powerpoint 导出到 flash(或 任何其他格式)。

下面是一段代码:

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-XXXjar 添加到您的 CLASSPATH

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文