命令失败(exitstatus = 1): - load-error-handling ignore --header-html

问题描述 投票:0回答:1

我正在使用PDFKit gemPDFs中生成Rails,我正在尝试在我的PDF中添加标题,我尝试使用header_html同时生成PDF,最终出现错误

这是错误:

RuntimeError - command failed (exitstatus=1): /usr/bin/wkhtmltopdf --page-size Letter --encoding UTF-8 --load-error-handling ignore --header-html 

这是我的代码:

    view_generator = ActionView::Base.new(Rails.root.join('app/views'))
    pdf_kit = PDFKit.new(view_generator.render(partial: 'field_set_answers/pdf_feedback', locals: { field_set_answer: self }, formats: [:html], layout: false).html_safe, header_html: Rails.root + 'app/views/field_set_answers/pdf_header.html.haml')
    pdf_kit.stylesheets << "#{Rails.root}/public/stylesheets/feedback.css"
    file_name = "feedback_#{Time.now.to_i}.pdf"
    file_path = "#{Rails.root}/tmp/#{file_name}"
    file = pdf_kit.to_file(file_path)
ruby-on-rails pdf wkhtmltopdf pdfkit
1个回答
0
投票

你尝试过这样的事吗?

pdf_kit = PDFKit.new(view_generator.render(partial: 'field_set_answers/pdf_feedback', :header_center => "foo", locals: { field_set_answer: self }, formats: [:html], layout: false).html_safe, header_html: Rails.root + 'app/views/field_set_answers/pdf_header.html.haml')
© www.soinside.com 2019 - 2024. All rights reserved.