HP PCL/PJL reference - Printer Job Language Technical Reference Manual
EN Programming Examples C-3
/****************************************************/
/* SWITCH.C (Switching Printer Languages) */
/****************************************************/
#include <stdio.h>
main()
{
FILE *prn; /* initialization section */
/************ open PRN for writing ***************/
prn = fopen("lpt1","wb");
/****** Send UEL command and @PJL<CR><LF> *****/
fprintf(prn,"\033%%-12345X@PJL \n");
fprintf(prn,"@PJL COMMENT **Beginning of PCL Job** \n");
fprintf(prn,"@PJL COMMENT **Enter PCL (& HP-GL/2)* \n");
fprintf(prn,"@PJL ENTER LANGUAGE = PCL \n");
fprintf(prn,"\033E\033%%0BIN;SP1;PA1010,1010;PW2.2;");
fprintf(prn,"PD5310,1010,5310,5310,1010,5310,1010,1010;");
fprintf(prn,"PU;PA2280,3040;");
fprintf(prn,"SD1,277,2,1,4,20,5,0,6,0,7,4148;");
fprintf(prn,"DT*;SS;LBPCL Print Job*;"); /** Print text **/
fprintf(prn,"\033%%0A\f\033E"); /*Exit HP-GL/2, <FF>, <Esc>E*/
fprintf(prn,"\033%%-12345X@PJL \n"); /*** UEL & @PJL ***/
fprintf(prn,"@PJL COMMENT *** END OF PCL JOB & *** \n");
fprintf(prn,"@PJL COMMENT ** START OF POSTSCRIPT * \n");
fprintf(prn,"@PJL ENTER LANGUAGE = POSTSCRIPT \n");
fprintf(prn,"5 setlinewidth\r"); /** PostScript Code **/
fprintf(prn,"100 100 moveto\r");
fprintf(prn,"0 300 rlineto\r");
fprintf(prn,"300 0 rlineto\r");
fprintf(prn,"0 -300 rlineto\r");
fprintf(prn,"stroke\r");
fprintf(prn,"185 240 moveto\r");
fprintf(prn,"/Helvetica findfont 20 scalefont setfont\r");
fprintf(prn,"(PostScript Job) show\r"); /** Print text **/
fprintf(prn,"showpage\r");
fprintf(prn,"\004"); /**** ^D *******/
fprintf(prn,"\033%%-12345X"); /*** UEL Command ***/
fclose(prn);
}
Notice the %% required to print the % character