首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >wicked_pdf的未知格式

wicked_pdf的未知格式
EN

Stack Overflow用户
提问于 2016-03-16 18:48:52
回答 1查看 1.8K关注 0票数 3

我正在尝试安装wicked_pdf,以便在我的Rails应用程序上的两个用户之间生成预先填写的合同。

我感觉我已经正确地安装了wicked_pdf,但是我得到了一个"ActionController::UnknownFormat“错误。

我做了什么:

代码语言:javascript
复制
# Gemfile

gem 'wicked_pdf'
gem 'wkhtmltopdf-binary'

不管有没有注释“exe...”行(一个接一个),我仍然得到错误:

代码语言:javascript
复制
# 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',
}

我的控制器:

代码语言:javascript
复制
#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正在工作...

代码语言:javascript
复制
# bookings/show.html.erb

<h1>PDF test</h1>

当我在控制器中注释掉"# format.html“时,...but不是PDF。

代码语言:javascript
复制
# bookings/show.pdf.erb

<h1>PDF test</h1>

提前谢谢你

EN

回答 1

Stack Overflow用户

发布于 2021-10-14 07:21:28

我知道这是一个相当古老的问题,但是您可以使用gem wkhtmltopdf-binary-edge而不是常规的wkhtmltopdf-binary gem。这对我很管用。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36033445

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档