33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/rtex/framework/rails.rb', line 33
def render_with_rtex(options=nil, *args, &block)
result = render_without_rtex(options, *args, &block)
if result.is_a?(String) && Thread.current[:_rendering_rtex]
Thread.current[:_rendering_rtex] = false
options ||= {}
::RTeX::Document.new(result, options.merge(:processed => true)).to_pdf do |filename|
serve_file = Tempfile.new('rtex-pdf')
FileUtils.mv filename, serve_file.path
send_file serve_file.path,
:disposition => (options[:disposition] rescue nil) || 'inline',
:url_based_filename => true,
:filename => (options[:filename] rescue nil),
:type => "application/pdf",
:length => File.size(serve_file.path)
serve_file.close
end
else
result
end
end
|