pdftoimage 0.1.6 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 2a7ff47bfe4c829a2912d1e88413d06ffe3e4d321896d2a3f5d2ab571d98e863
4
+ data.tar.gz: 641ae71e08ce8b7f7e011836169feec866be1a7edb1c194995008bf582b8b3e2
5
+ SHA512:
6
+ metadata.gz: c6ac26519e1ad5f28e904cf609113d9c5c4c52c26786e668f82511b139f8bcc55a6320623367e4738e4aa5a734625e1fb76e8a6e6ec07c01a4ad38db49869192
7
+ data.tar.gz: bcec5c69d21c6abd963e4a8c7003246969b8dc5c19e57059489ebc244e589c797c1e03108c96f24349f33bedb2b0087851d8a5421bc315e5a5bc7d721c6fb22f
data/ChangeLog.rdoc CHANGED
@@ -1,7 +1,17 @@
1
+ === 0.1.7 / 2018-05-01
2
+ * Fixed use of deprecated File.exists? method (pr#4 from Thornolf)
3
+ * File paths are now escaped to properly handle spaces and special characters (pr#3 from drnic)
4
+ * Specifying dpi resolution is now supported (pr#5 from lehf)
5
+
6
+ === 0.1.7 / 2018-05-01
7
+ * Updated yard to resolve a vulnerability.
8
+
1
9
  === 0.1.6 / 2011-07-13
2
10
  * Buggy PDF generators try to encode CreationDate and ModDate as UTF-16 as opposed to ASCII. This leads to parsing errors where the code was assuming UTF-8 encoding was in use.
11
+
3
12
  === 0.1.5 / 2011-03-08
4
13
  * Fixed a bug due to the fact that poppler_utils no longer leaves off the extra padded zero.
14
+
5
15
  === 0.1.4 / 2010-11-15
6
16
  * 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.
7
17
 
@@ -16,4 +26,3 @@
16
26
  === 0.1.1 / 2010-11-10
17
27
 
18
28
  * Initial release:
19
-
data/README.rdoc CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  == Description
6
6
 
7
- PDFToImage is a ruby gem which allows for conversion of a PDF document into
7
+ PDFToImage is a ruby gem which allows for conversion of a PDF document into
8
8
  images. It uses poppler_utils to first convert the document to PNG and then
9
9
  allows usage of ImageMagick to convert the image into other formats.
10
10
 
@@ -25,6 +25,14 @@ to be able to parse without error.
25
25
  page.resize('150').quality('80%').save('out/thumbnail-#{page.page}.jpg")
26
26
  end
27
27
 
28
+ require 'pdftoimage'
29
+ PDFToImage.open('anotherpdf.pdf') do |page|
30
+ # Set the resolution to 350dpi
31
+ page.r(350).save('out/thumbnail-#{page.page}.jpg")
32
+ end
33
+
34
+
35
+
28
36
  == Requirements
29
37
 
30
38
  poppler_utils
@@ -38,6 +46,6 @@ ImageMagick
38
46
 
39
47
  == Copyright
40
48
 
41
- Copyright (c) 2010 Rob Flynn
49
+ Copyright (c) 2023 Rob Flynn
42
50
 
43
- See LICENSE.txt for details.
51
+ See LICENSE for details.
@@ -1,115 +1,133 @@
1
1
  module PDFToImage
2
-
3
- # A class which is instantiated by PDFToImage when a PDF document
4
- # is opened.
5
- class Image
6
- attr_reader :pdf_name
7
- attr_reader :filename
8
- attr_reader :width
9
- attr_reader :height
10
- attr_reader :page
11
- attr_reader :args
12
- attr_reader :opened
13
-
14
- # ImageMagick methods that we currently support.
15
- CUSTOM_IMAGE_METHODS = [
16
- "resize",
17
- "quality"
18
- ]
19
-
20
- CUSTOM_IMAGE_METHODS.each do |method|
21
- define_method(method.to_sym) do |*args|
22
- @args << "-#{method} #{args.join(' ')}"
23
-
24
- self
25
- end
26
- end
27
-
28
- # Image constructor
29
- #
30
- # @param [filename] The name of the image file to open
31
- def initialize(pdf_name, filename, page, page_size, page_count)
32
- @args = []
33
-
34
- @pdf_name = pdf_name
35
- @filename = filename
36
- @opened = false
37
- @width = page_size[:width]
38
- @height = page_size[:height]
39
- @page_count = page_count
40
-
41
- @page = page
42
- end
43
-
44
- # Saves the converted image to the specified location
45
- #
46
- # @param [outname] The output filename of the image
47
- #
48
- def save(outname)
49
-
50
- generate_temp_file
51
-
52
- cmd = "convert "
53
-
54
- if not @args.empty?
55
- cmd += "#{@args.join(' ')} "
56
- end
57
-
58
- cmd += "#{@filename} #{outname}"
59
-
60
- PDFToImage::exec(cmd)
61
-
62
- return true
63
- end
64
-
65
- def <=>(img)
66
- if @page == img.page
67
- return 0
68
- elsif @page < img.page
69
- return -1
70
- else
71
- return 1
72
- end
2
+ # A class which is instantiated by PDFToImage when a PDF document
3
+ # is opened.
4
+ class Image
5
+ attr_reader :pdf_name
6
+ attr_reader :filename
7
+ attr_reader :width
8
+ attr_reader :height
9
+ attr_reader :page
10
+ attr_reader :args
11
+ attr_reader :pdf_args
12
+ attr_reader :opened
13
+
14
+ # ImageMagick methods that we currently support.
15
+ CUSTOM_IMAGE_METHODS = [
16
+ "resize",
17
+ "quality"
18
+ ]
19
+
20
+ # pdftoppm methods that we currently support.
21
+ PDF_IMAGE_METHODS = [
22
+ "r",
23
+ "rx",
24
+ "ry"
25
+ ]
26
+
27
+ CUSTOM_IMAGE_METHODS.each do |method|
28
+ define_method(method.to_sym) do |*args|
29
+ @args << "-#{method} #{args.join(' ')}"
30
+
31
+ self
32
+ end
33
+ end
34
+
35
+ PDF_IMAGE_METHODS.each do |method|
36
+ define_method(method.to_sym) do |*args|
37
+ @pdf_args << "-#{method} #{args.join(' ')}"
38
+
39
+ self
40
+ end
41
+ end
42
+
43
+ # Image constructor
44
+ #
45
+ # @param pdf_name [String] The name of the PDF
46
+ # @param filename [String] The name of the image for the specified page
47
+ # @param page [Integer] The page number of the PDF
48
+ # @param page_size [Hash] Hash containing width and height dimensions of the page
49
+ # @param page_count [integer] The number of pages in the PDF
50
+ #
51
+ def initialize(pdf_name, filename, page, page_size, page_count)
52
+ @args = []
53
+ @pdf_args = []
54
+
55
+ @pdf_name = pdf_name
56
+ @filename = filename
57
+ @opened = false
58
+ @width = page_size[:width]
59
+ @height = page_size[:height]
60
+ @page_count = page_count
61
+
62
+ @page = page
63
+ end
64
+
65
+ # Saves the converted image to the specified location
66
+ #
67
+ # @param outname [String] The output filename of the image
68
+ #
69
+ def save(outname)
70
+ generate_temp_file
71
+
72
+ cmd = "convert "
73
+
74
+ if not @args.empty?
75
+ cmd += "#{@args.join(' ')} "
76
+ end
77
+
78
+ cmd += "#{Shellwords.escape(@filename)} #{Shellwords.escape(outname)}"
79
+
80
+ PDFToImage.exec(cmd)
81
+
82
+ return true
83
+ end
84
+
85
+ def <=>(img)
86
+ if @page == img.page
87
+ return 0
88
+ elsif @page < img.page
89
+ return -1
90
+ else
91
+ return 1
92
+ end
93
+ end
94
+
95
+ private
96
+
97
+ def generate_temp_file
98
+ if @opened == false
99
+ cmd = "pdftoppm -png -f #{@page} #{@pdf_args.join(" ")} -l #{@page} #{Shellwords.escape(@pdf_name)} #{Shellwords.escape(@filename)}"
100
+ PDFToImage.exec(cmd)
101
+ @filename = "#{@filename}-#{page_suffix}.png"
102
+ @opened = true
103
+ end
104
+
105
+ return true
106
+ end
107
+
108
+ def page_suffix
109
+ cur_page_len = @page.to_s.length
110
+ total_page_len = @page_count.to_s.length
111
+
112
+ num_zeroes = total_page_len - cur_page_len
113
+
114
+ # This is really weird. Basically, poppler_utils does not
115
+ # prepend a '0' to the page count when the total number of
116
+ # pages is 10, 100, 1000, 10000, etc. I hate putting this here,
117
+ # but whatever...
118
+
119
+ # TODO: Keep an eye on this. This suddenly started causing problems.
120
+ # Did poppler_utils change?
121
+ # if @page_count.to_s.reverse.to_i == 1 && num_zeroes > 0
122
+ # num_zeroes = num_zeroes - 1
123
+ # end
124
+
125
+ if cur_page_len == total_page_len
126
+ @page
127
+ end
128
+
129
+ padded = '0' * num_zeroes + @page.to_s
130
+ padded
131
+ end
73
132
  end
74
-
75
- private
76
-
77
- def generate_temp_file
78
- if @opened == false
79
- cmd = "pdftoppm -png -f #{@page} -l #{@page} #{@pdf_name} #{@filename}"
80
- PDFToImage::exec(cmd)
81
- @filename = "#{@filename}-#{page_suffix}.png"
82
- @opened = true
83
- end
84
-
85
- return true
86
- end
87
-
88
- def page_suffix
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
-
99
- # TODO: Keep an eye on this. This suddenly started causing problems.
100
- # Did poppler_utils change?
101
- # if @page_count.to_s.reverse.to_i == 1 && num_zeroes > 0
102
- # num_zeroes = num_zeroes - 1
103
- # end
104
-
105
- if cur_page_len == total_page_len
106
- @page
107
- end
108
-
109
- padded = '0' * num_zeroes + @page.to_s
110
- padded
111
- end
112
-
113
- end
114
-
115
133
  end
@@ -1,4 +1,4 @@
1
1
  module PDFToImage
2
- # pdftoimage version
3
- VERSION = "0.1.6"
2
+ # pdftoimage version
3
+ VERSION = "0.2.0"
4
4
  end
data/lib/pdftoimage.rb CHANGED
@@ -1,117 +1,116 @@
1
- require 'tmpdir'
2
1
  require 'pdftoimage/version'
3
2
  require 'pdftoimage/image'
3
+
4
+ require 'tmpdir'
4
5
  require 'iconv'
6
+ require 'shellwords'
5
7
 
6
8
  module PDFToImage
7
- class PDFError < RuntimeError; end
9
+ class PDFError < RuntimeError; end
8
10
  end
9
11
 
10
12
  module PDFToImage
11
- # A class variable for storing the location of our temp folder
12
- @@pdf_temp_dir = File.join(Dir.tmpdir())
13
-
14
- begin
15
- tmp = `pdftoppm -v 2>&1`
16
- raise(PDFToImage::PDFError, "poppler_utils not installed") unless tmp.index('Poppler')
17
- rescue Errno::ENOENT
18
- raise PDFToImage::PDFError, "poppler_utils not installed"
19
- end
20
-
21
- begin
22
- tmp = `identify -version 2>&1`
23
- raise(PDFToImage::PDFError, "ImageMagick not installed") unless tmp.index('ImageMagick')
24
- rescue Errno::ENOENT
25
- raise PDFToImage::PDFError, "ImageMagick not installed"
26
- end
27
-
28
- class << self
13
+ # A class variable for storing the location of our temp folder
14
+ @@pdf_temp_dir = File.join(Dir.tmpdir())
15
+
16
+ begin
17
+ tmp = `pdftoppm -v 2>&1`
18
+ raise(PDFToImage::PDFError, "poppler_utils not installed") unless tmp.index('Poppler')
19
+ rescue Errno::ENOENT
20
+ raise PDFToImage::PDFError, "poppler_utils not installed"
21
+ end
29
22
 
30
- # Opens a PDF document and prepares it for splitting into images.
31
- #
32
- # @param [filename] The filename of the PDF to open
33
- # @return [Array] An array of images
34
- def open(filename, &block)
35
- if not File.exists?(filename)
36
- raise PDFError, "File '#{filename}' not found."
37
- end
23
+ begin
24
+ tmp = `identify -version 2>&1`
25
+ raise(PDFToImage::PDFError, "ImageMagick not installed") unless tmp.index('ImageMagick')
26
+ rescue Errno::ENOENT
27
+ raise PDFToImage::PDFError, "ImageMagick not installed"
28
+ end
38
29
 
39
- pages = page_count(filename)
30
+ class << self
31
+ # Opens a PDF document and prepares it for splitting into images.
32
+ #
33
+ # @param filename [String] The filename of the PDF to open
34
+ #
35
+ # @return [Array] An array of images
36
+ def open(filename, &block)
37
+ if not File.exist?(filename)
38
+ raise PDFError, "File '#{filename}' not found."
39
+ end
40
40
 
41
- # Array of images
42
- images = []
41
+ pages = page_count(filename)
43
42
 
44
- 1.upto(pages) { |n|
45
- dimensions = page_size(filename, n)
46
- image = Image.new(filename, random_filename, n, dimensions, pages)
47
- images << image
48
- }
43
+ # Array of images
44
+ images = []
49
45
 
50
- images.each(&block) if block_given?
46
+ 1.upto(pages) { |n|
47
+ dimensions = page_size(filename, n)
48
+ image = Image.new(filename, random_filename, n, dimensions, pages)
49
+ images << image
50
+ }
51
51
 
52
- return images
52
+ images.each(&block) if block_given?
53
53
 
54
- end
55
-
56
- # Executes the specified command, returning the output.
57
- #
58
- # @param [cmd] The command to run
59
- # @return [String] The output of the command
60
- def exec(cmd, error = nil)
61
- output = `#{cmd}`
62
- if $? != 0
63
- if error == nil
64
- raise PDFError, "Error executing command: #{cmd}"
65
- else
66
- raise PDFError, error
54
+ return images
67
55
  end
68
- end
69
56
 
70
- return output
71
- end
57
+ # Executes the specified command, returning the output.
58
+ #
59
+ # @param cmd [String] The command to run
60
+ # @return [String] The output of the command
61
+ def exec(cmd, error = nil)
62
+ output = `#{cmd}`
63
+ if $? != 0
64
+ if error == nil
65
+ raise PDFError, "Error executing command: #{cmd}"
66
+ else
67
+ raise PDFError, error
68
+ end
69
+ end
70
+
71
+ return output
72
+ end
72
73
 
73
- private
74
+ private
74
75
 
75
- def page_size(filename, page)
76
- cmd = "pdfinfo -f #{page} -l #{page} #{filename} | grep Page"
77
- output = exec(cmd)
76
+ def page_size(filename, page)
77
+ cmd = "pdfinfo -f #{page} -l #{page} #{Shellwords.escape(filename)} | grep Page"
78
+ output = exec(cmd)
78
79
 
79
- matches = /^Page.*?size:.*?(\d+).*?(\d+)/.match(output)
80
- if matches.nil?
81
- raise PDFError, "Unable to determine page size."
82
- end
80
+ matches = /^Page.*?size:.*?(\d+).*?(\d+)/.match(output)
81
+ if matches.nil?
82
+ raise PDFError, "Unable to determine page size."
83
+ end
83
84
 
84
- scale = 2.08333333333333333
85
- dimension = {
86
- :width => (matches[1].to_i * scale).to_i,
87
- :height => (matches[2].to_i * scale).to_i
88
- }
85
+ scale = 2.08333333333333333
86
+ dimension = {
87
+ width: (matches[1].to_i * scale).to_i,
88
+ height: (matches[2].to_i * scale).to_i
89
+ }
89
90
 
90
- dimension
91
- end
91
+ dimension
92
+ end
92
93
 
93
- def page_count(filename)
94
- cmd = "pdfinfo #{filename} | grep Pages"
95
- output = exec(cmd)
96
- matches = /^Pages:.*?(\d+)$/.match(output)
97
- if matches.nil?
98
- raise PDFError, "Error determining page count."
99
- end
94
+ def page_count(filename)
95
+ cmd = "pdfinfo #{Shellwords.escape(filename)} | grep Pages"
96
+ output = exec(cmd)
97
+ matches = /^Pages:.*?(\d+)$/.match(output)
98
+ if matches.nil?
99
+ raise PDFError, "Error determining page count."
100
+ end
100
101
 
101
- return matches[1].to_i
102
- end
102
+ return matches[1].to_i
103
+ end
103
104
 
104
- # Generate a random file name in the system's tmp folder
105
- def random_filename
106
- File.join(@@pdf_temp_dir, random_name)
107
- end
105
+ # Generate a random file name in the system's tmp folder
106
+ def random_filename
107
+ File.join(@@pdf_temp_dir, random_name)
108
+ end
108
109
 
109
- # Generate a random name of {#length} characters.
110
- def random_name(length = 15)
111
- @@chars ||= ("a".."z").to_a + ("A".."Z").to_a + ("1".."9").to_a
112
- return 'pdftoimage-' + Array.new(length, '').collect{@@chars[rand(@@chars.size)]}.join
110
+ # Generate a random name of {#length} characters.
111
+ def random_name(length = 15)
112
+ @@chars ||= ("a".."z").to_a + ("A".."Z").to_a + ("1".."9").to_a
113
+ return 'pdftoimage-' + Array.new(length, '').collect { @@chars[rand(@@chars.size)] }.join
114
+ end
113
115
  end
114
-
115
- end
116
-
117
116
  end
metadata CHANGED
@@ -1,99 +1,79 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: pdftoimage
3
- version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 0.1.6
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
6
5
  platform: ruby
7
- authors:
6
+ authors:
8
7
  - Rob Flynn
9
- autorequire:
8
+ autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
-
13
- date: 2011-07-13 00:00:00 -04:00
14
- default_executable:
15
- dependencies:
16
- - !ruby/object:Gem::Dependency
17
- name: bundler
11
+ date: 2023-04-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: iconv
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
18
21
  prerelease: false
19
- requirement: &id001 !ruby/object:Gem::Requirement
20
- none: false
21
- requirements:
22
- - - ~>
23
- - !ruby/object:Gem::Version
24
- version: 1.0.0
25
- type: :development
26
- version_requirements: *id001
27
- - !ruby/object:Gem::Dependency
28
- name: yard
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: shellwords
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.1.0
34
+ type: :runtime
29
35
  prerelease: false
30
- requirement: &id002 !ruby/object:Gem::Requirement
31
- none: false
32
- requirements:
33
- - - ~>
34
- - !ruby/object:Gem::Version
35
- version: 0.6.0
36
- type: :development
37
- version_requirements: *id002
38
- description: A ruby gem for converting PDF documents into a series of images. This module is based off poppler_utils and ImageMagick.
39
- email:
40
- - rob@thingerly.com
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.1.0
41
+ description: A ruby gem for converting PDF documents into a series of images. This
42
+ module is based off poppler_utils and ImageMagick.
43
+ email: rob@thingerly.com
41
44
  executables: []
42
-
43
45
  extensions: []
44
-
45
- extra_rdoc_files:
46
- - README.rdoc
47
- - ChangeLog.rdoc
48
- - LICENSE.txt
49
- files:
50
- - .bundle/config
51
- - .document
52
- - .rspec
53
- - .yardopts
46
+ extra_rdoc_files: []
47
+ files:
54
48
  - ChangeLog.rdoc
55
- - Gemfile
56
- - Gemfile.lock
57
- - LICENSE.txt
49
+ - LICENSE
58
50
  - README.rdoc
59
- - Rakefile
60
- - gemspec.yml
61
51
  - lib/pdftoimage.rb
62
52
  - lib/pdftoimage/image.rb
63
53
  - lib/pdftoimage/version.rb
64
- - pdftoimage.gemspec
65
- - spec/10pages.pdf
66
- - spec/11pages.pdf
67
- - spec/3pages.pdf
68
- - spec/pdftoimage_spec.rb
69
- - spec/spec_helper.rb
70
- has_rdoc: yard
71
54
  homepage: https://github.com/robflynn/pdftoimage
72
- licenses:
55
+ licenses:
73
56
  - MIT
74
- post_install_message:
57
+ metadata:
58
+ changelog_uri: https://github.com/robflynn/pdftoimage/blob/master/ChangeLog.rdoc
59
+ source_code_uri: https://github.com/robflynn/pdftoimage/
60
+ post_install_message:
75
61
  rdoc_options: []
76
-
77
- require_paths:
62
+ require_paths:
78
63
  - lib
79
- required_ruby_version: !ruby/object:Gem::Requirement
80
- none: false
81
- requirements:
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ requirements:
82
66
  - - ">="
83
- - !ruby/object:Gem::Version
84
- version: "0"
85
- required_rubygems_version: !ruby/object:Gem::Requirement
86
- none: false
87
- requirements:
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ requirements:
88
71
  - - ">="
89
- - !ruby/object:Gem::Version
90
- version: 1.3.6
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
91
74
  requirements: []
92
-
93
- rubyforge_project: pdftoimage
94
- rubygems_version: 1.6.2
95
- signing_key:
96
- specification_version: 3
75
+ rubygems_version: 3.0.9
76
+ signing_key:
77
+ specification_version: 4
97
78
  summary: A ruby gem for converting PDF documents into a series of images.
98
- test_files:
99
- - spec/pdftoimage_spec.rb
79
+ test_files: []
data/.bundle/config DELETED
@@ -1,2 +0,0 @@
1
- --- {}
2
-
data/.document DELETED
@@ -1,3 +0,0 @@
1
- -
2
- ChangeLog.*
3
- LICENSE.txt
data/.rspec DELETED
@@ -1 +0,0 @@
1
- --colour --format documentation
data/.yardopts DELETED
@@ -1 +0,0 @@
1
- --markup rdoc --title "pdftoimage Documentation" --protected
data/Gemfile DELETED
@@ -1,12 +0,0 @@
1
- source :rubygems
2
-
3
- gemspec
4
-
5
- group :development do
6
- gem 'rake', '~> 0.8.7'
7
- gem 'ore-core', '~> 0.1.0'
8
- gem 'rspec', '>= 2.1.0'
9
- gem 'yard', '~> 0.6.0'
10
- gem 'autotest'
11
- gem 'spork'
12
- end
data/Gemfile.lock DELETED
@@ -1,35 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- pdftoimage (0.1.6)
5
-
6
- GEM
7
- remote: http://rubygems.org/
8
- specs:
9
- autotest (4.4.4)
10
- diff-lcs (1.1.2)
11
- ore-core (0.1.5)
12
- rake (0.8.7)
13
- rspec (2.1.0)
14
- rspec-core (~> 2.1.0)
15
- rspec-expectations (~> 2.1.0)
16
- rspec-mocks (~> 2.1.0)
17
- rspec-core (2.1.0)
18
- rspec-expectations (2.1.0)
19
- diff-lcs (~> 1.1.2)
20
- rspec-mocks (2.1.0)
21
- spork (0.8.4)
22
- yard (0.6.2)
23
-
24
- PLATFORMS
25
- ruby
26
-
27
- DEPENDENCIES
28
- autotest
29
- bundler (~> 1.0.0)
30
- ore-core (~> 0.1.0)
31
- pdftoimage!
32
- rake (~> 0.8.7)
33
- rspec (>= 2.1.0)
34
- spork
35
- yard (~> 0.6.0)
data/Rakefile DELETED
@@ -1,26 +0,0 @@
1
- require 'rubygems'
2
-
3
- begin
4
- require 'bundler'
5
- rescue LoadError => e
6
- STDERR.puts e.message
7
- STDERR.puts "Run `gem install bundler` to install Bundler."
8
- exit e.status_code
9
- end
10
-
11
- begin
12
- Bundler.setup(:development)
13
- rescue Bundler::BundlerError => e
14
- STDERR.puts e.message
15
- STDERR.puts "Run `bundle install` to install missing gems."
16
- exit e.status_code
17
- end
18
-
19
- require 'rake'
20
-
21
- require 'rspec/core/rake_task'
22
- RSpec::Core::RakeTask.new
23
- task :default => :spec
24
-
25
- require 'yard'
26
- YARD::Rake::YardocTask.new
data/gemspec.yml DELETED
@@ -1,13 +0,0 @@
1
- name: pdftoimage
2
- summary: "A ruby gem for converting PDF documents into a series of images."
3
- description: "A ruby gem for converting PDF documents into a series of images. This module is based off poppler_utils and ImageMagick."
4
- license: MIT
5
- authors: Rob Flynn
6
- homepage: https://github.com/robflynn/pdftoimage
7
- email: rob@thingerly.com
8
- has_yard: true
9
-
10
- development_dependencies:
11
- bundler: ~> 1.0.0
12
- yard: ~> 0.6.0
13
-
data/pdftoimage.gemspec DELETED
@@ -1,15 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
-
3
- begin
4
- Ore::Specification.new do |gemspec|
5
- # custom logic here
6
- end
7
- rescue NameError
8
- begin
9
- require 'ore/specification'
10
- retry
11
- rescue LoadError
12
- STDERR.puts "The 'my-project.gemspec' file requires Ore."
13
- STDERR.puts "Run `gem install ore-core` to install Ore."
14
- end
15
- end
data/spec/10pages.pdf DELETED
Binary file
data/spec/11pages.pdf DELETED
Binary file
data/spec/3pages.pdf DELETED
Binary file
@@ -1,83 +0,0 @@
1
- require 'spec_helper'
2
- require 'pdftoimage'
3
-
4
- describe PDFToImage do
5
- it "should have a VERSION constant" do
6
- PDFToImage.const_get('VERSION').should_not be_empty
7
- end
8
-
9
- # I will find a better solution for having this commented out. I do not
10
- # have permission to release the document that I used for this test case.
11
- # I will generate a sufficiently buggy version. Basically, buggy PDF software
12
- # sometimes corrupts CreationDate and/or ModDate such as discussed here: http://www.linuxquestions.org/questions/solaris-opensolaris-20/converting-utf-16-files-to-another-encoding-such-as-utf-8-a-630588/
13
- # I also need to come upw ith a better solution
14
-
15
- # describe "edge cases" do
16
- # it "should handle invalid utf-8 in headers without crashing" do
17
- # @pages = PDFToImage.open('spec/weird_utf8.pdf')
18
- # @pages.size.should equal 1
19
- # @pages[0].resize('50%').save('spec/tmp1.jpg')
20
- # File.exists?('spec/tmp1.jpg').should equal true
21
- # File.unlink('spec/tmp1.jpg')
22
- # end
23
- # end
24
-
25
- describe "3pages.pdf" do
26
- it "should have three pages" do
27
- @pages = PDFToImage.open('spec/3pages.pdf')
28
- @pages.size.should equal 3
29
- end
30
-
31
- it "should allow saving" do
32
- @pages = PDFToImage.open('spec/3pages.pdf')
33
- @pages.each do |page|
34
- page.save('spec/tmp.jpg')
35
- File.exists?('spec/tmp.jpg').should equal true
36
- File.unlink('spec/tmp.jpg')
37
- end
38
- end
39
-
40
- it "should allow resizing and quality control" do
41
- @pages = PDFToImage.open('spec/3pages.pdf')
42
- @pages[0].resize('50%').quality('80%').save('spec/tmp2.jpg')
43
- File.exists?('spec/tmp2.jpg').should equal true
44
- File.unlink('spec/tmp2.jpg')
45
- end
46
-
47
- it "should work with blocks" do
48
- counter = 0
49
- PDFToImage.open("spec/3pages.pdf") do |page|
50
- counter = counter + 1
51
- end
52
- counter.should equal 3
53
- end
54
- end
55
-
56
- describe "multi page documents" do
57
- it "should parse 10 page documents properly" do
58
- counter = 0
59
- PDFToImage.open('spec/10pages.pdf') do |page|
60
- result = page.save("spec/10pg-#{page.page}.jpg")
61
- File.exists?("spec/10pg-#{page.page}.jpg").should equal true
62
- File.unlink("spec/10pg-#{page.page}.jpg")
63
- counter = counter + 1
64
- end
65
-
66
- counter.should equal 10
67
- end
68
-
69
- it "should parse 11 page counts" do
70
- counter = 0
71
- PDFToImage.open('spec/11pages.pdf') do |page|
72
- result = page.save("spec/11pg-#{page.page}.jpg")
73
- File.exists?("spec/11pg-#{page.page}.jpg").should equal true
74
- File.unlink("spec/11pg-#{page.page}.jpg")
75
- counter = counter + 1
76
- end
77
-
78
- counter.should equal 11
79
- end
80
-
81
-
82
- end
83
- end
data/spec/spec_helper.rb DELETED
@@ -1,13 +0,0 @@
1
- require 'rubygems'
2
- require 'spork'
3
-
4
- Spork.prefork do
5
- require 'rspec'
6
- require 'pdftoimage/version'
7
-
8
- include PDFToImage
9
- end
10
-
11
- Spork.each_run do
12
- end
13
-
File without changes