<p>Convert a .doc or .pdf to an image and display a thumbnail in Ruby?<br>
Does anyone know how to generate document thumbnails in Ruby (or C, python...)</p>

[{'answer_id': 65287, 'author': 'Loren Segal', 'author_id': 6436, 'author_profile': 'https://Stackoverflow.com/users/6436', 'pm_score': 0, 'selected': False, 'text': "<p>Not sure about .doc support in any open source library but ImageMagick (and the RMagick gem) can be compiled with pdf support (I think it's on by default)</p>\n"}, {'answer_id': 65344, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 0, 'selected': False, 'text': "<p>PDF support is a little buggy in ImageMagick - but it's by far the best OS way for ruby.  There's also a google summer of code project for pure Ruby PDF support.</p>\n\n<p>I've read stuff about using OpenOffice without the GUI to transform .doc files - but it'll be complicated at best.</p>\n"}, {'answer_id': 69015, 'author': 'Federico Builes', 'author_id': 161, 'author_profile': 'https://Stackoverflow.com/users/161', 'pm_score': 0, 'selected': False, 'text': "<p>As the 2 previous posters said, ImageMagick's probably the easiest way to generate the thumbnails.</p>\n\n<p>You could exec something like:</p>\n\n<pre><code>´convert -size 300x300 doc.pdf doc.png´\n</code></pre>\n\n<p>(The backquotes tell Ruby to shell it out).</p>\n\n<p>If you don't want to use exec to do the conversion you could use the RMagick gem to do it for you but it's probably a bit more of code.</p>\n"}, {'answer_id': 69804, 'author': 'tomafro', 'author_id': 7126, 'author_profile': 'https://Stackoverflow.com/users/7126', 'pm_score': 6, 'selected': True, 'text': '<p>A simple RMagick example to convert a PDF to a PNG would be:</p>\n\n<pre><code>require \'RMagick\'\npdf = Magick::ImageList.new("doc.pdf")\nthumb = pdf.scale(300, 300)\nthumb.write "doc.png"\n</code></pre>\n\n<p>To convert a MS Word document, it won\'t be as easy.  Your best option may be to first convert it to a PDF before generating the thumbnail.  Your options for generating the PDF depend heavily on the OS you\'re running on.  One might be to use OpenOffice and the <a href="http://www.artofsolving.com/opensource/pyodconverter" rel="noreferrer">Python Open Document Converter</a>.  There are also online conversion services you could try, including <a href="http://Zamzar.com" rel="noreferrer">http://Zamzar.com</a>.</p>\n'}, {'answer_id': 24267898, 'author': 'SciPhi', 'author_id': 765063, 'author_profile': 'https://Stackoverflow.com/users/765063', 'pm_score': 2, 'selected': False, 'text': '<p>Sample code to answer the comment by @aisensiy above :</p>\n\n<pre><code>require \'rmagick\'\npdf_path = "/path/to/interesting/file.pdf"\npage_index_path = pdf_path + "[0]" # first page in PDF\npdf_page = Magick::Image.read( page_index_path ).first # first item in Magick::ImageList\npdf_page.write( "/tmp/indexed-page.png" ) # implicit conversion based on file extension\n</code></pre>\n\n<p>Based on the path clue in answer to another question :</p>\n\n<p><a href="https://stackoverflow.com/a/6369524/765063">https://stackoverflow.com/a/6369524/765063</a></p>\n'}, {'answer_id': 30388902, 'author': 'Jan Klimo', 'author_id': 3678689, 'author_profile': 'https://Stackoverflow.com/users/3678689', 'pm_score': 0, 'selected': False, 'text': '<p>If you don\'t mind paying for Imgix, it <a href="https://www.imgix.com/docs/reference/pdf" rel="nofollow">handles PDFs</a> too. You get all the benefits of a fast CDN with it.</p>\n'}]
['https://Stackoverflow.com/questions/65250', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/-1/']