[fxruby-users] Canvas to postscript file
Jeroen van der Zijp
jeroen at fox-toolkit.org
Fri Mar 14 09:23:46 EDT 2008
On Friday 14 March 2008, Len Lawrence wrote:
> Philippe Lang wrote:
> > 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
> >
> >
> Thanks for the response Philippe. I need the canvas for interaction,
> adding, deleting labels, changing font size and colour, changing the
> typeface etc. In Tcl/Tk I create the .ps file from the canvas and then
> use the system command to print it;
> e.g. system( "lpr -Pdj940 $somefilewhatever" )
> and I had hoped to do something like that in fxruby. In your case,
> having created the Postscript file could you not use Ruby's system
> command? If you are using Windows or a Mac there must be a similar
> print command.
To save an FXImage, try fxsavePS().
- Jeroen
More information about the fxruby-users
mailing list