ROR 应用程序中的 WKHTMLTOPDF 路径
WKHTMLTOPDF path in ROR application
我正在使用 wicked_pdf gem 进行 HTML 到 PDF 的转换。根据 Github 中的描述,我正确安装了所有内容。但是我收到运行时错误 -
RuntimeError(错误的 wkhtmltopdf 路径:/usr/local/bin/wkhtmltopdf):
app/controllers/orders_controller.rb:46:在`create
`44 @count = Item.count(:qty)
45 @temp = Item.where(:received => true).count()
46 render :pdf => "Bill" ,
47 :template => 'orders/create.pdf.erb', # Excluding ".pdf" extension.
48 page_height: 100,
49 page_width: 80`
并且 wkhtmltopdf 安装在我的系统中 /usr/local/bin/wkhtmltopdf
指定 wkhtmltopdf 的路径应该是它已经安装的路径。
我无法弄清楚是什么问题。
在 wkhtmltopdf 的源代码中,看起来它所做的只是 运行ning File.exists?在这条路上:
所以我们必须仔细检查 wkhtmltopdf 是否正确安装在 /usr/local/bin/wkhtmltopdf
的假设
你能提供更多信息吗?只是为了验证 which wkhtmltopdf
的输出是什么
当您在控制台中 运行 wkhtmltopdf -V
时,您会得到什么?
您可以尝试在配置中指定路径(在 wkhtmltopdf 自述文件中提到的初始值设定项中),看看是否也有不同。
最后,您可以将可执行文件移动到不同的目录,然后在初始化程序中指定它以查看它是否可能与文件夹权限有关。
您是否尝试过在初始化程序中指定路径? ({rails.root}/config/initializers/wicked_pdf.rb) 例如..
WICKED_PDF = {
:exe_path => '/usr/local/bin/wkhtmltopdf-amd64'#should be whatever your version is called
}
我遇到了类似的问题。尝试重新安装 gem 并安装库以支持 gem。
这是在 mac 和 ubuntu:
中安装该库的链接
unable to install wkhtmltopdf with patched qt in ubuntu 16.04
wkhtmltopdf 将安装到 /usr/bin/wkhtmltopdf
,但预计安装在 /usr/local/bin/wkhtmltopdf
。
要修复它,只需创建符号 link 作为(可能需要使用 sudo):
ln -s /usr/bin/wkhtmltopdf /usr/local/bin/wkhtmltopdf
我正在使用 wicked_pdf gem 进行 HTML 到 PDF 的转换。根据 Github 中的描述,我正确安装了所有内容。但是我收到运行时错误 -
RuntimeError(错误的 wkhtmltopdf 路径:/usr/local/bin/wkhtmltopdf): app/controllers/orders_controller.rb:46:在`create
`44 @count = Item.count(:qty)
45 @temp = Item.where(:received => true).count()
46 render :pdf => "Bill" ,
47 :template => 'orders/create.pdf.erb', # Excluding ".pdf" extension.
48 page_height: 100,
49 page_width: 80`
并且 wkhtmltopdf 安装在我的系统中 /usr/local/bin/wkhtmltopdf
指定 wkhtmltopdf 的路径应该是它已经安装的路径。
我无法弄清楚是什么问题。
在 wkhtmltopdf 的源代码中,看起来它所做的只是 运行ning File.exists?在这条路上:
所以我们必须仔细检查 wkhtmltopdf 是否正确安装在 /usr/local/bin/wkhtmltopdf
你能提供更多信息吗?只是为了验证 which wkhtmltopdf
当您在控制台中 运行 wkhtmltopdf -V
时,您会得到什么?
您可以尝试在配置中指定路径(在 wkhtmltopdf 自述文件中提到的初始值设定项中),看看是否也有不同。
最后,您可以将可执行文件移动到不同的目录,然后在初始化程序中指定它以查看它是否可能与文件夹权限有关。
您是否尝试过在初始化程序中指定路径? ({rails.root}/config/initializers/wicked_pdf.rb) 例如..
WICKED_PDF = {
:exe_path => '/usr/local/bin/wkhtmltopdf-amd64'#should be whatever your version is called
}
我遇到了类似的问题。尝试重新安装 gem 并安装库以支持 gem。 这是在 mac 和 ubuntu:
中安装该库的链接unable to install wkhtmltopdf with patched qt in ubuntu 16.04
wkhtmltopdf 将安装到 /usr/bin/wkhtmltopdf
,但预计安装在 /usr/local/bin/wkhtmltopdf
。
要修复它,只需创建符号 link 作为(可能需要使用 sudo):
ln -s /usr/bin/wkhtmltopdf /usr/local/bin/wkhtmltopdf