Search code examples
pcl6

Create PCL by hand?


Is it more or less feasible to create PCL files "artisanally", by hand? I have done it for PostScript and found it not particularly difficult, though it takes a lot of time and effort to create even a simple drawing. Now I am faced with an OKI C823 that is connected to an Ubuntu PC, it prints ok but does not understand PostScript - which might explain why it was so inexpensive... (for such a big printer) I did find the below sample in the "PCL XL Feature Reference" but when I fed it to the printer, the text just printed as text instead of drawing the intended line.

eInch Measure
600 600 UnitsPerMeasure
BeginSession // attribute: basic measure for the session is inches
// attribute: 600 units in both X and Y direction
// operator: begin the imaging session
ePortraitOrientation Orientation
eLetterPaper MediaSize
BeginPage // attribute: page orientation is portrait
// attribute: size of media for page is letter
// operator: begin the page description
1200 800 Point
SetCursor // attribute: point a which to set the current cursor
// operator: set the cursor
2400 800 EndPoint
LinePath // attribute: endpoint of a 2 inch line
// operator: add the line to the current path
PaintPath // operator: paint the current path
EndPage // operator: end the page description
EndSession // operator: end the imaging session

Solution

  • Edit

    You can convert ps to pcl with ghostscript

    sudo apt-get install ghostscript
    gs -o ~/test.pcl -sDEVICE=pxlcolor -f ~/test.ps
    

    or

    gs -o ~/test.pcl -sDEVICE=pxlmono -f ~/test.ps
    

    If you need to go backward for some reason--convert pcl to ps--then see the more complicated instructions below


    You can convert from pcl6 to ps using GhostPDL from Ghostscript. It's a separate product from Ghostscript, and afaik the only way to install it is to build it from source.

    Build It

    I'm using ubuntu 18 LTS. some prereqs I needed, your system might already have them

    sudo apt-get install autoconf
    sudo apt-get install g++
    sudo apt-get install make
    

    download the source, untar, and build

    wget https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs950/ghostpdl-9.50.tar.gz
    tar xvf ghostpdl-9.50.tar.gz
    cd ghostpdl-9.50
    sh ./autogen.sh
    make
    

    The binaries are in the bin folder

    cd ./bin
    

    Sample Usage

    I copied a test.ps file from wikipedia that prints "Hello World" in courier.

    Convert ps to pcl, convert the pcl back to pdf

    ./gs -o ~/test.pcl -sDEVICE=pxlcolor -f ~/test.ps
    ./gpcl6 -o ~/test.pdf -sDEVICE=pdfwrite ~/test.pcl
    

    And everything worked as expected.