在我的项目中,我在Windows平台上使用了PDFKIT。最初它工作正常,但现在它给出了一些奇怪的错误信息。
没有这样的文件或目录 - “C:\ Program \ Files \ wkhtmltopdf \ wkhtmltopdf.exe“” - page-size“”Letter“ “ - margin-top”“0.75in”“ - margin-right”“0.75in”“ - margin-bottom” “0.75in”“ - margin-left”“0.75in”“ - 编码”“UTF-8”“--quiet”“ - ” “ - ”
我没有办法解决它,这是红宝石代码。
kit = PDFKit.new(html)
send_data(kit.to_pdf, :filename => "#{file_name}.pdf", :type =>'application/pdf')
文件:app / config / initializers / pdfkit.rb
PDFKit.configure do |config|
config.wkhtmltopdf = 'C:\Program Files\wkhtmltopdf\wkhtmltopdf.exe'
# config.default_options = {
# :page_size => 'Legal',
# :print_media_type => true
# }
# config.root_url = "http://localhost" # Use only if your external hostname is unavailable on the server.
end
提前致谢..
答案 0 :(得分:1)
当我的系统发生这种情况时,我通过将wkhtmltopdf移动到路径不包含空格的目录来解决它。