当我发送没有功能的打印机作业时,它的工作和打印:
<?php
$url = "http://www.google.com/cloudprint/submit?printerid=" . $printer_id . &output=json";
$post = array(
"printerid" => $printer_id,
"capabilities" => '',
"contentType" => "text/plain",
"title" => $title,
"content" => $docBytes
);
$post = http_build_query($post);
$ret = $this->processRequest($url, $post, "");
?>
但现在我需要以A7格式字母打印信息。所以我用一些功能编写了这段代码:
<?php
$url = "http://www.google.com/cloudprint/submit?printerid=" . $printer_id . "&output=json";
$post = array(
"printerid" => $printer_id,
"capabilities" => array('psk:MediaSizeWidth' => '74000', 'psk:MediaSizeHeight' => '104700'),
"contentType" => "text/plain",
"title" => $title,
"content" => $docBytes
);
$post = http_build_query($post);
$ret = $this->processRequest($url, $post, "");
?>
而且它不想打印。只是错误。也许有人知道如何正确地做到这一点?
答案 0 :(得分:6)
我目前正在使用云打印为Web应用程序实现无人值守打印,这已经是漫长的一天了!
从谷歌对话框(https://www.google.com/cloudprint/gadget.html)打印时一切正常,但通过我的API发送文件搞砸了所有内容(在热敏打印机上打印餐馆门票,最后有50厘米的上边距)
在网上到处查看后,我意识到谷歌打印小工具是纯HTML,使得提交请求非常容易捕获。只需触发开发工具,从对话框中打印一些内容,然后检查发布数据的“功能”值。
令人困惑的部分是这些设置需要采用类似PPD的格式,而不仅仅是普通的关联数组。
您可以使用正确的设置从所需的打印机进行打印,然后按照API /中的任何内容复制“功能”部分。作为一个例子,这是我的:
{"capabilities":[{"name":"TmtPaperSource","type":"Feature","options":[{"ppd:value":"\"\"","name":"PageFeedCut","displayName":"Page [Feed, Cut]"}]},{"name":"TmtPaperReduction","type":"Feature","options":[{"ppd:value":"\"\"","name":"Both","displayName":"Top & Bottom margins"}]}]}
并格式化:
{
"capabilities":[
{
"name":"TmtPaperSource",
"type":"Feature",
"options":[{
"ppd:value":"\"\"",
"name":"PageFeedCut",
"displayName":"Page [Feed, Cut]"
}]
},
{
"name":"TmtPaperReduction",
"type":"Feature",
"options":[{
"ppd:value":"\"\"",
"name":"Both",
"displayName":"Top & Bottom margins"
}]
}
]
}
最后注意:您需要将整个事物作为“功能”参数传递,这意味着您的请求类似.../submit?capabilities={capabilities:[...]}
,同样令人困惑!
答案 1 :(得分:0)
在GCP文档中,我发现,功能(打印格式,复印计数等)仅支持Google Cloud Ready打印机!
此时我发现只有一种方法可以做到这一点:只需在打印机的OS驱动程序中配置设置即可在A7中打印,它将始终在A7中打印