简体   繁体   English

我如何在第一页和第二页后的tcpdf中生成新页面

[英]How can i generate fresh page in tcpdf after the first one and half page

My question is, For example, there are two chapters . 我的问题是,例如,有两章。 The first chapter has one and half page of data in pdf format. 第一章有一页半的pdf格式的数据。 When the second chapter starts, it should not start from previous chapters half page, it should get start in next fresh page. 第二章开始时,不应从上一章的半页开始,而应从下一页重新开始。 These two chapters in while loop. while循环中的这两章。 I used the below syntax. 我使用了以下语法。 Please any one advice me. 请任何人给我建议。 I am trying since 2 days. 我从2天开始尝试。 Please help me out. 请帮帮我。 I am in starting stage. 我处于起步阶段。 I am learning tcpdf. 我正在学习tcpdf。

//here is the edited code //这是编辑后的代码

 while($example = mysqli_fetch_array($sql))
 {
        //contains some code


        $sql_chapter    =   mysqli_query($dbconn,"SELECT column1, column2, column3 FROM CHAPTER_DETAILS WHERE FORM_NAME='".$example['chapter']."' ");
        while($row_chapter=mysqli_fetch_array($sql_chapter))
        {
           $output  =   $row_chapter['column1']     ;
           $output1 =   fnFetchData($row_chapter['column2'],$row_chapter['column3'])     ;

           $pdf->MultiCell(200, 70, $output, 0, 'L', 0, 0, false);
           $pdf->MultiCell(250, 70, $output1, 0, 'L', 0, 0, false);
        }

        $pdf->AddPage() ;
 }

    $pdf->lastPage();
    $pdf->Output('test.pdf', 'I');

You should add a new page with AddPage 您应该使用AddPage添加一个新页面

$pdf->AddPage();

// Reset pointer to the last page
$pdf->lastPage();

// Close and output PDF document
$pdf->Output('test.pdf', 'I');

It should work fine 应该很好

EDIT 编辑

while($example = mysqli_fetch_array($sql))
 {
    $pdf->startPage() ; // you can also use AddPage();


    $sql_chapter    =   mysqli_query($dbconn,"SELECT column1, column2, column3 FROM CHAPTER_DETAILS WHERE FORM_NAME='".$example['chapter']."' ");
    while($row_chapter=mysqli_fetch_array($sql_chapter))
    {
       $output  =   $row_chapter['column1']     ;
       $output1 =   fnFetchData($row_chapter['column2'],$row_chapter['column3'])     ;

       $pdf->MultiCell(200, 70, $output, 0, 'L', 0, 0, false);
       $pdf->MultiCell(250, 70, $output1, 0, 'L', 0, 0, false);
    }
    $pdf->endPage() ; // only if you use startPage();
 }
$pdf->Output('test.pdf', 'I');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM