Я использую FPDF
, чтобы сохранить PDF с помощью преобразования текста.
Я использую следующий код:
<?php
require('fpdf.php');
class PDF extends FPDF
{
function ChapterBody($file)
{
// Read text file
$txt = file_get_contents($file);
$txt = str_replace("{{id_no}}","002",$txt);
// Times 12
$this->SetFont('Times','',12);
// Output justified text
$this->MultiCell(0,5,$txt);
// Line break
$this->Ln();
// Mention in italics
$this->SetFont('','I');
//$this->Cell(0,5,'(end of excerpt)');
}
function PrintChapter($num, $title, $file)
{
$this->AddPage();
// $this->ChapterTitle($num,$title);
$this->ChapterBody($file);
}
}
for($i=0;$i<3;$i++)
{
$pdf = new PDF();
$pdf->PrintChapter('','A RUNAWAY REEF','test.txt');
$pdf->Output('test'.$i.'.pdf','D');
}
?>
Я использовал for loop
для загрузки файла pdf 3 раза, но когда я выполняю этот код, он загружается только один раз с именем файла test0.pdf, почему test1.pdf and test2.pdf
id не загружается с использованием этого кода?