Ruby on rails 将PDF和虾混合
我正在使用prawn gem生成模型属性的pdf。到目前为止,我对此没有异议。不过,我现在使用Carrierwave上传更多PDF供参考 Carrierwave按预期工作,因为我的模型在上载附加PDF时有以下更改:Ruby on rails 将PDF和虾混合,ruby-on-rails,pdf,carrierwave,prawn,Ruby On Rails,Pdf,Carrierwave,Prawn,我正在使用prawn gem生成模型属性的pdf。到目前为止,我对此没有异议。不过,我现在使用Carrierwave上传更多PDF供参考 Carrierwave按预期工作,因为我的模型在上载附加PDF时有以下更改: documents: [] to [{"url"=>"/uploads/tmp/1536259407-12025-0001-8255/Amazon.com_-_Order_111-4655889-4409816.pdf"}] 我想使用combine_pdf gem将附加的ca
documents: [] to [{"url"=>"/uploads/tmp/1536259407-12025-0001-8255/Amazon.com_-_Order_111-4655889-4409816.pdf"}]
我想使用combine_pdf gem将附加的carrierwave pdf(文档
)呈现到我的呈现的prawn pdf中
我的控制器具有以下代码:
respond_to do |format|
format.html
format.js
format.json
format.pdf do
order_pdf = OrderPdf.new(@order, current_user).render
final_pdf = CombinePDF.new
final_pdf << CombinePDF.parse(order_pdf)
if @order.documents.any?
@order.documents.each do |doc|
# if I comment out this line, the original pdf loads, as expected
final_pdf << CombinePDF.parse(IO.read(doc.url))
end
end
send_data final_pdf.to_pdf,
filename: "order_#{@order.id}.pdf",
type: 'application/pdf',
disposition: 'inline'
end
end
以下是我的文档上传器供参考:
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end