pdfinfo 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +29 -2
- data/lib/pdfinfo.rb +2 -6
- data/lib/pdfinfo/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4aaac914cb686f9cdd99edfbc378b8fbb4f91ef1
|
4
|
+
data.tar.gz: 404f4ebdb111f48bd5b538b03f1cc08a870d1dde
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c4b285a441417f340030ed932a18aabc294b3784c0d358165dcff2d220b46663b98a503c8c8cfa5b1a467edef02e1882cf8db8acd0a5c379fd9e3ffca5acf40
|
7
|
+
data.tar.gz: 10956090e1a0ca786a85470fe43928bac9a83bad46cb8d1dc61c88e78c90c29be9fee3248b376d727779eec160d2991ba3acf7b5100bd6760cf142f536de9495
|
data/README.md
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
# Pdfinfo
|
2
2
|
|
3
|
-
|
3
|
+
Simple ruby wrapper around the pdfinfo command
|
4
4
|
|
5
|
+
## Depdendecies
|
6
|
+
|
7
|
+
usage of this gem assumes that you have xpdf installed. The fastest way to install xpdf:
|
8
|
+
|
9
|
+
$ brew install xpdf
|
10
|
+
|
5
11
|
## Installation
|
6
12
|
|
7
13
|
Add this line to your application's Gemfile:
|
@@ -18,7 +24,28 @@ Or install it yourself as:
|
|
18
24
|
|
19
25
|
## Usage
|
20
26
|
|
21
|
-
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
pdfinfo = Pdfinfo.new("path/to/file.pdf")
|
30
|
+
|
31
|
+
pdfinfo.creator #=> "Creator Name" # or nil
|
32
|
+
pdfinfo.producer #=> "Producer Name" # or nil
|
33
|
+
pdfinfo.form #=> "none"
|
34
|
+
pdfinfo.page_count #=> 3
|
35
|
+
pdfinfo.width #=> 612
|
36
|
+
pdfinfo.height #=> 792
|
37
|
+
pdfinfo.size #=> 1521 # file size in bytes
|
38
|
+
pdfinfo.pdf_version #=> "1.3"
|
39
|
+
pdfinfo.encrypted? #=> false # or true
|
40
|
+
pdfinfo.tagged? #=> false # or true
|
41
|
+
```
|
42
|
+
|
43
|
+
You can directly set the location of the executable if its not located in your environment $PATH or you just want to point to a different location.
|
44
|
+
|
45
|
+
```ruby
|
46
|
+
Pdfinfo.pdfinfo_command = '/another/bin/path/pdfinfo'
|
47
|
+
Pdfinfo.pdfinfo_command #=> '/another/bin/path/pdfinfo'
|
48
|
+
```
|
22
49
|
|
23
50
|
## Contributing
|
24
51
|
|
data/lib/pdfinfo.rb
CHANGED
@@ -14,7 +14,7 @@ class Pdfinfo
|
|
14
14
|
:pdf_version
|
15
15
|
|
16
16
|
def self.exec(file_path)
|
17
|
-
stdout, stderr, status = Open3.capture2e("
|
17
|
+
stdout, stderr, status = Open3.capture2e("#{pdfinfo_command} #{file_path}")
|
18
18
|
stdout.chomp
|
19
19
|
end
|
20
20
|
|
@@ -27,7 +27,7 @@ class Pdfinfo
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def initialize(source_path)
|
30
|
-
info_hash = parse_shell_response(exec(source_path))
|
30
|
+
info_hash = parse_shell_response(Pdfinfo.exec(source_path))
|
31
31
|
|
32
32
|
@creator = info_hash['Creator']
|
33
33
|
@producer = info_hash['Producer']
|
@@ -50,10 +50,6 @@ class Pdfinfo
|
|
50
50
|
|
51
51
|
private
|
52
52
|
|
53
|
-
def exec(file_path)
|
54
|
-
self.class.exec(file_path)
|
55
|
-
end
|
56
|
-
|
57
53
|
def parse_shell_response(response_str)
|
58
54
|
Hash[response_str.split(/\n/).map {|kv| kv.split(/:\s+/) }]
|
59
55
|
end
|
data/lib/pdfinfo/version.rb
CHANGED