Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 73 lines (55 sloc) 2.37 kb
616d232 @jonmagic Dang reaper!
authored
1 <pre>
5ead8ff @jonmagic Added Mr. Grim!
authored
2 ,____
3 |---.\
4 ___ | `
5 / .-\ ./=)
6 | |"|_/\/|
7 ; |-;| /_|
8 / \_| |/ \ |
9 / \/\( |
10 | / |` ) |
11 / \ _/ |
12 /--._/ \ |
13 `/|) | /
14 / | |
15 .' | |
16 / \ |
17 (_.-.__.__./ /
616d232 @jonmagic Dang reaper!
authored
18 </pre>
5ead8ff @jonmagic Added Mr. Grim!
authored
19
b288477 @jonmagic Renamed to Grim and made it the base class without a module.
authored
20 h1. Grim
d0193f7 @jonmagic Created gem shell, wrote README, and updated gemspec.
authored
21
046ff54 @jonmagic Now people will know why its called Grim :)
authored
22 Grim is a simple gem for extracting (reaping) a page from a pdf and converting it to an image as well as extract the text from the page as a string. It basically gives you an easy to use api to ghostscript, imagemagick, and pdftotext specific to this use case.
d0193f7 @jonmagic Created gem shell, wrote README, and updated gemspec.
authored
23
24 h2. Prerequisites
25
2f6948d @jonmagic Moved to a Grim module with two classes, Pdf and Page. You can still …
authored
26 You will need ghostscript, imagemagick, and xpdf installed. On the Mac (OSX) I highly recommend using "Homebrew":http://mxcl.github.com/homebrew/ to get them installed.
27
28 <pre><code>
29 brew install ghostscript imagemagick xpdf
30 </code></pre>
31
32 h2. Installation
33
34 <pre><code>
35 gem install grim
36 </code></pre>
d0193f7 @jonmagic Created gem shell, wrote README, and updated gemspec.
authored
37
38 h2. Usage
39
40 <pre><code>
977329b @jonmagic Changed to Grim.reap and updated documentation everywhere.
authored
41 pdf = Grim.reap("/path/to/pdf") # returns Grim::Pdf instance for pdf
42 count = pdf.count # returns the number of pages in the pdf
43 png = pdf[3].save('/path/to/image.png') # will return true if page was saved or false if not
44 text = pdf[3].text # returns text as a String
2e83ace @jonmagic Added Enumerable to pdf class so we can iterate on pages.
authored
45
46 pdf.each do |page|
47 puts page.text
48 end
ecab1ed @jonmagic Trying to adhere to TomDoc and also un-nested specs since we don't ha…
authored
49 </pre></code>
50
060b99c @jonmagic Added processor classes.
authored
51 We also support using other processors (the default is whatever version of Imagemagick/Ghostscript is in your path).
52
53 <pre><code>
54 # specifying one processor with specific ImageMagick and GhostScript paths
3671c1d @jonmagic Reimplemented being able to pass in convert/gs paths.
authored
55 Grim.processor = Grim::ImageMagickProcessor.new({:imagemagick_path => "/path/to/convert", :ghostscript_path => "/path/to/gs"})
060b99c @jonmagic Added processor classes.
authored
56
57 # multiple processors with fallback if first fails, useful if you need multiple versions of convert/gs
b6f4800 @jonmagic fix typo in readme
authored
58 Grim.processor = Grim::MultiProcessor.new([
3671c1d @jonmagic Reimplemented being able to pass in convert/gs paths.
authored
59 Grim::ImageMagickProcessor.new({:imagemagick_path => "/path/to/6.7/convert", :ghostscript_path => "/path/to/9.04/gs"}),
60 Grim::ImageMagickProcessor.new({:imagemagick_path => "/path/to/6.6/convert", :ghostscript_path => "/path/to/9.02/gs"})
b6f4800 @jonmagic fix typo in readme
authored
61 ])
060b99c @jonmagic Added processor classes.
authored
62
63 pdf = Grim.reap('/path/to/pdf)
64 </code></pre>
65
4e8a601 @jonmagic Update README.textile
authored
66 h2. Reference
67
68 * http://jonmagic.com/blog/archives/2011/09/06/grim/
69 * http://jonmagic.com/blog/archives/2011/10/06/grim-multiprocessor-to-the-rescue/
70
ecab1ed @jonmagic Trying to adhere to TomDoc and also un-nested specs since we don't ha…
authored
71 h2. License
72
73 See LICENSE for details.
Something went wrong with that request. Please try again.