要让FPDI和TTCPDF类一起工作,我遇到了一个很奇怪的问题。
FPDI:http://www.setasign.com/products/fpdi/about/
TCPDF:http://www.tcpdf.org/
从阅读,甚至看一些例子,这些应该一起工作没有问题.
但是..。我有点矛盾(或者别的什么)
这个链接展示了一种简单而直接的同时使用TPDF和TCPDF类的方法:
setasign.com/products/fpdi/demos/tcpdf-demo/
我正在使用WAMP在本地运行这个/测试这个。和PHP版本5.4.12
<?php
// just require TCPDF instead of FPDF
//require_once 'fpdf/fpdf.php'; //old
require_once('tcpdf/tcpdf.php');
require_once('fpdi/fpdi.php');
class PDF extends FPDI{
}
// initiate FPDI
$pdf = new FPDI();
// add a page
$pdf->AddPage();
// set the source file
$pdf->setSourceFile("SRS_blank.pdf");
// import page 1
$tplIdx = $pdf->importPage(1);
// use the imported page and place it at point 10,10 with a width of 210mm (width of A4)
$pdf->useTemplate($tplIdx, 0, 0, 210, 297);
// now write some text above the imported page
//position table at bottom
$pdf->SetXY(0, 200);
//set table font
$pdf->SetFont('Helvetica');
//set table color
$pdf->SetTextColor(255, 0, 0);
//table html
$html = '<table border="1" cellspacing="2" cellpadding="2">
<tr>
<td width="70" rowspan="6">Company Name</td>
</tr>
<tr>
<td rowspan="6"><img src="images/SRS_logo.jpg"></td>
</tr>
<tr>
<td>Name</td>
<td>Address</td>
<td>City/State/Zip</td>
<td>phone/fax</td>
<td>email</td>
<td>URL</td>
</tr>
</table>';
// output the HTML table to pdf overlay
$pdf->writeHTML($html, true, false, true, false, '');
$pdf->Output();
?>
下面是我在尝试使用TCPDF时遇到的错误(TCPDF在显示内容时有更健壮的选项)
严格标准:在第167行的C:\wamp\www\projects\PDF_generation\FPDI\fpdi2tcpdf_bridge.php中,FPDF::_putstream()的声明应该与TCPDF::_putstream($s,$n = 0)兼容
这是:
严格的标准:在第460行的C:\wamp\www\projects\PDF_generation\FPDI\fpdf_tpl.php中,FPDF_TPL::SetFont()的声明应该与TCPDF::SetFont($family,$style = '',$size = NULL,$fontfile = '',$subset = 'default',$out = true)兼容。
我被困在如何获得一个合适的开发环境来测试和使用这两个类?
有什么想法吗?感谢所有的建议。
谢谢!
发布于 2014-02-21 06:30:29
当重载函数需要指定所有参数时(也使用默认值)
在第31行的fpdi2tcpdf_bridge.php
文件中,函数的集合声明
function _putstream($s) {
在……上面
function _putstream($s, $n=0) {
在第275行的file fpdf_tpl.php
中,函数的集合声明
public function SetFont($family, $style = '', $size = 0) {
在……上面
public function SetFont($family, $style = '', $size = 0, $fontfile = '', $subset = 'default', $out = true) {
发布于 2014-08-04 17:06:27
从FPDI和TCPDF的最新版本来看,这种严格的警告不应该再发生了。我不知道FPDI的哪个版本,当它们最终正确地开始重载TCPDF函数时,但是下面的PHP、FPDI和TCPDF的混合似乎不再生成这些警告了.
PHP版本: 5.5.10
FPDI版本: 1.5.2 - http://www.setasign.com/products/fpdi/downloads/
TCPDF版本: 6.0.089 - http://sourceforge.net/projects/tcpdf/files/
https://stackoverflow.com/questions/19912591
复制相似问题