Printing plain text directly without dialogues
2009-06-24 22:32:20 GMT
Hi,
I recently searched for ways printing plain (but formatted) text directly and without major requirements using ruby and stumbled upon wxruby, which seems to be a nice framework that would meet my requirements quite well.
However, since I use a local Ruby on Rails server, I would like to be able to select a printer as well as print the text without using dialogues, i.e. only using the wxruby classes to interact with the user via http responses.
I had a look at the "printing.rb" example in the wxruby directory and modified it to just print formatted text, as I want it, but it's still having dialogues. My try without dialogues was the following non-functional code:
begin
require 'rubygems'
rescue LoadError
end
require 'wx'
dc = Wx::PrinterDC.new("", "", "") // deprecated way to initiate PrinterDC on default printer
dc.set_background(Wx::WHITE_BRUSH)
dc.clear()
dc.set_font(Wx::Font.new(12, Wx::DEFAULT, Wx::NORMAL, Wx::NORMAL, false, "Control"))
dc.set_background_mode(Wx::TRANSPARENT)
dc.draw_text( "D", 0, 0)
Since I could not figure out the whole concept of class relations in wxruby, yet, I would be very glad if someone could help me and give examples for selecting a printer and printing in wxruby without the use of dialogues.
As far as I understand, I need to create a PrintData object. This PrintData object could be handed to the device context PrinterDC containing my formatted text that got into there using draw_text methods. I don't yet understand where this PrintData comes from, if not from a dialogue (using Wx::get_app.print_data).
Thanks a lot for any hints!
Don Darone
_______________________________________________ wxruby-users mailing list wxruby-users <at> rubyforge.org http://rubyforge.org/mailman/listinfo/wxruby-users
RSS Feed