在PDF上打印Textarea元素而不会溢出
Printing Textarea element on PDF without being overflow
我在 HTML 和 PHP 的帮助下生成 PDF。但是 textarea 中的文本溢出了。打印中的文本仅在一行中。 我的 HTML 密码是
<html>
<head>
<title>registration form</title>
</head>
<h2 ALIGN="CENTER">Registration form</h2>
<form action="pro1.php" method="post">
<table border="0" align="center">
<tbody>
<tr>
<td><label for="id">Id: </label></td>
<td><input id="id" maxlength="50" name="name" type="text" /></td>
</tr>
<tr>
<td><label for="name">Name: </label></td>
<td><input id="name" maxlength="50" name="name" type="text" /></td>
</tr>
<tr>
<td><label for="course">Course: </label></td>
<td><input id="course" maxlength="50" name="course" type="text" /></td>
</tr>
<tr>
<td><label for="branch">Branch: </label></td>
<td><input id="branch" maxlength="50" name="branch" type="text" /></td>
</tr>
<tr>
<td><label for="rolln0">Rollno: </label></td>
<td><input id="rollno" maxlength="50" name="rollno" type="text" /></td>
</tr>
<tr>
<td><label for="email">Email_Address:</label></td>
<td><input id="email" maxlength="50" name="email" type="text" /></td>
</tr>
<tr>
<td><label for="username">User_Name:</label></td>
<td><input id="username" maxlength="50" name="username" type="text" /></td>
</tr>
<tr>
<td><label for="aboutus">About Us:</label></td>
<td valign="middle" align="center"><textarea wrap="wrap" rows ="1" cols ="1" name = "aboutus"></textarea></td>
</tr>
<tr>
<td><label for="password">Password:</label></td>
<td><input id="password" maxlength="50" name="password"
type="password" /></td>
</tr>
<tr>
<td align="right"><input name="Submit" type="Submit" value="Add" /></td>
</tr>
</tbody>
</table>
</form>
</html>
我的 PHP 代码是
require('fpdf/fpdf.php');
$pdf = new FPDF();
//var_dump(get_class_methods($pdf));
$pdf -> AddPage();
$pdf->SetFont("Arial","B",16);
$pdf->Cell(0,10,"Welcome {$pro_name}",1,1);
$pdf->Cell(50,10,"Name: ",1,0);
$pdf->Cell(50,10,$pro_name,1,1);
$pdf->Cell(50,10,"Branch: ",1,0);
$pdf->Cell(50,10,$pro_branch,1,1);
$pdf->Cell(50,10,"Roll No: ",1,0);
$pdf->Cell(50,10,$pro_rollno,1,1);
$pdf->Cell(50,10,"Email: ",1,0);
$pdf->Cell(50,10,$pro_email,1,1);
$pdf->Cell(50,10,"About Us: ",1,0);
$pdf->Cell(50,10,$pro_aboutus,1,1);
$pdf->output();
}
?>
请帮助我,告诉我应该怎么做才能使我的文本区域打印在 a4 内。提前致谢
使用 MultiCell 而不是 Cell。 正如它所说,“此方法允许打印带有换行符的文本。”
示例:
$this->MultiCell(60,5,$txt);