承接 imag/files-bundle 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

imag/files-bundle

最新稳定版本:v3.0.3

Composer 安装命令:

composer require imag/files-bundle

包简介

Files Bundle for Symfony 2

README 文档

README

This bundle can create/manage PDFs files. it can create a Pdf from a html page and append many Pdfs files on the document and zip final document. It use KnpSnappyBundle to create PDF from Html and ZendPdf to append pdfs files.

Install

  1. Download FilesBundle
  2. Enable the bundle
  3. Configure the KnpSnappyBundle

How get the bundle

Caution:

The dev-master version have not backward compatibility with the 2.x version.

Composer

Modify your composer.json on your project root

// {root}/composer.json

{
    [...],
    "require": {
        [...],
        "imag/files-bundle": "dev-master"
    }
}

Enable the Bundle

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
    // ...
    new IMAG\FilesBundle\IMAGFilesBundle(),
    );
}

Configure KnpSnappyBundle

Please read the official KnpSnappyBundle documentation https://github.com/KnpLabs/KnpSnappyBundle

Usage

Create PDF from Html

<?php

$pdf = $this->get('imag_files.pdf')
    ->setTemplate("foo.html.twig", array('includeVar', $includeVar))
    ->setPdfPrefix('foo-file') // Like : 'foo-file-uniqId().pdf'
    ->setPath('/home/foo/tmp') // Default sys_get_temp_dir()
    ->addParameter('name', $value)
    ->htmlToPdf()
    ;

Append pdf file to final document

<?php

$pdf = $this->get('imag_files.pdf')
    ->setPdfPath($finalPdf)
    ->appendFiles(array($file1, $files2))
    ;

Adding files into zip archive

<?php

$zip = $this->get('imag_files.zip')
    ->add($pdf)
    ;

Example

Twig template

<!DOCTYPE html>
<html>
  <head>
    <meta charset='utf-8'>
    {% include('NSFooBundle:Pdf/css:' ~ includeVar) %}
  </head>

  <body>
    <h1>{{ data.title }}</h1>
    <h2>{{ data.body }}</h2>
  </body>
</html>

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: CeCILL
  • 更新时间: 2013-02-07