# broked def render_pdf(html, name) in_file = "#{name}.xhtml" out_file = "#{name}.pdf" # if the file name contains accents, they are changed to '??' File.open(in_file, 'w') do |f| f.write html end # call java to build the PDF # this fails because the file written doesn't have the same name as we send java system("java generate_pdf #{in_file} #{out_file}") send_file out_file end # fixed def render_pdf(html, name) tmp_name = Digest::SHA1.hexdigest(name) in_file = "#{tmp_name}.xhtml" out_file = "#{tmp_name}.pdf" # this now saves the name with the hash instead (no accents guaranteed) File.open(in_file, 'w') do |f| f.write html end # so this now works system("java generate_pdf #{in_file} #{out_file}") # and we set the filename so the end user sees the right thing send_file(out_file, { :filename => "#{name}.pdf" }) end