smachara/html2pdfbundle 问题修复 & 功能扩展

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

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

smachara/html2pdfbundle

最新稳定版本:v2.1.1

Composer 安装命令:

composer require smachara/html2pdfbundle

包简介

This is a Bundle to use the last version of spipu-Html2pdf as a service in Symfony2 applications. I did this bundle because 'ensepar/html2pdf-bundle' does not use the last versions of spipu-Html2pdf and TCPDF. The rest still the same.

README 文档

README

This is a Bundle to use the last version of spipu-Html2pdf as a service in Symfony2 applications.

I did this bundle because "ensepar/html2pdf-bundle" does not use the last versions of spipu-Html2pdf and TCPDF. The rest still the same.

Installation

Step 1: Setup Bundle and dependencies

composer require smachara/html2pdfbundle

Step 2: Configure the autoloader

Add the smachara namespace to your autoloader:

// app/autoload.php
<?php
// ...
$loader->add('smachara',   __DIR__ . '/../vendor');

Step 3: Enable the bundle in the kernel

Add the bundle to the registerBundles() method in your kernel:

// app/AppKernel.php
<?php

public function registerBundles()
{
    $bundles = array(
        // ...
        new smachara\html2pdfbundle\smacharaHtml2pdfBundle(),
    );
}

How to use ?

In your action:

public function printAction()
    {
        $pdf = $this->get('html2pdf_factory')->create();
        $html = $this->renderView('PdfBundle:Pdf:content.html.twig', array( 'preview' => false));
        $pdf->writeHTML($html);
        $response = new Response($pdf->Output('test.pdf','D'));
        return $response;
    }

You can pass every option you would pass to $pdf, for instance :

$pdf = $this->get('html2pdf_factory')->create('P', 'A4', 'en', true, 'UTF-8', array(10, 15, 10, 15));

If the previous arguments are not provided, the factory uses its own default values. You can change this default values by adding the bundle configuration to your app/config/config.yml :

smachara_html2pdf:
    orientation: P
    format: A4
    lang: en
    unicode: true
    encoding: UTF-8
    margin: [10,15,10,15]

License

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: LGPL
  • 更新时间: 2016-03-24