问题描述
我需要使用Ruby on Ruby on Rails将格式文本发送到打印机的帮助,或者从Ruby程序将pdf文件发送到打印机的帮助.我可以编写代码从Rails应用程序创建pdf文件,但是不知道如何将pdf文件打印到默认打印机.我正在尝试使用Ruby on Rails编写一个小型票务应用程序.
I need help with sending a formatted text to a printer using Ruby on Ruby on Rails OR sending a pdf file to a printer from Ruby program. I can write the code to create a pdf file from Rails app but don't know how to print that pdf file to a default printer. I am trying to write a small ticketing application with Ruby on Rails.
推荐答案
在Windows环境中,这是一个解决方案:Foxit! http://www.foxitsoftware.com/pdf/reader/
Here is a solution in Windows environement : Foxit !http://www.foxitsoftware.com/pdf/reader/
您可以调用foxit.exe(独立可执行文件)在后台静默打印PDF.
You can call foxit.exe (standalone executable) to silently print a PDF in background.
语法:foxit.exe/t您的file.pdf"打印机名称"
Syntax : foxit.exe /t "your file.pdf" "The Printer Name"
shell = WIN32OLE.new('Shell.Application')
shell.ShellExecute("foxit.exe","/t \"#{filename}\" \"#{printer}\"")
这篇关于在Ruby中将文件打印到打印机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!