javajakarta-eeprintingpostscriptpjl

Printing using HP Printer via LPR - PJL with PS


I am using the printer HP LaserJet 5000 Series PCL6. Trying to set print attributes like copies and orientation using PJL. Using PostScript as the underlying job language. I am using LPR command (lpr -S{IP} -P{IP} test.txt) to run the below code to print from windows. The printer does not print any content at all. If i remove the PJL specific commands and just run the PS alone, the content is printed correctly. Is there anything that i am missing?

     Ec%-12345X@PJL SET COPIES = 3
     @PJL ENTER LANGUAGE = POSTSCRIPT
     %!PS-Adobe-3.0
     %% Example 1

     newpath
     100 200 moveto
     200 250 lineto
     100 300 lineto
     2 setlinewidth
     stroke
     showpage ^D Ec%-12345X

I also tried using <ESC> in the place of Ec.


Solution

  • Ec and <ESC> are both incorrect. You need the actual ASCII code for ESC which is ASCII character 27.

    The easiest way is:

    char esc = 27;
    

    and you can then incoroporate that as needed