Ruby on rails 使用prawnto将html字符串转换为pdf

Ruby on rails 使用prawnto将html字符串转换为pdf,ruby-on-rails,ruby,Ruby On Rails,Ruby,我有一个存储html内容的字段。我想转换pdf中的html字符串。我正在使用prawnto生成pdf 有什么想法吗?如何将特定的html字符串转换为pdf字符串?使用以下工具很容易: 它在背景中使用,也很容易使用。它有很多选项,可以自定义pdf生成 瑞安·贝茨有一个秘密 @your_object = YourObject.find(params[:id]) respond_to do |format| format.pdf do #html = render_to_string(:a

我有一个存储html内容的字段。我想转换pdf中的html字符串。我正在使用prawnto生成pdf

有什么想法吗?如何将特定的html字符串转换为pdf字符串?

使用以下工具很容易:

它在背景中使用,也很容易使用。它有很多选项,可以自定义pdf生成

瑞安·贝茨有一个秘密

@your_object = YourObject.find(params[:id])
respond_to do |format|
  format.pdf do
    #html = render_to_string(:action => "show.html.haml", :layout => "pdf.html.haml")
    html = @your_object.your_html_field
    content = PDFKit.new(html)
    send_data(content.to_pdf, :filename => "content.pdf", :type => 'application/pdf', :disposition => 'inline')
  end
end