alejandrososa/yii-power-point

该软件包最新版本(dev-master)没有提供许可证信息。

Yii PowerPoint - 使用PHP创建和编写演示文稿,幻灯片由文本和图片组成

dev-master 2019-12-01 00:35 UTC

This package is not auto-updated.

Last update: 2024-09-14 19:20:15 UTC


README

Yii PowerPoint - 使用PHP创建和编写演示文稿,幻灯片由文本和图片组成

快速开始

您可以查看所有示例和文档

  yiiAppPath/protected/vendor/alejandrososa/yii-power-point/samples
  yiiAppPath/protected/vendor/alejandrososa/yii-power-point/README.md

安装

在命令行中,输入以下命令

    $ cd yiiAppPath/protected              
    $ composer init && composer install                    (optional if not have composer.json)
    $ composer require alejandrososa/yii-power-point dev-master

假设供应商已安装在yiiAppPath/index.php

    // Include the vendor's autoloader:
    $vendor = dirname(__FILE__) . '/protected/vendor/autoload.php';
    require_once($vendor);

现在我们在library/main.php中导入已安装的供应商,编辑protected/config/main.php,添加以下内容

    //(optional path alias for images)
    Yii::setPathOfAlias('images', dirname(dirname(dirname(__FILE__))).'/images');
    
    return array(
        // autoloading model and component classes
        'import' => array(
            'application.vendor.*',
            ...
        )
        // application components
        'components'=>array(
            'ppt' => array(
                'class' => 'AlejandroSosa\\YiiPowerPoint\\PowerPoint'
            )
            ...
        )
    ),

用法

在我们的控制器中,第一步是导入PowerPoint类

    // in your Controller
    (use optional, only to call constants defined in PowerPoint)
    use AlejandroSosa\YiiPowerPoint\PowerPoint;
    
    class SiteController extends Controller {
        ...
    }

现在在您的操作中

    /**
    * Create PPT
    */
    public function actionCreatePPT()
    {
        $options = [
            'fileName' => 'myFirstPPT',
            'fileProperties' => [
                'creator' => Yii::t('app', 'MyCompany'),
                'title' => Yii::t('app', 'State Budget 2016'),
                'subject' => Yii::t('app', 'Resumen General'),
                'description' => Yii::t('app', 'Any description')
            ],
            'layout' => [
                'background' => Yii::getPathOfAlias('images') .'/ppt/bg.png'
            ]
        ];

        $slides = [
            [
                'texts' => [
                    [
                        'text'=>Yii::t('app', 'Delivery'),
                        'options'=>[
                            'height'=>143, 'width'=>793, 'ox'=>120, 'oy'=>180,
                            'bold'=> true, 'size'=>44, 'color'=>PowerPoint::COLOR_CYAN,
                            'align'=>PowerPoint::TEXT_ALIGN_HORIZONTAL_CENTER,
                        ],
                    ],
                    [
                        'text'=>Yii::t('app', 'State Budget 2016'),
                        'options'=>[
                            'height'=>143, 'width'=>793, 'ox'=>170, 'oy'=>240,
                            'bold'=> false, 'size'=>40, 'color'=>PowerPoint::COLOR_BLUE,
                            'align'=>PowerPoint::TEXT_ALIGN_HORIZONTAL_CENTER,
                        ],
                    ] 
                ]
            ]
        ];
        
        Yii::app()->ppt->generate($options, $slides);
    }

图表设置

选项中的通用目的

图片

文本

表格

注意:样式可以在通用级别应用于所有行,或在特定级别应用于列,您可以在sample_tables中查看示例

图表

以下类型的图表可用:CHART_TYPE_BAR, CHART_TYPE_BAR_HORIZONTAL, CHART_TYPE_BAR_STACKED, CHART_TYPE_BAR_PERCENT_STACKED, CHART_TYPE_BAR_3D, CHART_TYPE_BAR_TRENDLINE, CHART_TYPE_PIE, CHART_TYPE_PIE_3D, CHART_TYPE_SCATTER.

散点图中以下符号可用:SYMBOL_CIRCLE, SYMBOL_DASH, SYMBOL_DIAMOND, SYMBOL_DOT, SYMBOL_NONE, SYMBOL_PLUS, SYMBOL_SQUARE, SYMBOL_STAR, SYMBOL_TRIANGLE, SYMBOL_X.

其他示例

创建表格和图表的其他示例可以在vendor/alejandrososa/yii-power-point/samples中找到

下一步是什么

如果您发现了一个错误,或者想到了一些改进,请告诉我