wicked_pdf를 사용하여 레일스에서 일부 PDF를 생성했습니다. 개발 환경에서 잘 작동하지만 500 오류가 발생합니다. 로그) 내 프로덕션 환경에서 하나를 생성하려고 할 때. 내가 처음으로 느낀 것은 wkhtmltopdf 바이너리 내 생산 상자의 다른 위치에 있었던, 그래서 나는 내 wicked_pdf.rb 초기화에 다음을 추가했습니다 :Wicked_pdf는 개발 중에는 잘 작동하지만 생산에는 적용되지 않습니다.
여기if Rails.env == "production"
WickedPdf.config = {
:exe_path => '/usr/bin/wkhtmltopdf'
}
end
내가 그것을 전화 드렸습니다 방법은 내 컨트롤러 : 나는 쿼리 문자열에 debug=true
을 추가 할 때
# certificate.pdf.erb
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style type="text/css">
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;
}
</style>
</head>
<body>
<%= wicked_pdf_image_tag "certificate#{@inspection.rating}.jpg", :id => "bg" %>
<div id="address">
<p><%= @inspection.name %><br />
<%= @inspection.address("<br />").html_safe %> </p>
</div>
<div id="date">
<p><%= @inspection.date.strftime("%B %d %Y") %></p>
</div>
<div id="council">
<p><%= @council.address.html_safe %><br /><br />
<strong>Tel: </strong><%= @council.tel %></p>
</div>
<div id="logo">
<%= wicked_pdf_image_tag "certificates/#{@council.logo}.png" %>
</div>
</body>
</html>
가 확인을 생성하는 것 (그리고,268 : 여기
def certificate
@inspection = Inspection.find(params[:id])
@council = Council.find(@inspection.councilid)
respond_to do |format|
format.pdf do
render :pdf => @inspection.slug,
:show_as_html => params[:debug].present?,
:margin => {:top => 0,
:bottom => 0,
:left => 0,
:right => 0}
end
end
end
그리고 내보기의 내용입니다도우미가 올바른 위치를 생성하는 것처럼 보입니다. 레일즈 3.1에서 잡아 당김처럼 보였습니다.) 어떤 아이디어? 나는 Ruby/Rails에 익숙하지 않으므로 친절하게 대해주십시오!
우수한 보시기 바랍니다 프로덕션 환경에 표시되지, 그게있어, 감사합니다! – Pezholio
당신이 신경 쓰지 않는다면 바로 upvote하십시오! 감사! – TheDelChop
probs 없음. 끝난! :) – Pezholio