There is no render_to_string with tex templates. It is not
possible to do something like
a = render_to_string :template => 'projects/index.pdf.rtex'
send_data a, :type => 'application/pdf', :disposition => 'inline'
A possible solution is this new function in
lib/rtex/framework/rails.rb
def render_to_string_with_rtex(options=nil, *args, &block)
@internal_rtex_call = true
result = render_to_string_without_rtex(options, *args, &block)
@internal_rtex_call = nil
if result.is_a?(String) && @template.template_format == :pdf
options ||= {}
::RTeX::Document.new(result, options.merge(:processed => true)).to_pdf
else
result
end
end
But this is not enough. render_to_string and send_data both call
render to do the real work and render is mapped to
render_with_rtex. And render_with_rtex will always generate a PDF
if the template format is pdf. So the first if statement in
render_with_rtex must be modified.
Old condition
if result.is_a?(String) && @template.template_format == :pdf
New condition
if result.is_a?(String) && @template.template_format == :pdf && @internal_rtex_call != true && result[0,5] != '%PDF-'
The modified version of lib/rtex/framework/rails.rb is attached
to this ticket.