2012-10-04 31 views
2

当我没有能力发送打印作业,这是工作和打印:Google云打印。如何提交有效的功能?

<?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

在我发现的GCP文档中,只有Google Cloud Ready打印机支持该功能(打印格式,副本数量等)!

这时我发现只有一个这样做的方法就是:配置在一次打印机的你的操作系统驱动程序设置在A7打印,它会在A7

总是打印
6

我目前正在执行无人值守打印一个使用云打印的网络应用程序,这已经过了漫长的一天!从谷歌对话(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

这是有价值的,很难得到的信息 - 谢谢!如果可以的话,我会多花点时间。作为参考,我消除了我的请求对象中的“type”属性,它工作正常。 – pettys