Method: WikiController#pdf

Defined in:
app/controllers/wiki_controller.rb

#pdfObject



141
142
143
144
145
146
147
148
149
150
151
# File 'app/controllers/wiki_controller.rb', line 141

def pdf
  page = wiki.read_page(@web_name, @page_name)
  safe_page_name = @page.name.gsub(/\W/, '')
  file_name = "#{safe_page_name}-#{@web.address}-#{@page.created_at.strftime('%Y-%m-%d-%H-%M-%S')}"
  file_path = File.join(@wiki.storage_path, file_name)

  export_page_to_tex("#{file_path}.tex") unless FileTest.exists?("#{file_path}.tex")
  # NB: this is _very_ slow

  convert_tex_to_pdf("#{file_path}.tex")
  send_file "#{file_path}.pdf"
end