[fxruby-users] Canvas to postscript file

Philippe Lang philippe.lang at attiksystem.ch
Fri Mar 14 02:48:48 EDT 2008


fxruby-users-bounces at rubyforge.org wrote:

> Ruby 1.8
> FOX 1.6
> fxruby-1.6.13
> 
> Mandriva 2008 - Linux 2.6.22.9-server-2mdv
> 
> Having invested several months in learning and using fxruby as an
> alternative to C/Tcl/Tk or rubytk I have started redeveloping some of
> my homegrown programs for this new environment.  The most important
> is paddb, an address label printer, which uses Tcl to generate
> postscript files from a canvas.  FOX has the FXDCPrint class which
> looks like it generates postscript output.  If this is supported by
> fxruby can it be used somehow in conjunction with a canvas and
> further would it be possible to copy that to a postscript file?  In
> Tcl/Tk the canvas.postscript function handles all that transparently.
> Is there such a method in fxruby?  The documentation available
> suggests not. Are there then any plans to incorporate such a facility
> in fxruby?  If not I shall have to regress to rubytk, which I could
> never get to work satisfactorily.  There are additional problems with
> that in Mandriva 2008 to do with the adoption of TclTk8.5. 
> Mandriva's rubytk is compiled against version 8.4 AFAIK.             
> 
> Comments?

Hi,

I was able to draw forms into a PS file, like with this code:

-------------------------------
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
-------------------------------

But I haven't been able to draw an image (taken from a Canvas) into a PS
file:

-------------------------------
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
-------------------------------


Is it possible, in Tcl/Tk, to print directly on a printer? This is
something I'm searching for for some time now, and FXDCPrint does not
allow that at the moment. Maybe there is code we can reuse?

Regards,

Philippe


More information about the fxruby-users mailing list