FPDI和TCPDF问题?

whi*_*ers 1 php pdf pdf-generation fpdi tcpdf

我有一个相当奇怪的问题,让FPDI和TTCPDF php类一起工作.

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测试此LOCALLY

<?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();
?>
Run Code Online (Sandbox Code Playgroud)

以下是我在尝试使用TCPDF时遇到的错误(TCPDF具有更强大的显示内容选项)

严格的标准:FPDF :: _ putstream()的声明应与第167行的C:\ wamp\www\projects\PDF_generation\FPDI\fpdi2tcpdf_bridge.php中的TCPDF :: _ putstream($ s,$ n = 0)兼容

还有这个:

严格标准:FPDF_TPL :: SetFont()声明应与TCPDF :: SetFont兼容($ family,$ style ='',$ size = NULL,$ fontfile ='',$ subset ='default',$ out =在第460行的C:\ wamp\www\projects\PDF_generation\FPDI\fpdf_tpl.php中)

我被困在如何获得一个体面的开发环境来测试和使用这两个类?

有任何想法吗?所有建议赞赏.

谢谢!

hai*_*ive 6

当重载函数需要指定所有参数时(也有默认值)

fpdi2tcpdf_bridge.php第31行的文件中设置函数声明

function _putstream($s) {
Run Code Online (Sandbox Code Playgroud)

function _putstream($s, $n=0) {
Run Code Online (Sandbox Code Playgroud)

AND在file fpdf_tpl.php第275行设置函数声明

public function SetFont($family, $style = '', $size = 0) {
Run Code Online (Sandbox Code Playgroud)

public function SetFont($family, $style = '', $size = 0, $fontfile = '', $subset = 'default', $out = true) {
Run Code Online (Sandbox Code Playgroud)