[fxruby-users] Printing under FXRuby

Philippe Lang philippe.lang at attiksystem.ch
Fri Mar 7 04:56:30 EST 2008


fxruby-users-bounces at rubyforge.org wrote:

> Hi,
> 
> I've been trying to print with FXRuby, and I have to say I was not
> able to do it, or find a tutorial explaning it. 
> 
> When trying to draw anything inside the dc, my application bombs:
> 
> -------------------------------
> using HP Color LaserJet 4550 PS
>
c:/erp/ruby/lib/ruby/gems/1.8/gems/fxruby-1.6.12-mswin32/lib/fox16/itera
> tors.rb:
> 344: [BUG] Segmentation fault
> ruby 1.8.6 (2007-03-13) [i386-mswin32]
> -------------------------------
> 
> I've bee trying different mixes of beginPrint / beginPage, and the
> last thing I've been trying is: 
> 
> -------------------------------
> print_dialog = FXPrintDialog.new(self, "Print Something") if
>   print_dialog.execute != 0 print_instance = FXDCPrint.new($app)
>   print_instance.beginPrint(print_dialog.printer) do |dc|
>     print_instance.beginPage(1) do |dc|
>       dc.drawImage(@image, 0, 0)
>     end
>   end
> end
> -------------------------------
> 
> I came accross an old post of year 2002 saying FXDCPrint was not
> working yet. Is it still the case maybe? Most likely, I'm doing
> something wrong... Can anyone help?  

Hi again.

A few more precisions:

This code works when printing into a Postscript file, but does a GPF
when trying to print on a real printer, even a Postcript one:

-------------------------------
print_dialog = FXPrintDialog.new(self, "Print Something")
if print_dialog.execute != 0
  print_instance = FXDCPrint.new($app)
  print_instance.setContentRange(0, 0, 1280, 1024)
  print_instance.beginPrint(print_dialog.printer) do |dc|
    print_instance.beginPage(1) do |dc|
            
      dc.foreground = FXRGB(255, 150, 185)
      dc.drawLine(0, 0, 400, 0)
      dc.drawLine(0, 0, 0, 400)
     
    end
  end
end
-------------------------------

Second thing: there seems to be a problem with drawImage, associated
with an FXDCPrint. (There is not problem when associated with an
FXDCWindow). The following code does not reveal any image data in the
Postcript file, and does a GPF when trying to print on a real printer.

-------------------------------
print_dialog = FXPrintDialog.new(self, "Print Something")
if print_dialog.execute != 0
  print_instance = FXDCPrint.new($app)
  print_instance.setContentRange(0, 0, 1280, 1024)
  print_instance.beginPrint(print_dialog.printer) do |dc|
    print_instance.beginPage(1) do |dc|
            
      dc.drawImage(@image, 0, 400)
     
    end
  end
end
-------------------------------

Philippe Lang


More information about the fxruby-users mailing list