Add PJL command into PDF file with PHP code

前端 未结 1 1771
终归单人心
终归单人心 2021-01-05 11:59

How can I insert a PJL command into PDF without having to convert PDF to PostScript

*STARTPJL
@PJL SET STAPLE=LEFTTOP
*ENDPJL

after I send

相关标签:
1条回答
  • 2021-01-05 12:03

    I'm not going to explain how to achieve the following points with PHP. These points merely explain the most important fundamentals to be familiar with when dealing with PJL and with PJL regarding PDF-based print jobs. You have to 'translate' this generic info to PHP yourself....


    You cannot insert PJL commands into PDF. But you can prepend PJL commands to a PDF print job.

    Also, it is not meaningful to do this after you send it to a printer via FTP or via LPR. It is only meaningful if you do it before sending the file.

    Next, your example PJL code is not valid for most purposes. The standard way to prepend PJL lines to a PDF print job file is this:

    <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
    

    Explanations:

    • Here <ESC> denotes the escape character (27 in decimal, 1B in hex).
    • <CR> denotes the carriage return character (13 in dec, 0D in hex). It is optional within PJL.
    • <LF> denotes the line feed charaxter (10 in dec, 0A in hex). It is required within PJL.
    • <ESC>%-12345X denotes the 'Universal Exit Language' command (UEL). It is required in PJL. It defines beginning and end of any PJL-based data stream.

    Lastly, please note:

    1. Not all printers and not all LPR print services are able to deal with PDF-based print jobs.

    2. Also, not all printers and not all LPR print services are able to honor PJL commands which are prepended to print job files.

    0 讨论(0)
提交回复
热议问题