Subject: Re: [netatalk-admins] Problems sending binary data to parrallel port postscript printer

From: John Barry -Technician <[email-masked]>
Date: Mon, 16 Feb 98 20:27:05 GMT

> 
> At 19:37 Uhr +0100 16.02.1998, Bill Hart wrote:
> >Hi I'm desperate,
> >	this must be a common problem, but I can't find a reference to it
> >anywhere.
> >Anyway the situation is
> >Macs running Laserwriter 8.5.1 printing images from photoshop via netatalk to
> >a Linux (Red Hat 4.2) or FreeBSD (2.2.5) box with a Tektronix Phaser IIIPXi
> >printer connected via a parrallel port.  Spooling works fine (the whole idea
> >of doing it was to get the printer off localtalk).  Printing files with only
> >ascii in them works fine, printing images (which are binary encoded) causes
> >the printer to choke..

We have the same problems here. The problem seems to be with colour, if the
image is a colour document, then the printer processes the job for a good 20
minutes then spits out a header sheet and nothing else. However, if the image
is saved as black and white first, we don't seem to have a problem.

I'm spooling from a SPARC IPX (SunOS 4.1.4 & NeWSprint2.2) to HP LaserJet 6 via
a spiderport conected via the serial port. (the ppd files I'm using are for a 
LaserJet 5, the newest I could find on the Adobe site.)

later
jb

---

From: Michael Hojnowski <[email-masked]>
Date: Mon, 16 Feb 1998 19:45:47 -0500

>> >ascii in them works fine, printing images (which are binary encoded)
causes

I had a similar problem using CAP/LWSRV to collect postscript, then
spooling it to HP or Lexmark printers via IP.  The problem was this - the
Mac generates "Binary Postscript", however the HP and Lexmark (and probably
Tektronix) printers don't expect Binary Postscript unless it comes in via
Appletalk.  If you send in Binary Postscript via IP or the serial lines,
the postscript ripper isn't prepared for it, and it chokes.

The workaround for me was to insert a filter which translated the
postscript into "Tagged Binary Postscript" before sending it to the
printer.  A guru at Lexmark sent me the following program.  I filter the
data through this filter, which escapes the 8 or so binary sequences that
are choking the printer.  This will probably fix it, if you can figure out
how to wrench this filter into the Netatalk setup.  I don't run netatalk, I
just read this mail list out of curiosity.  Sick, huh?

The filter is below.
Mike
---
/* 
   bin2tbcp.c   -  Convert file to Tagged Binary Communications Protocol.
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void main(argc,argv) 
int argc;
char *argv[];
{
	FILE *infp,*outfp;
	long CH;
	char inputfile[80],outputfile[80];

	if (argc == 3) {
	    strcpy(inputfile, argv[1]);
	    strcpy(outputfile, argv[2]);
	    if ( (infp = fopen(inputfile,"r")) == NULL ) {
		printf("\nERROR : Unable to open input file: %s\n",inputfile);
		exit(1);
	    }
	    if ( (outfp = fopen(outputfile,"w")) == NULL ) {
		printf("\nERROR : Unable to open output file: %s\n",outputfile);
		exit(1);
	    }
	}
	else if (argc == 2) {
	    strcpy(inputfile, argv[1]);
	    outfp = stdout;
	    if ( (infp = fopen(inputfile,"r")) == NULL ) {
		printf("\nERROR : Unable to open input file: %s\n",inputfile);
		exit(1);
	    }
	}
	else {
	    infp=stdin;
	    outfp=stdout;
	}

	fprintf(outfp,"%cM",(unsigned char)(0x01));
	while ((CH = fgetc(infp)) != EOF) {
	    switch (CH) {
	    case (unsigned char) 0x01:  /* ^A */
	    case (unsigned char) 0x03:  /* ^C */
	    case (unsigned char) 0x04:  /* ^D */
	    case (unsigned char) 0x05:  /* ^E */
	    case (unsigned char) 0x11:  /* ^Q */
	    case (unsigned char) 0x13:  /* ^S */
	    case (unsigned char) 0x14:  /* ^T */
	    case (unsigned char) 0x1c:  /* ^\ */
	    case (unsigned char) 0x1b:  /* ^[ */
		fputc((unsigned char) 0x01,outfp);
		fputc((unsigned char)(CH ^ 0x40),outfp); 
		break;
	    default:
		fputc(CH,outfp);
	    }

	}

	fprintf(outfp,"%c%%-12345X",(unsigned char)(0x1b));
	fclose(outfp);
	fclose(infp);
    }

---
Michael Hojnowski - Sr Prog/Analyst - Cornell University  (607) 255-7407
Home Page: http://mqh.cit.cornell.edu/~mqh/	    Fax:  (607) 255-8169
PGP Public Key: Can be found on my home page