Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/291.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php FPDF多单元文本换行_Php_Fpdf - Fatal编程技术网

Php FPDF多单元文本换行

Php FPDF多单元文本换行,php,fpdf,Php,Fpdf,你好,善良的先生,请你帮我解决我的问题。请给我写一篇论文。我想在我的单元格中使用多单元格包装文本。我试着看视频,在这里寻找同样的问题,但我无法解决。请帮我理解怎么做。这将是非常有益的,如果你给我的例子,或是有一个更好的pdf生成器 这是我的密码 <?php require('fpdf181/fpdf.php'); $conn = mysqli_connect("localhost", "root", "", "srdatabase"); class PDF extends FPDF

你好,善良的先生,请你帮我解决我的问题。请给我写一篇论文。我想在我的单元格中使用多单元格包装文本。我试着看视频,在这里寻找同样的问题,但我无法解决。请帮我理解怎么做。这将是非常有益的,如果你给我的例子,或是有一个更好的pdf生成器

这是我的密码

<?php
require('fpdf181/fpdf.php');
$conn = mysqli_connect("localhost", "root", "", "srdatabase");  

class PDF extends FPDF
{
    function Header()
    {
        $this->SetFont('Arial','B',12);
        $this->Cell(100, 10, 'Reports', 0,1);
        $this->Ln(5);
        $this->SetFont('Arial','B',7);
        $this->SetFillColor(180, 180, 255);
        $this->SetDrawColor(50,50,100);
        $this->Cell(26,10,'Full Name',1,0,'',true);
        $this->Cell(25,10,'Specialization',1,0,'',true);
        $this->Cell(190,10,'Description',1,0,'',true);
        $this->Cell(22,10,'Reserved Count',1,0,'',true);
        $this->Cell(18,10,'Date Added',1,1,'',true);
    }
}

$pdf = new PDF('P','mm', 'A4');
$pdf->AliasNbPages('{pages}');
$pdf->SetAutoPageBreak(true,15);
$pdf->AddPage('L','A4',0);
$pdf->setFont('Arial','',7);
$pdf->setDrawColor(50,50,100);

if(empty($_POST["from_date"]) && empty($_POST["to_date"])&& isset($_POST["search_text"])) 
{
    $search = mysqli_real_escape_string($conn, $_POST["search_text"]);

    $query = mysqli_query($conn, "
    SELECT * FROM speakers 
    WHERE speaker_fullname LIKE '%".$search."%'
    OR speaker_image LIKE '%".$search."%' 
    OR speaker_specialization LIKE '%".$search."%' 
    OR speaker_description LIKE '%".$search."%' 
    OR speaker_paymentcost LIKE '%".$search."%'
    OR speaker_reservedcount LIKE '%".$search."%' 
    OR date_added LIKE '%".$search."%' 
    ORDER BY date_added DESC"); 

    while($data=mysqli_fetch_array($query))
    {
        $pdf->Cell(26,10,$data['speaker_fullname'],1,0);
        $pdf->Cell(25,10,$data['speaker_specialization'],1,0);
        $pdf->Cell(190,10,$data['speaker_description'],1,0);
        $pdf->Cell(22,10,$data['speaker_reservedcount'],1,0);
        $pdf->Cell(18,10,$data['date_added'],1,1);
    }
}

看起来您可能希望
$data['speaker\u description']
在过长时进行包装。无论如何,如果不是这样,您可以对所有列执行此操作


您可以使用FPDFs
GetStringWidth()
查看它是否会大于您建议的宽度,并在每列上使用
MultiCell()
,而不是
Cell()
。另外,请注意,如果您没有指定
$pdf->SetAutoPageBreak(false),您需要这样做(当您到达底部时添加页面),并确保在添加新页面之前,的最后一个单元格不会溢出到下面的页面中。

您没有使用MultiCell,因此我不知道您期望的是什么。我试着让它成为多小区,但它把它下面的一行搞砸了。所以,如果你给我一个例子,这将是非常有帮助的,你将基本上取代你所有的手机通话与多小区