atans/atans-gcp 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

atans/atans-gcp

Composer 安装命令:

composer require atans/atans-gcp

包简介

Google Cloud Print module for Zend Framework 2

关键字:

README 文档

README

Google Cloud Print module for Zend Framework 2 (Beta Version)

Installation

With composer

1.Add this project in your composer.json:

"require": {
    "atans/atans-gcp": "dev-master"
}

2.Now tell composer to download AtansGCP by running the command:

$ php composer.phar update

Post installation

  1. Enabling it in your application.config.php file.
<?php
return array(
    'modules' => array(
        // ...
        'AtansGCP',
    ),
    // ...
);
  1. Copy ./vendor/atans/atans-gcp/config/attansgcp.global.php.dist to ./config/autoload/attansgcp.global.php

  2. Add printers to your email account via Google Chrome or https://www.google.com/cloudprint/learn/

  3. Edit ./config/autoload/attansgcp.global.php

    'gcp_email'       => 'your.email@gmail.com',
    'gcp_password'    => 'your.email.password',

Use it

Get printers

class IndexController extends AbstractActionController
{
    public function indexAction()
    {
        $cloudPrint = $this->getServiceLocator()->get('AtansGCP\Google\CloudPrint\CloudPrint');
        $printers = $cloudPrintService->getPrinters();

        var_dump($printers);
    }

    //...

Submit job

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());
    }

    //...

统计信息

  • 总下载量: 59
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-04-16

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固