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

查看:30
本文介绍了使用 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 和处理基于 PDF 的打印作业的 PJL 时需要熟悉的最重要的基础知识.您必须自己将这些通用信息翻译"为 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 代码在大多数情况下都无效.在 PDF 打印作业文件中添加 PJL 行的标准方法是:

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

说明:

  • 这里表示转义字符(27十进制,1B十六进制).
  • <CR> 表示回车字符(13 十进制,0D 十六进制).它在 PJL 中可选.
  • 表示换行 字符(10 十进制,0A 十六进制).它在 PJL 中必需.
  • %-12345X 表示 'Universal Exit Language' 命令 (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天全站免登陆