在我的Rails 5应用程序中,我使用、wicked_pdf、和gem来从HTML生成PDF。但是在生产过程中生成PDF时存在一些问题。货币符号没有正确地显示,但它在开发过程中运行良好。
这是我的PDF图像。
我的Gemfile是这样的:
gem 'wicked_pdf', '~> 1.1'
gem 'wkhtmltopdf-binary', '~> 0.12.3.1'我的控制器代码:
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我尝试了很多解决方案,从Stackoverflow到其他类似的问题。他们都建议我在布局文件中添加元。我还在布局文件中添加了它。
编辑的
我的PDF布局文件。
<!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>如果有人能指出这件事出了什么问题,我会非常感激的。提前谢谢。
发布于 2019-05-22 09:55:11
其他的编码问题(看起来很好,只是我会使用Content-Type来确定),您可能对生产机器上的字体有问题。
要尝试的事情:
wkhtmltopdf-binary -(当时为0.12.4),或wkhtmltopdf_binary (其他宝石,目前已过时)fontconfig和libfontconfig,还确保它包含您正在使用的字体https://stackoverflow.com/questions/56252338
复制相似问题