Anonymous
Пустой выход PDF с использованием библиотеки FPDF - codeigniter
Сообщение
Anonymous » 07 июн 2025, 14:03
Я собираюсь генерировать отчет PDF с использованием библиотеки FPDF, но вывод пуст. Ошибка не отображается, как я могу решить эту проблему? < /p>
В любом случае, я попробовал этот код в Localhost, и он работает отлично, но когда я загружаю его в облако, вывод не отображается .. Я пытался сделать функцию выходить такой же .. < /p>
Код: Выделить всё
$this->fpdf->OUTPUT('try.pdf','I'); but nothing happens..
< /code>
Примечание: в моем выходе, c: /backup /incompee _ .. php, выход в папке, ошибка нет, и она работает нормально .. Но когда я загружаю этот, нет вывода, чтобы отобразить < /p>
это мой контроллер: < /p>
< /p>
< /p>
public function backup_employees_pdf()
{
$this->load->library('fpdf');
define('FPDF_FONTPATH',$this->config->item('fonts_path'));
$this->fpdf =new FPDF('L', 'mm', 'Legal', true, 'UTF-8', false);
$this->fpdf->AliasNbPages();
$this->fpdf->AddPage();
//load data
$data = array();
$row = $this->m_employee->load_data_employees();
$data = $row->result();
// Whatever written here will come in header of the pdf file.
$this->fpdf->Image('assets/images1/mpowerstafflogo.jpg',10,5,50,50,'','www.mpowerstaff.com');
$this->fpdf->SetFont('Arial','B',15);
$this->fpdf->Cell(140);
$this->fpdf->Cell(50,10,'Employee File Management Website',0,0,'C');
$this->fpdf->Ln(5);
$this->fpdf->Cell(140);
$this->fpdf->Ln(5);
$this->fpdf->SetFont('Arial','',12);
$this->fpdf->Cell(140);
$this->fpdf->Cell(50,10,'3F Room 305 Jackson Bldg. 926 Arnaiz Ave., San Loreno Village Makati City, 1223 PHILIPPINES',0,0,'C');
$this->fpdf->Ln(5);
$this->fpdf->Ln(5);
$this->fpdf->Cell(140);
$this->fpdf->Cell(50,10,'Tel. (632) 810-4026 * 810-9121',0,0,'C');
$this->fpdf->Ln(5);
$this->fpdf->Ln(5);
$this->fpdf->Cell(140);
$this->fpdf->Cell(50,10,'Email: mpowerstaff@yahoo.com',0,0,'C');
$this->fpdf->Ln(10);
$this->fpdf->SetFont('Arial','B',12);
$this->fpdf->Cell(140);
$this->fpdf->Cell(50,10,'Employees Report',0,0,'C');
$this->fpdf->Ln(15);
// Colors, line width and bold font
$this->fpdf->SetFillColor(105,100,231);
$this->fpdf->SetTextColor(255);
$this->fpdf->SetDrawColor(60,89,117);
$this->fpdf->SetLineWidth(0.3);
$this->fpdf->SetFont('', 'B');
// Header
$w = array(35,80,40,40,40,40,61);
$this->fpdf->Ln();
//border LRTB
$this->fpdf->Cell(5);
$this->fpdf->Cell(90,10,'NAME',1,0,'C', 'LR');
$this->fpdf->Cell(60,10,'ACCOUNT NUMBER',1,0,'C', 'LR');
$this->fpdf->Cell(60,10,'ADDRESS',1,0,'C', 'LR');
$this->fpdf->Cell(60,10,'BIRTHDAY',1,0,'C', 'LR');
$this->fpdf->Cell(60,10,'CONTACT NO.',1,0,'C', 'LR');
$this->fpdf->Ln(10);
// Color and font restoration
$this->fpdf->SetFillColor(224, 235, 255);
$this->fpdf->SetTextColor(0);
$this->fpdf->SetFont('');
$fill = 0;
//data
foreach($data as $empsItem)
{
$this->fpdf->Cell(5);
$this->fpdf->Cell(90,10,$empsItem->name,1,0,'C',$fill);
$this->fpdf->Cell(60,10,$empsItem->account_no,1,0,'C',$fill);
$this->fpdf->Cell(60,10,$empsItem->address,1,0,'C',$fill);
$this->fpdf->Cell(60,10,$empsItem->birthday,1,0,'C',$fill);
$this->fpdf->Cell(60,10,$empsItem->contact_no,1,0,'C',$fill);
$this->fpdf->Ln(10);
$fill=!$fill;
}
$this->fpdf->Ln(30);
$this->fpdf->SetFont('Arial','B',10);
$this->fpdf->Cell(20, 5,'Total Employees: '.$row->num_rows(), '', 0, 'LR', 0);
$this->fpdf->SetY(184);
$this->fpdf->SetFont('Arial','I',8);
$this->fpdf->Cell(0,10,'Copyright. All Rights Reserved',0,0,'C');
$this->fpdf->Cell(0,10,'Page '.$this->fpdf->PageNo().' of {nb}',0,0,'C');
$dir = 'C:/backup/';
$filename = "employee report";
$this->fpdf->Output($dir.$filename.'.pdf');
}
// ==== Это моя модель === //
Код: Выделить всё
public function load_data_employees()
{
$query = $this->db->query("SELECT concat(e_first_name,' ',e_middle_name,' ',e_last_name) AS 'name',account_number AS 'account_no',address AS 'address',birthday AS 'birthday',contact_number AS 'contact_no'FROM tb_emp where status='available'");
return $query;
}
// == config.php == //
$config['fonts_path']= "./system/fonts/font/";
< /code>
Это детали. Я попытался исправить это, но все же нет вывода.
Подробнее здесь:
https://stackoverflow.com/questions/125 ... odeigniter
1749294210
Anonymous
Я собираюсь генерировать отчет PDF с использованием библиотеки FPDF, но вывод пуст. Ошибка не отображается, как я могу решить эту проблему? < /p> В любом случае, я попробовал этот код в Localhost, и он работает отлично, но когда я загружаю его в облако, вывод не отображается .. Я пытался сделать функцию выходить такой же .. < /p> [code]$this->fpdf->OUTPUT('try.pdf','I'); but nothing happens.. < /code> Примечание: в моем выходе, c: /backup /incompee _ .. php, выход в папке, ошибка нет, и она работает нормально .. Но когда я загружаю этот, нет вывода, чтобы отобразить < /p> это мой контроллер: < /p> < /p> < /p> public function backup_employees_pdf() { $this->load->library('fpdf'); define('FPDF_FONTPATH',$this->config->item('fonts_path')); $this->fpdf =new FPDF('L', 'mm', 'Legal', true, 'UTF-8', false); $this->fpdf->AliasNbPages(); $this->fpdf->AddPage(); //load data $data = array(); $row = $this->m_employee->load_data_employees(); $data = $row->result(); // Whatever written here will come in header of the pdf file. $this->fpdf->Image('assets/images1/mpowerstafflogo.jpg',10,5,50,50,'','www.mpowerstaff.com'); $this->fpdf->SetFont('Arial','B',15); $this->fpdf->Cell(140); $this->fpdf->Cell(50,10,'Employee File Management Website',0,0,'C'); $this->fpdf->Ln(5); $this->fpdf->Cell(140); $this->fpdf->Ln(5); $this->fpdf->SetFont('Arial','',12); $this->fpdf->Cell(140); $this->fpdf->Cell(50,10,'3F Room 305 Jackson Bldg. 926 Arnaiz Ave., San Loreno Village Makati City, 1223 PHILIPPINES',0,0,'C'); $this->fpdf->Ln(5); $this->fpdf->Ln(5); $this->fpdf->Cell(140); $this->fpdf->Cell(50,10,'Tel. (632) 810-4026 * 810-9121',0,0,'C'); $this->fpdf->Ln(5); $this->fpdf->Ln(5); $this->fpdf->Cell(140); $this->fpdf->Cell(50,10,'Email: mpowerstaff@yahoo.com',0,0,'C'); $this->fpdf->Ln(10); $this->fpdf->SetFont('Arial','B',12); $this->fpdf->Cell(140); $this->fpdf->Cell(50,10,'Employees Report',0,0,'C'); $this->fpdf->Ln(15); // Colors, line width and bold font $this->fpdf->SetFillColor(105,100,231); $this->fpdf->SetTextColor(255); $this->fpdf->SetDrawColor(60,89,117); $this->fpdf->SetLineWidth(0.3); $this->fpdf->SetFont('', 'B'); // Header $w = array(35,80,40,40,40,40,61); $this->fpdf->Ln(); //border LRTB $this->fpdf->Cell(5); $this->fpdf->Cell(90,10,'NAME',1,0,'C', 'LR'); $this->fpdf->Cell(60,10,'ACCOUNT NUMBER',1,0,'C', 'LR'); $this->fpdf->Cell(60,10,'ADDRESS',1,0,'C', 'LR'); $this->fpdf->Cell(60,10,'BIRTHDAY',1,0,'C', 'LR'); $this->fpdf->Cell(60,10,'CONTACT NO.',1,0,'C', 'LR'); $this->fpdf->Ln(10); // Color and font restoration $this->fpdf->SetFillColor(224, 235, 255); $this->fpdf->SetTextColor(0); $this->fpdf->SetFont(''); $fill = 0; //data foreach($data as $empsItem) { $this->fpdf->Cell(5); $this->fpdf->Cell(90,10,$empsItem->name,1,0,'C',$fill); $this->fpdf->Cell(60,10,$empsItem->account_no,1,0,'C',$fill); $this->fpdf->Cell(60,10,$empsItem->address,1,0,'C',$fill); $this->fpdf->Cell(60,10,$empsItem->birthday,1,0,'C',$fill); $this->fpdf->Cell(60,10,$empsItem->contact_no,1,0,'C',$fill); $this->fpdf->Ln(10); $fill=!$fill; } $this->fpdf->Ln(30); $this->fpdf->SetFont('Arial','B',10); $this->fpdf->Cell(20, 5,'Total Employees: '.$row->num_rows(), '', 0, 'LR', 0); $this->fpdf->SetY(184); $this->fpdf->SetFont('Arial','I',8); $this->fpdf->Cell(0,10,'Copyright. All Rights Reserved',0,0,'C'); $this->fpdf->Cell(0,10,'Page '.$this->fpdf->PageNo().' of {nb}',0,0,'C'); $dir = 'C:/backup/'; $filename = "employee report"; $this->fpdf->Output($dir.$filename.'.pdf'); } [/code] // ==== Это моя модель === // [code]public function load_data_employees() { $query = $this->db->query("SELECT concat(e_first_name,' ',e_middle_name,' ',e_last_name) AS 'name',account_number AS 'account_no',address AS 'address',birthday AS 'birthday',contact_number AS 'contact_no'FROM tb_emp where status='available'"); return $query; } [/code] // == config.php == // $config['fonts_path']= "./system/fonts/font/"; < /code> Это детали. Я попытался исправить это, но все же нет вывода. Подробнее здесь: [url]https://stackoverflow.com/questions/12599192/blank-output-pdf-using-fpdf-library-codeigniter[/url]