GithubHelp home page GithubHelp logo

ruby_powerpoint's Introduction

<img src=“https://badge.fury.io/rb/ruby_powerpoint.svg” alt=“Gem Version” /> <img src=“https://ruby-gem-downloads-badge.herokuapp.com/ruby_powerpoint?type=total&total_label=downloads” alt=“Downloads” />

RubyPowerpoint – Parser for Powerpoint (pptx) files.

ruby_powerpoint is a Ruby gem that can extract title, content and images from Powerpoint (pptx) slides.

Installation

RubyPowerpoint can be used from the command line or as part of a Ruby web framework. To install the gem using terminal, run the following command:

gem install ruby_powerpoint

To use it in Rails, add this line to your Gemfile:

gem "ruby_powerpoint"

Basic Usage

RubyPowerpoint can parse a PowerPoint file (pptx) by extracting text and images from each slide:

require 'ruby_powerpoint'

deck = RubyPowerpoint::Presentation.new "specs/fixtures/sample.pptx"

deck.slides.each do |slide|
  slide.content # => ["Presentation Notes...", "12345"]
  slide.title # => "Prsentation Header"
  slide.images # => ["\xE3=\xA8h\x8E\x17\...."] Byte Stream
  # Saving the image byte stream to a file:
  File.open('temp.jpg', 'w'){|f| f.puts slide.images[0].read}
end

Contributing

Contributions are welcomed. You can fork a repository, add your code changes to the forked branch, ensure all existing unit tests pass, create new unit tests cover your new changes and finally create a pull request.

After forking and then cloning the repository locally, install Bundler and then use it to install the development gem dependencies:

gem install bundler
bundle install

Once this is complete, you should be able to run the test suite:

rake

Bug Reporting

Please use the Issues page to report bugs or suggest new enhancements.

License

RubyPowerpoint has been published under MIT License

ruby_powerpoint's People

Contributors

blueplanet avatar ezraball-lux avatar mcmarius avatar mjy avatar om-nishu-trantor avatar pythonicrubyist avatar seanwalbran avatar vincent-pochet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ruby_powerpoint's Issues

PPT files

It is just a suggestion. This gem not support ppt files, so. If the scenario is extract the content from each ppt slide this gem does not help.
The code below convert the ppt file in a pptx file.
libreoffice --headless --invisible --convert-to pptx *.ppt
Maybe put this code to convert the file is a way to support ppt.
Anyway tnks for this gem, help me a lot.

Parsing Charts using this gem.

Hey, Amazing gem.

I wanted to know if it is possible to data from charts in the slide of pptx file.
If yes, please let me know how, It will be huge help. Even getting the chart title is enough.

In the attached screenshot, I want the text written in the titles/content itself.

Using your gem, I am able to get ["2 (Text)", "3 (Table)", "4 (Image)"] as output, but wanted to get [ "1 (Chart)", "2 (Text)", "3 (Table)", "4 (Image)"] returned from slide.content .

Thank you.

Warm regards,
Anuj Mohatkar

Edit power point text?

I would like to parse and change the powerpoint text. What is the best way of going about this?

bug export images

I followed the example and wanted to export the images of a pptx like this:
deck.slides.each do |slide|
File.open('temp.jpg', 'w'){|f| f.puts slide.images[0]}
end

the saved files are not valid images.
when I open them in an editor the only contain the line: #<Zip::InputStream:
are the generated files zip that need to be uncompressed?

Improve documentation for slide notes

It took me too long to figure out that the last entry in the ppt note array is the slide number. Could you please document this?

Another suggestion I would like to make is to return the notes_content as a hash instead of an array.

{
  <slide_number>: [note_content]
}

Iterating over slide notes thrown NoMethodError: undefined method 'xpath' for nil:NilClass

Iterating over slide notes when notes are missing for some of slides throws this error.

This is the offending line:

xml.xpath('//a:t').collect{ |node| node.text }

It is really problematic because there's no clean way to recover from this error without using rescue nil.

Edit: I checked the code again with the sample.pptx included in the specs/fixtures but couldn't reproduce it with sample.pptx. Not sure what could be causing it. I have 3 ppts and all of them exhibit the same behavior. I am afraid I am unable to share those ppts I'll see if I can try reproducing it with the included sample.pptx

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.