pdftoimage 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog.rdoc +3 -0
- data/lib/pdftoimage/image.rb +15 -3
- data/lib/pdftoimage/version.rb +1 -1
- data/spec/10pages.pdf +0 -0
- data/spec/pdftoimage_spec.rb +15 -1
- metadata +5 -4
data/ChangeLog.rdoc
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
=== 0.1.4 / 2010-11-15
|
2
|
+
* Fixed a bug concerning documents with page counts that are exact powers of 10. poppler_utils prepends one less zero to the page counts when a document count is a power of 10. This is now fixed in PDFToImage.
|
3
|
+
|
1
4
|
=== 0.1.3 / 2010-11-12
|
2
5
|
* Fixed a problem where PDF documents with more than 9 pages were not parsing properly. (embarrassing 0 padding problem.)
|
3
6
|
|
data/lib/pdftoimage/image.rb
CHANGED
@@ -86,12 +86,24 @@ module PDFToImage
|
|
86
86
|
end
|
87
87
|
|
88
88
|
def page_suffix
|
89
|
-
|
90
|
-
|
89
|
+
cur_page_len = @page.to_s.length
|
90
|
+
total_page_len = @page_count.to_s.length
|
91
|
+
|
92
|
+
num_zeroes = total_page_len - cur_page_len
|
93
|
+
|
94
|
+
# This is really weird. Basically, poppler_utils does not
|
95
|
+
# prepend a '0' to the page count when the total number of
|
96
|
+
# pages is 10, 100, 1000, 10000, etc. I hate putting this here,
|
97
|
+
# but whatever...
|
98
|
+
if @page_count.to_s.reverse.to_i == 1 && num_zeroes > 0
|
99
|
+
num_zeroes = num_zeroes - 1
|
100
|
+
end
|
101
|
+
|
102
|
+
if cur_page_len == total_page_len
|
91
103
|
@page
|
92
104
|
end
|
93
105
|
|
94
|
-
padded = '0' *
|
106
|
+
padded = '0' * num_zeroes + @page.to_s
|
95
107
|
padded
|
96
108
|
end
|
97
109
|
|
data/lib/pdftoimage/version.rb
CHANGED
data/spec/10pages.pdf
ADDED
Binary file
|
data/spec/pdftoimage_spec.rb
CHANGED
@@ -33,8 +33,22 @@ describe PDFToImage do
|
|
33
33
|
end
|
34
34
|
counter.should equal 3
|
35
35
|
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "multi page documents" do
|
39
|
+
it "should parse 10 page documents properly" do
|
40
|
+
counter = 0
|
41
|
+
PDFToImage.open('spec/10pages.pdf') do |page|
|
42
|
+
result = page.save("spec/10pg-#{page.page}.jpg")
|
43
|
+
File.exists?("spec/10pg-#{page.page}.jpg").should equal true
|
44
|
+
File.unlink("spec/10pg-#{page.page}.jpg")
|
45
|
+
counter = counter + 1
|
46
|
+
end
|
47
|
+
|
48
|
+
counter.should equal 10
|
49
|
+
end
|
36
50
|
|
37
|
-
it "should parse
|
51
|
+
it "should parse 11 page counts" do
|
38
52
|
counter = 0
|
39
53
|
PDFToImage.open('spec/11pages.pdf') do |page|
|
40
54
|
result = page.save("spec/11pg-#{page.page}.jpg")
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pdftoimage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 4
|
10
|
+
version: 0.1.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Rob Flynn
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-11-
|
18
|
+
date: 2010-11-15 00:00:00 +00:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -68,6 +68,7 @@ files:
|
|
68
68
|
- gemspec.yml
|
69
69
|
- ChangeLog.rdoc
|
70
70
|
- .rspec
|
71
|
+
- spec/10pages.pdf
|
71
72
|
- pdftoimage.gemspec
|
72
73
|
- .yardopts
|
73
74
|
- .bundle/config
|