Search code examples
phppdfprintingprinter-control-language

PRINT PDF using PCL AND PJL in PHP


we have some ricoh printers in our offices and we want to print from php using a simple socket but some documents are pre printed and are located in tray 2 the default sheets are in tray 1 . i want to be able to select a tray of that printer using a combination of the PJL PDF and PJL PCL language . anyone has an idea maybe? i've found this on the forum :

<ESC>%-12345X@PJL<CR><LF>
@PJL SET STAPLE=LEFTTOP<CR><LF>
@PJL    [... more PJL commands if required ...]
@PJL ENTER LANGUAGE = PDF<CR><LF>
[... all bytes of the PDF file, starting with '%PDF-1.' ...]
[... all bytes of the PDF file ............................]
[... all bytes of the PDF file ............................]
[... all bytes of the PDF file, ending with '%%EOF' .......]
<ESC>%-12345X

it prints my pdf , however when i add the

@PJL ENTER LANGUAGE = PCL<CR><LF>
<ESC>&l1H <CR><LF>

around that code . i get some strange results... 1 pdf splits up over 5 papers with nothing but stream data (weird signs).

so i did the following

<ESC>%-12345X@PJL<CR><LF>
@PJL ENTER LANGUAGE = PCL<CR><LF>
<ESC>&l1H <CR><LF>
<ESC>%-12345X@PJL<CR><LF>
@PJL SET STAPLE=LEFTTOP<CR><LF>
@PJL    [... more PJL commands if required ...]
@PJL ENTER LANGUAGE = PDF<CR><LF>
[... all bytes of the PDF file, starting with '%PDF-1.' ...]
[... all bytes of the PDF file ............................]
[... all bytes of the PDF file ............................]
[... all bytes of the PDF file, ending with '%%EOF' .......]
<ESC>%-12345X

however this printed the file from tray 1 again , it seems that it lost the settings when trying to print the pdf file ...

anyone got any tips for me or can make a correction? i think i'm nearly there ...


Solution

  • Set paper type as workaround for tray selection:

    Not all printers with PDF Direct Print feature support the PJL mediasource instruction; e.g. Ricoh aficio printers do not. After weeks of struggling, I finally managed to get hold of the Ricoh manuals relating to PJL instructions supported by Ricoh. Ricoh supports the @PJL SET MEDIATYPE=SPECIAL – special is the paper as defined for a specific tray. You can assign a specific paper type for a tray, so requiring a specific paper results in using a specific tray. And provided the printer is properly configured (trays need to be set to “automatically selected”), this finally works.

    Source: http://www.tachytelic.net/2010/10/hp-direct-pdf-printing-and-printer-tray-control/

    I'm also interested in driverless printing using PJL to wrap pdf, and also working with Ricoh printers, plase keep me updated. Wich Ricoh models are you working with ?

    TIA