Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1998
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1998

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Printing from Kernel

  • To: mathgroup at smc.vnet.net
  • Subject: [mg14186] Re: Printing from Kernel
  • From: "P.J. Hinton" <paulh>
  • Date: Wed, 30 Sep 1998 19:42:20 -0400
  • Organization: "Wolfram Research, Inc."
  • References: <6us89f$lcn$1@dragonfly.wolfram.com>
  • Sender: owner-wri-mathgroup at wolfram.com

On 30 Sep 1998, Jason Gill wrote:

>     I am running Mathematica 3.0 under Win 95.  I would like to have
> mathematica send graphic images directly to a printer.  i.e implement
> the print commands directly from the kernel.
>     A search of Mathsource brought up the exe file rasterps, but this is
> listed for versions 2.2.  Does anyone know if this will still work?  Is
> their a better way to do this.  I know Display can generate the Post
> Script files, can you also use it to print? Thanks,

You don't really need rasterps to do this.  You can use Display[] to
write your data to a temporary file and then copy the temporary file to
the device that represents your printer.  Here is an example function
called PSPrint[] that could do this sort of task.

PSPrint[x_?(
        MemberQ[{Graphics, Graphics3D, ContourGraphics, DensityGraphics,

              GraphicsArray, BoxData},Head[#]]&)]:=
  Block[{stmp = OpenTemporary[]}, Display[First[stmp], x,
"EPS"];Close[stmp];
    Run["copy", First[stmp], <insert your printer name here>];
    DeleteFile[First[stmp]];x]

The usage would looks something like this.

gr = Plot[Sin[x], {x, 0, 2 Pi}];

PSPrint[gr]

Note that the name of the printer must appear in the third argument to
Run[].  If the printer is local to your machine, this name will be
something like "LPT1:".  

If you are working with a network, then you will need to use the
universal name of the form \\printerserver\printername.  Since the name
appears in a string argument to Run[], double backslashes must be used.

You must have a PostScript printer to be able to use this function as
is. If you don't, you will need to modify the function to pipe the EPS
file through ghostscript so that the file is converted to an
appropriate binary format (PCL, ESCP/2, etc.).

One drawback to this approach is that it does not center the EPS on the
paper, so the graphic will appear on the lower left hand side of the
page.   Unix users have the advantage of employing a shell script,
called psfix, to make this adjustment.  Unfortunately, a Windows
version of this utility is not provided with Mathematica.

--
P.J. Hinton
Mathematica Programming Group           paulh at wolfram.com Wolfram
Research, Inc.                  http://www.wolfram.com/~paulh/



  • Prev by Date: Re: Eigenvalue
  • Next by Date: Re: Series
  • Previous by thread: Printing from Kernel
  • Next by thread: roots of BesselJPrimes