Class: Texrack::PdfToPng
- Inherits:
-
Object
- Object
- Texrack::PdfToPng
- Defined in:
- lib/texrack/pdf_to_png.rb
Instance Attribute Summary collapse
-
#line ⇒ Object
readonly
Returns the value of attribute line.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#pdf_path ⇒ Object
readonly
Returns the value of attribute pdf_path.
Instance Method Summary collapse
- #command ⇒ Object
-
#initialize(pdf_path, trim, logger) ⇒ PdfToPng
constructor
A new instance of PdfToPng.
- #to_file(file) ⇒ Object
Constructor Details
#initialize(pdf_path, trim, logger) ⇒ PdfToPng
Returns a new instance of PdfToPng.
6 7 8 9 10 11 12 |
# File 'lib/texrack/pdf_to_png.rb', line 6 def initialize(pdf_path, trim, logger) @pdf_path = pdf_path @trim = trim @logger = logger @line = Cocaine::CommandLine.new(command, "-density 300x300 -quality 90 #{"-trim" if trim} :in :out", logger: logger) end |
Instance Attribute Details
#line ⇒ Object (readonly)
Returns the value of attribute line.
4 5 6 |
# File 'lib/texrack/pdf_to_png.rb', line 4 def line @line end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
4 5 6 |
# File 'lib/texrack/pdf_to_png.rb', line 4 def logger @logger end |
#pdf_path ⇒ Object (readonly)
Returns the value of attribute pdf_path.
4 5 6 |
# File 'lib/texrack/pdf_to_png.rb', line 4 def pdf_path @pdf_path end |
Instance Method Details
#command ⇒ Object
14 15 16 |
# File 'lib/texrack/pdf_to_png.rb', line 14 def command Texrack.config[:convert] || "convert" end |
#to_file(file) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/texrack/pdf_to_png.rb', line 18 def to_file(file) line.run(in: pdf_path, out: file.path) file.path rescue Cocaine::CommandNotFoundError => e raise Texrack::ConvertNotFoundError end |