Я пытаюсь сделать PDF в raspberry-pi с использованием FPDF, но у меня есть эта ошибка ниже:
Я попытался обновить разрешение с помощью chmod, установив его на 755, Это мой код:
<?php
$curDate=date("m/d/y");
$pdfDate=date("mdy");
$aveTime='';
require('fpdf.php');
//Connect to your database
$conn=mysqli_connect("localhost","root","password","queuingsystem");
//Create new pdf file
$pdf=new FPDF('P','pt','Letter');
//Disable automatic page break
$pdf->SetAutoPageBreak(false);
//Add first page
$pdf->AddPage();
$pdf->SetFont('Arial','B',30);
$pdf->SetX(25);
$pdf->Cell(560,100,'ENLISTMENT',0,0,'C');
$pdf->Ln(72);
$pdf->SetFont('Arial','',15);
$pdf->SetX(25);
$pdf->Cell(140, 20, 'Date: '. $curDate ,0, 0, 'L');
//set initial y axis position per page
$y_axis_initial = 130;
//Set Row Height
$row_height = 20;
//print column titles
$pdf->SetFillColor(0, 255, 0);
$pdf->SetFont('Arial', 'B', 12);
$pdf->SetY($y_axis_initial);
$pdf->SetX(25);
$pdf->Cell(140, 20, 'Student ID', 1, 0, 'C', 1);
$pdf->Cell(140, 20, 'TimeIn', 1, 0, 'C', 1);
$pdf->Cell(140, 20, 'TimeOut', 1, 0, 'C', 1);
$pdf->Cell(140, 20, 'TimeSpent', 1, 0, 'C', 1);
$y_axis = $y_axis_initial + $row_height;
//Select the Products you want to show in your PDF file
$queryGet='select studID,TimeIn,TimeOut,TimeSpent from tbl_enlistmentlogs WHERE date=CURDATE() AND Status=2';
$result=mysqli_query($conn,$queryGet);
$rowCount=mysqli_num_rows($result);
//initialize counter
$i = 0;
//Set maximum rows per page
$max = 25;
if($rowCount==0){
$pdf->SetFont('Arial','B',30);
$pdf->SetX(25);
$pdf->Cell(560,100,'No Records found!',0,0,'C');
}
else{
while($row = mysqli_fetch_array($result))
{
//If the current row is the last one, create new page and print column title
if ($i == $max)
{
$pdf->AddPage();
//print column titles for the current page
$pdf->SetFillColor(0, 255, 0);
$pdf->SetFont('Arial', 'B', 12);
$pdf->SetY($y_axis_initial);
$pdf->SetX(25);
$pdf->Cell(140, 20, 'Student ID', 1, 0, 'C', 1);
$pdf->Cell(140, 20, 'TimeIn', 1, 0, 'C', 1);
$pdf->Cell(140, 20, 'TimeOut', 1, 0, 'C', 1);
$pdf->Cell(140, 20, 'TimeSpent', 1, 0, 'C', 1);
//Go to next row
$y_axis = $y_axis + $row_height;
//Set $i variable to 0 (first row)
$i = 0;
}
$StudentID = $row['studID'];
$TimeIn = $row['TimeIn'];
$TimeOut = $row['TimeOut'];
$TimeSpent = $row['TimeSpent'];
$pdf->SetFillColor(232, 232, 232);
$pdf->SetFont('Arial','', 12);
$pdf->SetY($y_axis);
$pdf->SetX(25);
$pdf->Cell(140, 20, $StudentID, 1, 0, 'C', 1);
$pdf->Cell(140, 20, $TimeIn, 1, 0, 'C', 1);
$pdf->Cell(140, 20, $TimeOut, 1, 0, 'C', 1);
$pdf->Cell(140, 20, $TimeSpent, 1, 0, 'C', 1);
//Go to next row
$y_axis = $y_axis + $row_height;
$i = $i + 1;
}
$queryAve='SELECT SEC_TO_TIME ( AVG ( TIMESTAMPDIFF ( SECOND, `TimeIn`,`TimeOut`))) FROM tbl_enlistmentlogs WHERE date=CURDATE() AND Status=2';
$ave=mysqli_query($conn,$queryAve);
$row = mysqli_fetch_array($ave);
$aveTime=$row[0];
$pdf->Ln(20);
$pdf->SetFillColor(255, 255, 0);
$pdf->SetFont('Arial','B', 12);
$pdf->SetX(25);
$pdf->Cell(420, 20, 'THE AVERAGE TIME SPENT BY STUDENT', 1, 0, 'C', 1);
$pdf->Cell(140, 20, $aveTime, 1, 0, 'C', 1);
}
mysqli_close($conn);
//Save file
$filee=$pdf->Output('EnlistmentReport'.$pdfDate.'.pdf','F');
$pdf->Output();
?>
Это ошибка, предоставленная error.log.
Неустранимая ошибка PHP: Uncaught Исключение: ошибка FPDF: некоторые данные уже были выведены, не удается отправить файл PDFв /var/www/html/fpdf.php:271\nStack trace: \ n # 0
/var/www/html/fpdf.php(1063): FPDF-> Error ('Некоторые данные имеют ... ') \ n # 1
/var/www/html/fpdf.php(999): FPDF -> _ checkoutput () \ n # 2
/var/www/html/testFpdf.php(116): FPDF-> Output () \ n # 3 {main} \ n
, добавляемый в /var/www/html/fpdf.php в строку 271
В Windows он будет просматривать PDF-файлфайл без ошибок.