Printing prawn generated pdf

2019-05-29 05:41发布

问题:

Using prawn gem for ruby-on-rails webpage, is it possible to send print request to printer device to print pdf page I've generated using prawn?

回答1:

Looks like you would want to use prawn-print.

# Open print dialog, but don't autoprint.
pdf = Prawn::Document.new
pdf.text "I installed Adobe Reader and all I got was this lousy printout."
pdf.print

# Autoprint it on the default printer, when opened.
pdf = Prawn::Document.new
pdf.text "Help! I am trapped in a PDF factory!"
pdf.autoprint

# Autoprint it on a printer where the name includes "LaserJet".
pdf = Prawn::Document.new
pdf.text "Help! I am trapped in a PDF factory!"
pdf.autoprint "LaserJet"