使用PHP代码将PJL命令添加到PDF文件中 [英] Add PJL command into PDF file with PHP code

查看:336
本文介绍了使用PHP代码将PJL命令添加到PDF文件中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在不将PDF转换为PostScript的情况下将PJL命令插入PDF

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

*STARTPJL
@PJL SET STAPLE=LEFTTOP
*ENDPJL

在我通过FTP或LPR将其发送到打印机后.

after I send it to printer via FTP or LPR.

我正在使用Zend_Pdf创建PDF文档.

I'm using Zend_Pdf to create PDF documents.

**我没有成功尝试此代码

**I tried unsuccessfully this code

$a .= "<ESC>%-12345X@PJL<CR><LF>";
$a .= "@PJL SET OUTBIN=OUTBIN101<CR><LF>";
$a .= "@PJL SET STAPLE=LEFTTOP<CR><LF>";
$a .= "@PJL ENTER LANGUAGE = PDF<CR><LF>";
$a .= file_get_contents("/www/zendsvr/htdocs/GDA/public/pdf/test.pdf");
$a .= "<ESC>%-12345X";

$myfile = fopen("/www/zendsvr/htdocs/GDA/public/pdf/t.pdf", "w");
fwrite($myfile, $a);
fclose($myfile);

文档已正确打印,但不会改变打印纸且不会卡住,有什么建议吗?

the document is printed correctly but does not change the drawe and not clamp, any suggestions?

推荐答案

我不会解释如何使用PHP实现以下几点.这些要点仅说明与PJL和PJL有关基于PDF的打印作业时应熟悉的最重要的基础知识.您必须自己将此通用信息翻译"为PHP....

您不能 插入 PJL命令插入 PDF.但是,您可以 添加 PJL命令到PDF打印作业.

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

此外,在 通过FTP或LPR将其发送到打印机后,执行此操作没有任何意义.只有在发送文件之前 这样做才有意义.

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.

接下来,您的示例PJL代码在大多数情况下无效.将PJL行添加到PDF打印作业文件的标准方法是:

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:

  • 此处<ESC>表示转义字符(十进制27,十六进制1B).
  • <CR>表示回车字符(dec中的13,十六进制的0D).在PJL中,这是可选.
  • <LF>表示换行符字符(dec中的10,十六进制的0A).它是PJL中的必需.
  • <ESC>%-12345X表示通用退出语言" 命令(UEL).它是PJL中的必需.它定义了任何基于PJL的数据流的开始和结束.
  • 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.

最后,请注意:

  1. 并非所有打印机和所有LPR打印服务都能够处理基于PDF的打印作业.

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

而且,并非所有打印机和LPR打印服务都不能使用PJL命令,这些命令是用来打印作业文件的.

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

这篇关于使用PHP代码将PJL命令添加到PDF文件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆