【问题标题】:How to convert ppt to images in Ruby?如何在 Ruby 中将 ppt 转换为图像?
【发布时间】:2011-03-20 15:19:17
【问题描述】:

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

【问题讨论】:

    标签: ruby openoffice.org powerpoint


    【解决方案1】:

    我推荐使用Docsplit

    安装 gem,然后你可以做类似的事情:

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

    【讨论】:

      【解决方案2】:

      您可以使用RjbJODConverter 将您的PowerPoint 导出到Flash(或any other format)。

      这里有一段代码:

      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 添加到您的类路径

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-08-16
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-03-21
        • 1970-01-01
        • 2021-01-13
        相关资源
        最近更新 更多