![](/img/trans.png)
[英]wicked_pdf shows unknown character on unicode pdf conversion (ruby)
[英]Unknown format with wicked_pdf
我正在嘗試安裝 wicked_pdf 以便在我的 Rails 應用程序上生成 2 個用戶之間的預填充合同。
我覺得我已經正確安裝了 wicked_pdf,但出現“ActionController::UnknownFormat”錯誤。
我做了什么 :
# Gemfile
gem 'wicked_pdf'
gem 'wkhtmltopdf-binary'
無論是否取消注釋“exe...”行(一個接一個),我仍然收到錯誤:
# initializers/wicked_pdf.rb
WickedPdf.config = {
# Path to the wkhtmltopdf executable: This usually isn't needed if using
# one of the wkhtmltopdf-binary family of gems.
# exe_path: '/usr/local/bin/wkhtmltopdf',
# or
# exe_path: Gem.bin_path('wkhtmltopdf-binary', 'wkhtmltopdf')
# Layout file to be used for all PDFs
# (but can be overridden in `render :pdf` calls)
# layout: 'pdf.html',
}
我的控制器:
#bookings_controller.rb
class BookingsController < ApplicationController
def show
@booking = Booking.find(params[:id])
respond_to do |format|
format.html
format.pdf do
render pdf: "test_wicked_pdf"
end
end
authorize @booking # For Pundit
end
當我去 localhost:3000/bookings/135 時渲染 HTML 正在工作......
# bookings/show.html.erb
<h1>PDF test</h1>
...但不是在我的控制器中注釋掉“#format.html”時的 PDF
# bookings/show.pdf.erb
<h1>PDF test</h1>
非常感謝提前
我知道這是一個很老的問題,但您可以使用gem wkhtmltopdf-binary-edge
而不是常規的wkhtmltopdf-binary
gem。 它對我有用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.