Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
400 views
in Technique[技术] by (71.8m points)

TP框架使用TCPDF这个生成PDF文件的类出现错误??

TCPDF ERROR: Some data has already been output, can't send PDF file
想问下为什么会这样啊。
我在控制器
public function guaranteeAgreement(){

    ..........//省略
    $this->assign ( 'names', $str );
    $this->assign ( 'invs', $invs );
    $this->assign ( 'binfo', $binfo );
    $this->assign ( 'borrower', $borrower );
    $this->assign ( 'cd_member', $cd_member );

    $html = $this->fetch ( 'agreement:guarantee' );

    $data['html'] = $html;

    $this->downAgreement($data);

}

private function downAgreement($data) {

     $this->pdfPath = C ( "APP_ROOT" ) . 'Lib/Tcpdf/';
    require $this->pdfPath . 'config/lang/eng.php';
    require $this->pdfPath . 'tcpdf.php';

    $pdf = new TCPDF ( PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false );


    $pdf->SetCreator ( PDF_CREATOR );
    $pdf->SetAuthor ( str_replace ( "http://", "", "http://" . $_SERVER ['HTTP_HOST'] ) );
    $pdf->SetTitle ( $data['title']  );
    $pdf->SetSubject ( $data['subject'] );
    $pdf->SetKeywords ( $data['keywords'] );

    
    $pdf->SetHeaderData ( PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH );

    
    $pdf->setHeaderFont ( Array (
        PDF_FONT_NAME_MAIN,
        '',
        PDF_FONT_SIZE_MAIN
    ) );
    $pdf->setFooterFont ( Array (
        PDF_FONT_NAME_DATA,
        '',
        PDF_FONT_SIZE_DATA
    ) );


    $pdf->SetDefaultMonospacedFont ( PDF_FONT_MONOSPACED );

    
    $pdf->SetMargins ( PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT );
    $pdf->SetHeaderMargin ( PDF_MARGIN_HEADER );
    $pdf->SetFooterMargin ( PDF_MARGIN_FOOTER );

    
    $pdf->SetAutoPageBreak ( TRUE, PDF_MARGIN_BOTTOM );

    
    $pdf->setImageScale ( PDF_IMAGE_SCALE_RATIO );


    $pdf->setLanguageArray ( $l );
    
    $pdf->SetFont ( 'droidsansfallback', '', 20 );

    
    $pdf->AddPage ();

    $this->mypdf = $pdf;
    $this->mypdf->writeHTML ( $data['html'], true, false, true, false, '' );

    $posx = $this->mypdf->GetX ();
    $posy = $this->mypdf->GetY ();

    $posx = $posx + 40;
    if ($posy > 50)
        $posy = $posy - 50;

    $path = str_replace ( 'App/Lib/Tcpdf/', '', K_PATH_MAIN );
    
    $this->mypdf->Output ( $data['title'] . '.pdf', 'I' );

}

我并没有在 方法里 打印数据,为什么会提示这个啊
TCPDF ERROR: Some data has already been output, can't send PDF file

控制器继承的父类也没有什么问题啊,请问还有什么可能的原因啊


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...