Reputation: 101
In my Rails 5 app I use wicked_pdf and wkhtmltopdf-binary gem for generating PDF from HTML. But there is some problem while generating PDF on production. Currency symbol is not displaying properly, but it's working fine in development.
Here is my PDF image.
My Gemfile looks like this:
gem 'wicked_pdf', '~> 1.1'
gem 'wkhtmltopdf-binary', '~> 0.12.3.1'
My Controller code:
def generate_order
@order = @user_builder.orders.find(params[:id])
render pdf: 'billing_pdf',
layout: 'layouts/pdf.html.erb',
:show_as_html => params[:debug].present?, #true
encoding: 'utf8'
end
I tried lots of solutions from Stackoverflow to other similar questions. They all suggested me to add meta in layout file. I also added it in my layout file.
edited
my PDF layout file.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Billing</title>
</head>
<body>
<div class='container'>
<%= yield %>
</div>
</body>
</html>
I will be really grateful if someone could point out what is going wrong in this case. Thanks in advance.
Upvotes: 2
Views: 1615
Reputation: 18504
Other that encoding issues (which look to be set up fine, only I'd use Content-Type
to be sure) you may be having issues with fonts on production machine.
Things to try:
wkhtmltopdf-binary
- (0.12.4 at the time), or wkhtmltopdf_binary
(other gem, is stale at the moment)fontconfig
and libfontconfig
installed and set up, also that it contains fonts that you're usingUpvotes: 3