0

我想创建一个 24 页的 A5 PDF 文档,不需要考虑 slug 或 bleed,什么是最好的 Zendframwork 2 PDF 生成模块?你有教程或示例请给我链接

谢谢你 ..

4

2 回答 2

1

我使用TCPDF

要在您的 Zf2 安装中启动并运行它,您必须在您的composer.json. 它应该看起来像这样。

{
  "name": "...
  "description": "...",
  "require": {
      "php": ">=5.4",
      ....
      "tecnick.com/tcpdf": ">=6.0.043"
      ....
  },
  "repositories": [{
       "type":"package",
       "package": {
           "name": "tecnick.com/tcpdf",
           "version":"master",
           "source": {
                "url": "http://git.code.sf.net/p/tcpdf/code",
                "type": "git",
                "reference":"master"
           }
       }
  }],
  "minimum-stability": "dev",
  "prefer-stable": true,
  "autoload": {
    "classmap": [
      "vendor/tecnick.com/tcpdf"
    ]
  }
}

此处的功能将在您的供应商/作曲家路径中"autoload"创建一些条目。autoload_classmap.php

<?php

// autoload_classmap.php @generated by Composer

$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);

return array(
...
   'TCPDF' => $vendorDir . '/tecnick.com/tcpdf/tcpdf.php',
   'TCPDF2DBarcode' => $vendorDir . '/tecnick.com/tcpdf/tcpdf_barcodes_2d.php',
   'TCPDFBarcode' => $vendorDir . '/tecnick.com/tcpdf/tcpdf_barcodes_1d.php',
   'TCPDF_COLORS' => $vendorDir . '/tecnick.com/tcpdf/include/tcpdf_colors.php',
   'TCPDF_FILTERS' => $vendorDir . '/tecnick.com/tcpdf/include/tcpdf_filters.php',
   'TCPDF_FONTS' => $vendorDir . '/tecnick.com/tcpdf/include/tcpdf_fonts.php',
   'TCPDF_FONT_DATA' => $vendorDir . '/tecnick.com/tcpdf/include/tcpdf_font_data.php',
   'TCPDF_IMAGES' => $vendorDir . '/tecnick.com/tcpdf/include/tcpdf_images.php',
   'TCPDF_IMPORT' => $vendorDir . '/tecnick.com/tcpdf/tcpdf_import.php',
   'TCPDF_PARSER' => $vendorDir . '/tecnick.com/tcpdf/tcpdf_parser.php',
   'TCPDF_STATIC' => $vendorDir . '/tecnick.com/tcpdf/include/tcpdf_static.php',
...
);

此时,您可以创建一个 Pdf 对象或根据自己的喜好使用其他定义的类。

//to create a Pdf Object
$pdf = new \TCPDF('P', 'mm', 'A4', true, 'UTF-8', false);

可悲的是,TCPDF 网站不是很漂亮,也不清楚在那里找到东西(在我看来)。但它确实提供了相当多的例子,涵盖了相当多的内容。

于 2013-11-05T10:30:46.960 回答
0

这一切都取决于几件事;

您需要对 PDF 进行多少控制 您是否能够安装 php 扩展?您是从头开始制作 PDF,还是转换其他格式等

packagist.org 上有一些,可以通过 composer 轻松安装,还有一个可以与 ZF2 组件一起使用:

https://github.com/psliwa/PHPPdf/tree/master
于 2013-11-05T09:17:50.370 回答