How to Convert Ppt to Images in Ruby

How convert powerpoint presentation in serverside to png

This is super-complicated (involves either reverse-engineering the various Microsoft PowerPoint formats, and re-rendering them as images, or else having a copy of PowerPoint on a server and writing code that will open files within it and screen capture them), and isn't something you're going to be able to do within Ruby on Rails.

Your best bet is to either 1) look into using SlideShare, or a similar service, via APIs and then embedding them within your side or 2) let people upload powerpoint files, and then if others want to view them, they have to download them again and re-open them within the application.

Or alternatively don't let people upload powerpoint files at all - instead get them to export their presentations as images or a PDF (which many browsers can view nowadays).

Rails image documents

Here are some common ones:

  • RMagick (probably most advanced one
  • ImageScience
  • MiniMagick

PS: you can convert PDFs to JPG to using RMagick :)

Edit: Converting MS Office Documents to images can be done using OpenOffice - here are two solutions:

  • JODConverter (See second answer)
  • Convert to PDF (using CUPS-PDF printer driver) like:

openoffice.org2.4 -norestore -nofirststartwizard -nologo -headless -pt Cups-PDF sample.ppt

and then you can convert the PDF to an image.

How to get a proper filepath of Tempfile in Rails when seeing Getting Errno::ENOENT ' no such file or directory @ rb_sysopen'

In your ensure you are using tempfile.close! this unlinks the file per https://ruby-doc.org/stdlib-2.5.3/libdoc/tempfile/rdoc/Tempfile.html#method-i-close-21

If you just use close without the bang (!) then you should be all set!



Related Topics



Leave a reply



Submit