定制 rarog/dompdf-helper 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

rarog/dompdf-helper

最新稳定版本:4.2.0

Composer 安装命令:

composer require rarog/dompdf-helper

包简介

DompdfHelper - a lightweight library wrapper Laminas module

README 文档

README

DompdfHelper - a lightweight library wrapper Laminas module

Build Status Coverage Status

Requirements

Installation

Installation of DompdfHelper uses PHP Composer. For more information about PHP Composer, please visit the official PHP Composer site.

Installation steps

  1. cd my/project/directory

  2. create a composer.json file with following contents:

    {
        "require": {
            "rarog/dompdf-helper": "^4.0"
        }
    }
  3. install PHP Composer via curl -s http://getcomposer.org/installer | php (on windows, download http://getcomposer.org/installer and execute it with PHP)

  4. run php composer.phar install

  5. open my/project/directory/config/application.config.php and add the following key to your modules:

    'DompdfHelper',

Configuration options

You can override default options via the dompdf key in your local or global config files. See the config/dompdf.config.php.dist file for the list of default settings.

Full list of possible settings is available at the official Dompdf library site.

Example usage

Controller factory

<?php

namespace My\Factory\Controller;

use Interop\Container\ContainerInterface;
use My\Controller\ExampleController;

class ExampleControllerFactory implements FactoryInterface
{
    /**
     * {@inheritDoc}
     * @see \Laminas\ServiceManager\Factory\FactoryInterface::__invoke()
     */
    public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
    {
        return new ExampleController(
            $container->get('dompdf')
        );
    }
}

Controller

<?php

namespace My\Controller;

use Dompdf\Dompdf;
use Laminas\Mvc\Controller\AbstractActionController;

class ExampleController extends AbstractActionController
{
    /**
     * @var Dompdf
     */
    private $dompdf;

    /**
     * Constructor
     *
     * @param Dompdf $dompdf
     */
    public function __construct(
        Dompdf $dompdf
    ) {
        $this->dompdf = $dompdf;
    }

    public function indexAction()
    {
        $this->dompdf->load_html('<strong>Hello World</strong>');
        $this->dompdf->render();

        file_put_contents(__DIR__ . '/document.pdf', $this->dompdf->output());
    }
}

统计信息

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

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2020-06-06