# pdf rtex

I love LaTeX and I love ruby/rails. I want to use rtex, it seems perfect for me. But, I am having trouble and am looking for help — once i get this working i’ll make a blog post for the world.

First, do i have what it takes?


tim@polycarp:~/test_rails$which pdflatex /usr/bin/pdflatex tim@polycarp:~/test_rails$ which latex
/usr/bin/latex
tim@polycarp:~/test_rails$which rtex /usr/bin/rtex tim@polycarp:~/test_rails$ which pdflatex
/usr/bin/pdflatex
tim@polycarp:~/test_rails$rails -v Rails 2.2.2 tim@polycarp:~/test_rails$ ruby -v
ruby 1.8.7 (2008-08-11 patchlevel 72) [i486-linux]
tim@polycarp:~/test_rails$more /etc/lsb-release DISTRIB_ID=Ubuntu DISTRIB_RELEASE=8.10 DISTRIB_CODENAME=intrepid DISTRIB_DESCRIPTION="Ubuntu 8.10"  Now I need a rails app to test this with:  rails test_rails/ cd test_rails/ ./script/generate controller make_pdf  i was getting a sqlite3 error and I had to  sudo gem install sqlite3-ruby  Now I needed a model to work with, so using the scaffold generator:  ./script/generate scaffold Item name:string purpose:string next_step:text rake db:migrate  in emacs, i created, app/views/layouts/application.pdf.rtex  documentclass[12pt]{article} begin{document} end{document}  i also created: show_pdf.pdf.rtex in app/views/make_pdf  section*{Items} begin{itemize} @items %> end{itemize}  now i create the controller:  class MakePdfController < ApplicationController def index end def show_pdf @items = Item.find(:all) end end  but from ./script/server and went to http://localhost:3000/make_pdf/show_pdf.pdf  Routing Error No route matches "/make_pdf/show_pdf.pdf" with {:method=>:get}  I thought i might need to initialize the gem as a plugin  test_rails$ rtex -i .
Installed at ./vendor/plugins/rtex


but i still get the same error after restarting mongrel

after adding config.gem "rtex" to my environment.rb and getting a nasty stack error (caused because i enabled a gem and a plugin). i realized that i can't use both together and commented out the config.gem "rtex".

in discussions with August Lilleaas on IRC, it became clear that I needed to add:

map.connect ":controller/:action.:format"

to my routes.rb.

Now, this is very close to working -- when i load: http://localhost:3000/make_pdf/show_pdf.pdf in firefox, I can open or save. If I save, all I get is simple text:


documentclass[12pt]{article}
begin{document}
section*{Items}
begin{itemize}

end{itemize}

end{document}


if I try to open (in ubuntu using document viewer) I get:


File type TeX document (text/x-tex) is not supported


As an interesting aside, I wanted to test that rtex was actually working.

Creating a textile file test.textile with some basic textile.


rtex -o output.pdf -f textile test.textile


generates output.pdf, which is a true pdf formatted file.

After some excellent help from Bruce Williams, I was able to get it working just fine -- just download the new gem (rtex 2.1.0, and you should be fine)