私は直接PDFから印刷しようとしています。あなたはhereシステムコマンドを使用したRailsアプリケーションでの直接印刷
を見ることができるように私は正常に動作しますが、のUbuntuでない窓やその他のOS秒でシステム(LPR) command.Thisソリューションを使用する必要があります。 ウィンドウでそれを行う方法を知っていますか?
、これが私の方法である:
def general_receipt_export
if params[:official_id].present?
@ids = params[:official_id].split(',')
@officials = Official.find(@ids)
pdf = render_to_string pdf: "#{@ids.map(&:inspect).join(',').to_s + '_receipt.pdf'}", :template => 'officials/general_receipt_export.html.erb', encoding: 'utf8',orientation: 'Landscape',page_size: 'A4'
render layout: false
save_path = Rails.root.join('public','pdfs', "#{@ids.map(&:inspect).join(',').to_s + '_receipt.pdf'}")
File.open(save_path, 'wb') do |file|
file << pdf
end
system("lpr", "public/pdfs/#{@ids.map(&:inspect).join(',').to_s + '_receipt.pdf'}")
else
render json:{messege: 'No letter to export'},status: 404
end
end