Class: PDFToImage::Image
- Inherits:
-
Object
- Object
- PDFToImage::Image
- Defined in:
- lib/pdftoimage/image.rb
Overview
A class which is instantiated by PDFToImage when a PDF document is opened.
Constant Summary collapse
- CUSTOM_IMAGE_METHODS =
ImageMagick methods that we currently support.
[ "resize", "quality" ]
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#opened ⇒ Object
readonly
Returns the value of attribute opened.
-
#page ⇒ Object
readonly
Returns the value of attribute page.
-
#pdf_name ⇒ Object
readonly
Returns the value of attribute pdf_name.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Instance Method Summary collapse
- #<=>(img) ⇒ Object
-
#initialize(pdf_name, filename, page, page_size, page_count) ⇒ Image
constructor
Image constructor.
-
#save(outname) ⇒ Object
Saves the converted image to the specified location.
Constructor Details
#initialize(pdf_name, filename, page, page_size, page_count) ⇒ Image
Image constructor
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/pdftoimage/image.rb', line 31 def initialize(pdf_name, filename, page, page_size, page_count) @args = [] @pdf_name = pdf_name @filename = filename @opened = false @width = page_size[:width] @height = page_size[:height] @page_count = page_count @page = page end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
11 12 13 |
# File 'lib/pdftoimage/image.rb', line 11 def args @args end |
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
7 8 9 |
# File 'lib/pdftoimage/image.rb', line 7 def filename @filename end |
#height ⇒ Object (readonly)
Returns the value of attribute height.
9 10 11 |
# File 'lib/pdftoimage/image.rb', line 9 def height @height end |
#opened ⇒ Object (readonly)
Returns the value of attribute opened.
12 13 14 |
# File 'lib/pdftoimage/image.rb', line 12 def opened @opened end |
#page ⇒ Object (readonly)
Returns the value of attribute page.
10 11 12 |
# File 'lib/pdftoimage/image.rb', line 10 def page @page end |
#pdf_name ⇒ Object (readonly)
Returns the value of attribute pdf_name.
6 7 8 |
# File 'lib/pdftoimage/image.rb', line 6 def pdf_name @pdf_name end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
8 9 10 |
# File 'lib/pdftoimage/image.rb', line 8 def width @width end |
Instance Method Details
#<=>(img) ⇒ Object
65 66 67 68 69 70 71 72 73 |
# File 'lib/pdftoimage/image.rb', line 65 def <=>(img) if @page == img.page return 0 elsif @page < img.page return -1 else return 1 end end |
#save(outname) ⇒ Object
Saves the converted image to the specified location
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/pdftoimage/image.rb', line 48 def save(outname) generate_temp_file cmd = "convert " if not @args.empty? cmd += "#{@args.join(' ')} " end cmd += "#{@filename} #{outname}" PDFToImage::exec(cmd) return true end |