falgun/phantom-bundle

使用 phantomjs 生成 PDF

安装: 68

依赖: 0

建议者: 0

安全性: 0

星标: 2

关注者: 3

分支: 0

开放问题: 0

类型:symfony-bundle

dev-master 2014-02-26 06:52 UTC

This package is not auto-updated.

Last update: 2024-09-28 14:43:01 UTC


README

这是一个使用 phantomjs 生成 PDF 的 symfony 2 扩展包。

安装

步骤 1:您需要在您的机器上下载 Phantomjs 来使用此扩展包

从以下链接安装 phantomjs 1.9.2:http://phantomjs.org/download.html

步骤 2:下载 FalgunPhantomBundle

将 FalgunPhantomBundle 添加到您的 composer.json 文件中,如下所示

"falgun/phantom-bundle": "dev-master"

使用此命令更新/安装

php composer.phar update "falgun/phantom-bundle"
步骤 2:启用扩展包

注册扩展包

public function registerBundles()
{
    $bundles = array(
        ...
        new Falgun\Bundle\PhantomBundle\FalgunPhantomBundle(),
);
步骤 3:激活主要配置
# app/config/config.yml
falgun_phantom:
  config:
    format: 'A3'
    margin: '.5cm'
    zoom: 1
    orientation: 'portrait'
    rendering_time: 1000
    viewport_width: 800
    viewport_height: 800
    rendering_timeout: 90000
    phantomjs: '/usr/local/bin/phantomjs'

如何使用?

public function indexAction()
{
    $falgun_pdf = $this->get('falgun_pdf');
    $result = $falgun_pdf->to_pdf("http://www.google.com");
}