Note that there are some explanatory texts on larger screens.

plurals
  1. POWicked_pdf working fine in development, but not in production
    primarykey
    data
    text
    <p>I've been working with wicked_pdf to generate some PDFs in Rails, and it's been working fine in my dev environment, but I get a 500 error (but no specific errors in my log) when I try and generate one on my production environment. The first thing I noticed was that the wkhtmltopdf binary was in a different location on my production box, so I've added the following to my wicked_pdf.rb initializer:</p> <pre><code>if Rails.env == "production" WickedPdf.config = { :exe_path =&gt; '/usr/bin/wkhtmltopdf' } end </code></pre> <p>Here's how I'm calling it in my controller:</p> <pre><code> def certificate @inspection = Inspection.find(params[:id]) @council = Council.find(@inspection.councilid) respond_to do |format| format.pdf do render :pdf =&gt; @inspection.slug, :show_as_html =&gt; params[:debug].present?, :margin =&gt; {:top =&gt; 0, :bottom =&gt; 0, :left =&gt; 0, :right =&gt; 0} end end end </code></pre> <p>And here's the contents of my view:</p> <pre><code># certificate.pdf.erb &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt; &lt;style type="text/css"&gt; body { margin: 0; padding: 0; font-family: "Lucida Grande", "Lucida Sans Unicode", Helvetica, Arial, sans-serif; } img#bg { width: 800px; height: 1130px; position: absolute; } #date p, #council p { line-height: 17px; font-size: 12px; } #council { position: absolute; top: 650px; left: 445px; } #logo { position: absolute; top: 965px; left: 98px; } #logo img { height: 65px; } #address { position: absolute; top: 425px; left: 300px; } #address p { font-size: 22px; line-height: 27px; } #date { position: absolute; top: 650px; left: 98px; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;%= wicked_pdf_image_tag "certificate#{@inspection.rating}.jpg", :id =&gt; "bg" %&gt; &lt;div id="address"&gt; &lt;p&gt;&lt;%= @inspection.name %&gt;&lt;br /&gt; &lt;%= @inspection.address("&lt;br /&gt;").html_safe %&gt; &lt;/p&gt; &lt;/div&gt; &lt;div id="date"&gt; &lt;p&gt;&lt;%= @inspection.date.strftime("%B %d %Y") %&gt;&lt;/p&gt; &lt;/div&gt; &lt;div id="council"&gt; &lt;p&gt;&lt;%= @council.address.html_safe %&gt;&lt;br /&gt;&lt;br /&gt; &lt;strong&gt;Tel: &lt;/strong&gt;&lt;%= @council.tel %&gt;&lt;/p&gt; &lt;/div&gt; &lt;div id="logo"&gt; &lt;%= wicked_pdf_image_tag "certificates/#{@council.logo}.png" %&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>When I add <code>debug=true</code> to the query string it seems to generate OK (and the <code>wicked_pdf_image_tag</code> helper seems to generate the correct location, which seemed to be a gotcha in Rails 3.1). Any ideas? I am pretty new to Ruby / Rails, so please be gentle!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload