【问题标题】:Google cloud print. how to submit valid capabilities?谷歌云打印。如何提交有效能力?
【发布时间】:2012-09-25 07:23:53
【问题描述】:

当我发送没有功能的打印机作业时,它可以工作并打印:

<?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, "");
?>

而且它不想打印。只是错误。也许有人知道如何正确地做到这一点?

【问题讨论】:

    标签: php google-cloud-print


    【解决方案1】:

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

    目前我发现只有一种方法可以做到这一点:只需在打印机的操作系统驱动程序中立即配置设置以在 A7 中打印,它将始终在 A7 中打印

    【讨论】:

      【解决方案2】:

      我目前正在使用云打印为 Web 应用程序实现无人值守打印,这已经是漫长的一天!

      从 google 对话框 (https://www.google.com/cloudprint/gadget.html) 打印时一切正常,但是通过我的 API 发送文件时一切都搞砸了(在热敏打印机上打印餐厅门票,最后有 50 厘米的上边距)

      在网上到处查看后,我意识到 google print 小工具是纯 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:[...]},也很令人困惑!

      【讨论】:

      • 这是有价值且难以获得的信息——谢谢!如果可以的话,我会再投票几次。作为参考,我删除了请求对象中的“类型”属性,它工作正常。
      猜你喜欢
      • 2013-07-15
      • 2012-09-23
      • 2016-04-15
      • 2014-07-21
      • 2013-03-10
      • 2015-04-23
      • 1970-01-01
      • 2013-12-18
      • 1970-01-01
      相关资源
      最近更新 更多