Forum Documentation

princexml and ruby on rails

Adis
Hey,
I am trying to use princexml with ruby on rails on my macbook. I installed the prince and I followed the instructions,however I am not able to generate the pdf. If I use this simple example:

def show
respond_to do |format|
format.html
format.pdf do
render :pdf => "filename", :stylesheets => ["application", "prince"], :layout => "pdf"
end
end
end

it causes 2 errors: Broken pipe or undefined method `bytesize' for nil:NilClass. Any clue?
I am using Mac OS Lion 10.7.4, Ruby 1.8.7 and Rails 2.3.14.
mikeday
Can you successfully run Prince from the command-line? Are you using the "Princely" component to call Prince from Rails?
Adis
I am able to run Prince from the command-line, for an example: prince test.html -o test.pdf . Also I am using Princely component to call Prince from Rails. Do I need to set up some configuration file inside my application?
mikeday
I'm not entirely sure. Can you add some debug print statements to pdf_helper.rb in the make_pdf method and check that it is reaching the call to prince.pdf_from_string(html_string)?
Adis
Does prince support haml files?
mikeday
No, you will need to generate actual HTML to pass to Prince.