我目前正在向php后端系统添加该功能以允许其直接打印,并且我正尝试使用Google的云打印工作。将该应用想象为一个在线购物车,并且我希望它能够打印采摘备忘录(已完成订单),而无需登录。服务器是远程的,目的地是Cloud Ready打印机。使用Google云打印进行PHP打印
到目前为止,只要我简单地将HTML,纯文本或URL传递到PDF,我就能成功地使用interfaces进行打印。我可以将打印设置为彩色,无边距和打印质量。
但是,当我遇到问题时,系统创建的PDF不能公开访问,因此我无法将URL传递给该文件,我需要传递该文件的内容。
我一直在努力修改我在网上找到的一个例子HERE。但是我不知道这种语言,所以我一直在努力。
python HERE的另一个例子我一直在努力没有成功!
我使用PHP和Zend框架来处理接口。这里是我尝试过的一个示例,简化为我准备发送文件的位置,就像我说的我并不确定从python到php的翻译,或者python脚本甚至可以工作,但这是什么我想出了:
<?php
// Test print a job:
$b64_pathname = PDF_PATH.'ec22c3.pdf'.'.b64';
$fileType = "application/pdf";
// Open the original file and base64 encode it:
$dataHandle = fopen(PDF_PATH.'ec22c3.pdf', "rb");
$dataContent = fread($dataHandle, filesize(PDF_PATH.'ec22ed167763a15e8591a3776f3c65c3.pdf'));
fclose($dataHandle);
$b64data = $fileType.base64_encode($dataContent);
// Store the base64 encoded file:
$ourFileHandle = fopen($b64_pathname, 'w');
fwrite($ourFileHandle, $b64data);
fclose($ourFileHandle);
// Read the contents of the base64 encoded file and delete it:
$fileHandle = fopen($b64_pathname, "rb");
$fileContent = fread($fileHandle, filesize($b64_pathname));
fclose($fileHandle);
unlink($b64_pathname);
// URL encode the file contents:
$file = urlencode($fileContent);
// Add the file and send to the printer:
$client->setParameterPost('content', $file);
$client->setParameterPost('contentType', $fileType);
$client->request(Zend_Http_Client::POST);
?>
我会试试看。 – Cymbals 2012-04-11 21:35:44