printing from mathematica to non-postscript printer with gs 
Author Message
 printing from mathematica to non-postscript printer with gs

Using redhat 5.2 linux, with ghostscript installed, I am having trouble printing
from mathematica, since math'a generates postscript directly. What prints is
straight postscript text, not the rendered bitmap. Any ideas?

--
Robb Aley Allan
Gulfstream Group, Inc. / Myron A. Minskoff, Inc. / Helical Design



Wed, 24 Oct 2001 03:00:00 GMT  
 printing from mathematica to non-postscript printer with gs

Quote:
> Using redhat 5.2 linux, with ghostscript installed, I am having
> trouble printing from mathematica, since math'a generates postscript
> directly. What prints is straight postscript text, not the rendered
> bitmap. Any ideas?

I doubt that this is a PostScript programming language problem.  It is
probably a configuration issue or a problem in the front end's PostScript
generation facility.

What sort of infrastructure do you have in place for printing Mathematica
notebooks?  There are two things to keep in mind.  

First, what is the shell command to which the front end pipes PostScript
output.  You can tell by summoning the front end print dialog with the
menu command

                File -> Print

and looking at the second field in the Print Destination subsection of the
dialog box.  Is it the default value of "lpr", or is it something else?

Second, what is being used to handle the translation of PostScript into
your printer's native language format?  Having GhostScript installed by
itself isn't enough.  Usually you have to have some sort of print
interceptor tool (like Magic Filter) that checks whether the stream is a
PostScript file.  If you don't have such a tool in place, the PostScript
will go straight to the printer.  Hence the raw PostScript code.

There is a problem in the X front end wherein the front end does not emit
the PostScript in a totally kosher way.  That is, rather than the
"%!PS-Adobe" line, a bunch of extraneous resource comments are present.
The "%!" line is what filtering tools look for in deciding whether the
stream is a PostScript document.  Because it is not present under these
circumstances, the filter lets the raw text go to the printer rather than
piping it through Ghostscript.

A simple workaround is to write a filter program through which the front
end can pipe the PostScript to strip the extraneous stuff before the "%!".
Here is one such piece of code written for C.

[begin C code listing]
#include <stdio.h>
#include <string.h>

#define BUFSIZE         1024
#define KEEP            1
#define DISCARD         0
#define MAGIC           "%!PS-Adobe-2.0"

int main(){
        int state;
        char buf[BUFSIZE];

        state = DISCARD;
        while (fgets(buf, BUFSIZE, stdin) != NULL) {
                if (state == DISCARD)
                        if (!strncmp(buf, MAGIC, strlen(MAGIC) - 1))
                                state = KEEP;
                if (state == KEEP) {
                        fprintf(stdout, buf);
                }              
        }
        return 0;

Quote:
}

[end C code listing]

Suppose we save this code to a file named fecleanps.c and compile it with
the shell command:

        cc -o fecleanps fecleanps.c

This creates an executeable named "fecleanps", which can then be moved to
a directory on your shell's executable search path (PATH).  Then all you
need to do is to add the following snippet to your .Xdefaults file

        XMathematica*printCommand: fecleanps | lpr

It will set your print dialog to display this command by default when you
print a notebook.

Where "lpr" replaced with the shell command you normally use for printing.

You can post questions specific to Mathematica at
comp.soft-sys.math.mathematica.  The posting guidelines can be found at
this URL:

        http://smc.vnet.net/MathGroup.html

--
P.J. Hinton

Wolfram Research, Inc.                  http://www.wolfram.com/~paulh/
Disclaimer: Opinions expressed herein are those of the author alone.



Wed, 24 Oct 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Printing Postscript files on non-Postscript printers

2. Printing Postscript Files on a Non-Postscript Printer

3. Printing postscript with a non-postscript printer

4. Printing Postscript files on non-PostScript printer from UNIX

5. Printing Postscript files to non PostScript printers

6. printing level 3 postscript to non-postscript printers

7. Printing Quarkfile to a non-postscript printer

8. Print to Non-PostScript Printer

9. printing a .ps file on a non-postscript printer.N°2

10. Printing PostScript files from Windows 95/98 on non-laser printer

11. Is is possible to print to a non-postscript printer directly from Word

12. Can I print postscript files to a non-post script HP deskjet printer

 

 
Powered by phpBB® Forum Software