Skip to content

Commit 707b830

Browse files
committed
Convert README to markdown
1 parent 36440c0 commit 707b830

File tree

2 files changed

+93
-93
lines changed

2 files changed

+93
-93
lines changed

README.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
```
2+
,____
3+
|---.\
4+
___ | `
5+
/ .-\ ./=)
6+
| |"|_/\/|
7+
; |-;| /_|
8+
/ \_| |/ \ |
9+
/ \/\( |
10+
| / |` ) |
11+
/ \ _/ |
12+
/--._/ \ |
13+
`/|) | /
14+
/ | |
15+
.' | |
16+
/ \ |
17+
(_.-.__.__./ /
18+
```
19+
20+
# Grim
21+
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.
23+
24+
## Prerequisites
25+
26+
You will need ghostscript, imagemagick, and poppler installed. On the Mac (OSX) I highly recommend using [Homebrew](http://mxcl.github.com/homebrew/) to get them installed.
27+
28+
```bash
29+
$ brew install ghostscript imagemagick poppler
30+
```
31+
32+
## Installation
33+
34+
```bash
35+
$ gem install grim
36+
```
37+
38+
## Usage
39+
40+
```ruby
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
45+
46+
pdf.each do |page|
47+
puts page.text
48+
end
49+
```
50+
51+
We also support using other processors (the default is whatever version of Imagemagick/Ghostscript is in your path).
52+
53+
```ruby
54+
# specifying one processor with specific ImageMagick and GhostScript paths
55+
Grim.processor = Grim::ImageMagickProcessor.new({:imagemagick_path => "/path/to/convert", :ghostscript_path => "/path/to/gs"})
56+
57+
# multiple processors with fallback if first fails, useful if you need multiple versions of convert/gs
58+
Grim.processor = Grim::MultiProcessor.new([
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"})
61+
])
62+
63+
pdf = Grim.reap('/path/to/pdf')
64+
```
65+
66+
It is also supported to use another ghostscript executable, which is especially interesting for windows users since the executable is named differently there.
67+
68+
```ruby
69+
# specifying another ghostscript executable, win64 in this example
70+
# the ghostscript/bin folder still has to be in the PATH for this to work
71+
Grim.processor = Grim::ImageMagickProcessor.new({:ghostscript_path => "gswin64c.exe"})
72+
73+
pdf = Grim.reap('/path/to/pdf')
74+
```
75+
76+
## Reference
77+
78+
* [jonmagic.com: Grim](http://jonmagic.com/blog/archives/2011/09/06/grim/)
79+
* [jonmagic.com: Grim MultiProcessor](http://jonmagic.com/blog/archives/2011/10/06/grim-multiprocessor-to-the-rescue/)
80+
81+
## Contributors
82+
83+
* [@jonmagic](https://github.com/jonmagic)
84+
* [@jnunemaker](https://github.com/jnunemaker)
85+
* [@bryckbost](https://github.com/bryckbost)
86+
* [@bkeepers](https://github.com/bkeepers)
87+
* [@BobaFaux](https://github.com/BobaFaux)
88+
* [@Rubikan](https://github.com/Rubikan)
89+
* [@victormier](https://github.com/victormier)
90+
91+
## License
92+
93+
See [LICENSE](LICENSE) for details.

README.textile

Lines changed: 0 additions & 93 deletions
This file was deleted.

0 commit comments

Comments
 (0)