29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/texrack/endpoint.rb', line 29
def render_png
begin
output = Texrack::OutputFile.new(digest)
unless output.exists?
pdf_source = erb :latex
pdf = Texrack::LatexToPdf.new(pdf_source, logger).generate_pdf
Texrack::PdfToPng.new(pdf, trim?, logger).to_file(output)
output.finish
end
send_file output, disposition: :inline
rescue Texrack::LatexFailedError
send_static_error "latex-failed.png"
rescue Texrack::LatexNotFoundError
logger.error "Could not find pdflatex in #{ENV['PATH']}"
send_static_error "missing-pdflatex.png"
rescue Texrack::ConvertNotFoundError
logger.error "Could not find convert (ImageMagick) in #{ENV['PATH']}"
send_static_error "missing-convert.png"
end
end
|