[comp.sys.mac.programmer] Sending PostScript through the printer driver

rick@ut-emx.UUCP (Rick Watson) (03/24/88)

The following code fragment for sending a PostScript job to a laser printer
works under LaserWriter v3.2, but not 5.0.  Can anyone tell me why not? 
If no, does anyone have a code fragment that uses the pict comment
method of sending PostScript?

Rick Watson
University of Texas Computation Center
 arpa:   ccaw001@utadnx.cc.utexas.edu
 uucp:   ...seismo!ut-sally!ut-emx!rick
 bitnet: ccaw001@utadnx     span:  utspan::watson
 phone:  512/471-3241

----------------------------------------------------------------

	prdrvropen();
	prctlcall(iprdevctl, lprreset, 0L, 0L);
	prctlcall(iprioctl, ptr-to-postscript, length-of-postscript, 1L);
	prctlcall(iprdevctl, lprpageend, 0L, 0L);
	prdrvrclose();

olson@endor.harvard.edu (Eric K. Olson) (03/25/88)

In a recent article Rick Watson writes:
>The following code fragment for sending a PostScript job to a laser printer
>works under LaserWriter v3.2, but not 5.0.  Can anyone tell me why not? 
>If no, does anyone have a code fragment that uses the pict comment
>method of sending PostScript?

What follows is code to send PS to the LaserWriter via the PicComment that
turns DrawString() into a PS "Quote" function.  I tried to use the PicComment
"PS Quote" (Comment # 192) but couldn't get that to work (probably trouble
turning the string into a Handle).  

Note that this code assumes that you are already in a Printing recording
GrafPort and you've done everything you'ld do to print QuickDraw stuff.

It send the PS in a STR# resource to the Laserwriter.

printps()
{
	
	PicComment(190,0,NIL);		/* PS Begin */
	PicComment(194,0,NIL);		/* DrawString() == Postscript Text */
	
	poststrings(256);
	
	PicComment(191,0,NIL);		/* PS End */
	}

poststrings(id)
	short		id;
{
	short		x;
	Handle		pstext;
	short		numstrs;
	unsigned char *	where;
	
	pstext=GetResource('STR#',id);		/* Header strings */
	HLock(pstext);
	
	numstrs=*(short *)*pstext;
	where=(unsigned char *)*pstext;
	where+=2;
	
	for (x=0;x<numstrs;x++) {
		DrawString(where);
		where+=where[0]+1;
		}
	HUnlock(pstext);
	}		

Hope this helps.

-Eric
	    "We're writing tomorrow's software yesterday."
Eric K. Olson     olson@endor.harvard.edu     harvard!endor!olson     D0760
   (Name)                (ArpaNet)                 (UseNet)        (AppleLink)

lsr@Apple.COM (Larry Rosenstein) (04/06/88)

In article <1344@ut-emx.UUCP> rick@ut-emx.UUCP (Rick Watson) writes:
>The following code fragment for sending a PostScript job to a laser printer
>works under LaserWriter v3.2, but not 5.0.  Can anyone tell me why not? 

This is covered in Tech Note #192.

In LaserWriter 5.0 the low level printer driver calls are converted into
corresponding high-level calls.  One of the results is exactly the problem
you described.  The solution given in the Tech Note is as follows (in
Pascal):

	PrDrvrOpen;
	PrCtlCall(iPrDevCtl, lPrDocOpen, 0, 0);
	PrCtlCall(iPrDevCtl, lPrPageOpen, 0, 0);
	{ send data }
	PrCtlCall(iPrDevCtl, lPrPageClose, 0, 0);
	PrCtlCall(iPrDevCtl, lPrDocClose, 0, 0);
	PrDrvrClose;

-- 
		 Larry Rosenstein,  Object Specialist
 Apple Computer, Inc.  20525 Mariani Ave, MS 27-AJ  Cupertino, CA 95014
	    AppleLink:Rosenstein1    domain:lsr@Apple.COM
		UUCP:{sun,voder,nsc,decwrl}!apple!lsr