简体   繁体   English

如何通过IPP协议打印HTML文档?

[英]How printing HTML document via IPP protocol?

So, I write PHP component, that can print documents via IPP (Internet Printing Protocol). 因此,我编写了PHP组件,该组件可以通过IPP(Internet打印协议)打印文档。 But I can not print HTML document (text|html - mimetype) correct. 但是我无法正确打印HTML文档(text | html-mimetype)。 Printer has printed this type as RAW. 打印机已将此类型打印为RAW。 May be somebody give example of correct request (header and body)? 可能有人给出正确请求的示例(标题和正文)?

For example my incorrect request, that was printed as RAW data. 例如,我的错误请求被打印为RAW数据。

Headers: 头:

POST /printers/CanonLPR HTTP/1.1
Host: 10.2.2.105:631
Connection: close
Accept-encoding: gzip, deflate
User-agent: EHttpClient
Content-Type: application/ipp
Content-Length: 772

Body: 身体:

Gattributes-charsetutf-8Hattributes-natural-languageen_usEprinter-uri'http://10.2.2.105:631/printers/CanonLPRDrequesting-user-name
PHP-SERVERIdocument-format  text/html<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="language" content="ru" />
</head>
<body>
<img style="float: left; margin-right: 10px;" src="/static/img/printer.png" />
<h1>Test page</h1>
</body>
</html>

Even though eg CUPS advertises support for text/html (see it's printer attribute document-formats-supported ) it's not converting html to eg postscript. 即使例如CUPS宣传了对text/html支持(请参阅document-formats-supported属性document-formats-supported的打印机属性),但它并未将html转换为例如postscript。

You can not expect a printer or spooler to render HTML for you (like a browser would). 您不能期望打印机或后台打印程序能够为您呈现HTML (就像浏览器一样)。 You might want to search for a html-to-pdf converter as a workaround. 您可能需要搜索html-to-pdf转换器作为解决方法。

A typical and proper solution would involve a dedicated pdf-library for creating printable documents. 一个典型且适当的解决方案将包括创建可打印文档的专用pdf库。 The downside is you'd have to code the layout again. 缺点是您必须重新编码布局。

Step 2 would involve submitting the job to the printer. 步骤2将涉及将作业提交给打印机。 It look's like you can handle this. 看起来您可以处理。 If not check this answer . 如果没有,请检查此答案 Also there's an IPP implementation for PHP available at http://www.nongnu.org/phpprintipp/ http://www.nongnu.org/phpprintipp/上也有一个PHP的IPP实现

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM