Zend框架2 PDF生成 [英] Zend framework 2 PDF generation
问题描述
我想创建一个 24 页的 A5 PDF 文档,不需要考虑 slug 或出血,什么是最好的 Zendframwork 2 PDF 生成模块?你有教程或例子请给我链接
I want to crate single A5 PDF document with 24 pages , There is no need to account for slugs or bleed , What is the Best Zendframwork 2 PDF generation Module for this ? Do you have tutorials or example pleas send me the links
谢谢...
推荐答案
我使用 TCPD.
要在 Zf2 安装中启动并运行它,您必须向 composer.json
添加一点额外的内容.它应该看起来像这样.
To get it up and running within your Zf2 installation you have to add a litle extra to your composer.json
. It should look something like this.
{
"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
中创建一些条目.
The "autoload"
functionality here will create a few entries within your autoload_classmap.php
in your vendor/composer path.
<?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 对象或使用其他定义的类.
At this point you can just create a Pdf Object or use the other defiened Classes to your liking.
//to create a Pdf Object
$pdf = new \TCPDF('P', 'mm', 'A4', true, 'UTF-8', false);
遗憾的是,TCPDF 网站不太好看,也不清楚在那里找到东西(在我看来).但它确实提供了相当多的示例,涵盖了相当多的内容.
Sadly the TCPDF website is not quite the looker nor is it clear to find things there (in my opinion). But it does provide quite a few examples which cover quite a bit.
这篇关于Zend框架2 PDF生成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!