duanquan4451 2013-11-11 17:44
浏览 99

FPDI和TCPDF问题?

Im having a rather odd problem getting FPDI & TTCPDF php classes to work together.

FPDI: http://www.setasign.com/products/fpdi/about/

TCPDF: http://www.tcpdf.org/

From reading around and even looking at some of the examples given, these should work together NO PROBLEM...

however.. I am getting some conflicts (or something)

This link shows a rather simple & straight forward way to using BOTH the TPDF and TCPDF classes together:

setasign.com/products/fpdi/demos/tcpdf-demo/

I am running this/testing this LOCALLY using WAMP.. and PHP version 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();
?>

Here are the errors I am now getting when trying to use TCPDF (which has much more robust options for displaying content)

Strict standards: Declaration of FPDF::_putstream() should be compatible with TCPDF::_putstream($s, $n = 0) in C:\wamp\www\projects\PDF_generation\FPDI\fpdi2tcpdf_bridge.php on line 167

and this:

Strict standards: Declaration of FPDF_TPL::SetFont() should be compatible with TCPDF::SetFont($family, $style = '', $size = NULL, $fontfile = '', $subset = 'default', $out = true) in C:\wamp\www\projects\PDF_generation\FPDI\fpdf_tpl.php on line 460

I am stuck on HOW I get a decent dev environment to test and work with these two classes?

Any ideas? all suggestions appreciated.

thanks!

  • 写回答

2条回答 默认 最新

  • draj30958 2014-02-21 06:30
    关注

    when overloading function need specify all params (also with default value)

    In file fpdi2tcpdf_bridge.php at line 31 set declaration of function

    function _putstream($s) {
    

    on

    function _putstream($s, $n=0) {
    

    AND in file fpdf_tpl.php at line 275 set declaration of function

    public function SetFont($family, $style = '', $size = 0) {
    

    on

    public function SetFont($family, $style = '', $size = 0, $fontfile = '', $subset = 'default', $out = true) {
    
    评论

报告相同问题?

悬赏问题

  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥50 我撰写的python爬虫爬不了 要爬的网址有反爬机制
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥120 计算机网络的新校区组网设计
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等