PHP code example of atans / atans-gcp
1. Go to this page and download the library: Download atans/atans-gcp library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
atans / atans-gcp example snippets
return array(
'modules' => array(
// ...
'AtansGCP',
),
// ...
);
class IndexController extends AbstractActionController
{
public function indexAction()
{
$cloudPrint = $this->getServiceLocator()->get('AtansGCP\Google\CloudPrint\CloudPrint');
$printers = $cloudPrintService->getPrinters();
var_dump($printers);
}
//...
class IndexController extends AbstractActionController
{
public function indexAction()
{
$file = 'example.pdf';
$handle = fopen($file, 'r');
$content = fread($handle, filesize($file));
fclose($handle);
$cloudPrintService = $this->getServiceLocator()->get('AtansGCP\Google\CloudPrint\CloudPrint');
// Your printer id
$printerId = 'fb3a765e-50ad-94b0-6101-example';
// Set page size as A4
$mediaSizeTicket = new \AtansGCP\Google\CloudPrint\Ticket\Item\MediaSizeTicketItem();
$mediaSizeTicket->setVendorId('psk:ISOA4')
->setWidthMicrons(210000)
->setHeightMicrons(297000);
$printTicket = new \AtansGCP\Google\CloudPrint\Ticket\Section\PrintTicketSection();
$printTicket->setMediaSize($mediaSizeTicket);
$ticket = new \AtansGCP\Google\CloudPrint\Model\Ticket();
$ticket->setPrint($printTicket);
$submit = new \AtansGCP\Google\CloudPrint\Model\Submit();
$submit->setTitle('Example')
->setContent($content)
->setTicket($ticket)
->setPrinterId($printerId)
->setContentType('application/pdf');
/**
* @var \AtansGCP\Google\CloudPrint\Response\SubmitResponse $response
*/
$response = $this->getCloudPrintService()->submit($submit);
var_dump($response->getSuccess());
var_dump($response->getJob());
}
//...