PHPでFPDFライブラリを使用してPDFを生成しています。 PDFを生成し、私の次のコードを考えてみてください:PHPのFPDFライブラリでの書式設定
Student Details
Username: abc123
Name: John
Parent Details
Name: Mathew
Occupation: Businessman
しかし、私はこのような出力を必要とする:
<?php
require("fpdf181/fpdf.php");
class PDF extends FPDF
{
//Page header
function Header()
{
}
//Page footer
function Footer()
{
}
}
$pdf = new PDF('P', 'mm', 'A4');
$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->SetFont('Arial','U',14);
$pdf->MultiCell(90, 8, "Student Details", 0, 'L');
$pdf->SetFont('Arial','B',12);
$pdf->Cell(32, 8, "Username: ");
$pdf->SetFont('Arial','',12);
$pdf->Cell(10, 8, 'abc123', 0, 1);
$pdf->SetFont('Arial','B',12);
$pdf->Cell(32, 8, "Name: ");
$pdf->SetFont('Arial','',12);
$pdf->Cell(10, 8, 'John', 0, 1);
$pdf->SetFont('Arial','U',14);
$pdf->MultiCell(90, 8, "Parent Details", 0, 'L');
$pdf->SetFont('Arial','B',12);
$pdf->Cell(32, 8, "Name: ");
$pdf->SetFont('Arial','',12);
$pdf->Cell(10, 8, 'Mathew', 0, 1);
$pdf->SetFont('Arial','B',12);
$pdf->Cell(32, 8, "Occupation: ");
$pdf->SetFont('Arial','',12);
$pdf->Cell(10, 8, 'Businessman', 0, 1);
$pdf->Output();
?>
は、今ではこのようになりますPDFを生成
Student Details Parent Details
Username: abc123 Name: Mathew
Name: John Occupation: Businessman
どのような変更この種の書式設定を行うために私のコードで行うべきですか?
これは簡単な方法です。私は、PDFの読み込みを遅らせる複雑なテーブルを作成するのではなく、同じことをやっています。提案していただきありがとうございます。 –