Note that there are some explanatory texts on larger screens.

plurals
  1. POFPDF in Codeigniter give Network Error when it download
    primarykey
    data
    text
    <p>How to Generate FPDF file in codeigniter. I have tried below code it gives error.</p> <p>Controller function</p> <pre><code>public function pdf() { // Generate PDF by saying hello to the world $this-&gt;load-&gt;library('pdf'); // Load library $this-&gt;pdf-&gt;fontpath = 'font/'; // Specify font folder $this-&gt;pdf-&gt;AddPage(); $this-&gt;pdf-&gt;SetFont('Arial','B',16); $this-&gt;pdf-&gt;Cell(40,10,'Hello World!'); $this-&gt;pdf-&gt;Output(); } </code></pre> <p>I put pdf.php file in application/libraries folder</p> <p>pdf.php</p> <pre><code>&lt;?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); require('fpdf.php'); class Pdf extends FPDF { // Extend FPDF using this class // More at fpdf.org -&gt; Tutorials function __construct($orientation='P', $unit='mm', $size='A4') { // Call parent constructor parent::__construct($orientation,$unit,$size); } } ?&gt; </code></pre> <p>fpdf.php file available in same folder. When i use this code, I cannot able to download pdf file i gives me a Network Error or webpage not found</p> <p>This is my output() available in fpdf.php file</p> <pre><code>function Output($name='', $dest='') { // Output PDF to some destination if($this-&gt;state&lt;3) $this-&gt;Close(); $dest = strtoupper($dest); if($dest=='') { if($name=='') { $name = 'doc.pdf'; $dest = 'I'; } else $dest = 'F'; } switch($dest) { case 'I': // Send to standard output $this-&gt;_checkoutput(); if(PHP_SAPI!='cli') { // We send to a browser header('Content-Type: application/pdf'); header('Content-Disposition: inline; filename="'.$name.'"'); header('Cache-Control: private, max-age=0, must-revalidate'); header('Pragma: public'); } echo $this-&gt;buffer; break; case 'D': // Download file $this-&gt;_checkoutput(); header('Content-Type: application/x-download'); header('Content-Disposition: attachment; filename="'.$name.'"'); header('Cache-Control: private, max-age=0, must-revalidate'); header('Pragma: public'); echo $this-&gt;buffer; break; case 'F': // Save to local file $f = fopen($name,'wb'); if(!$f) $this-&gt;Error('Unable to create output file: '.$name); fwrite($f,$this-&gt;buffer,strlen($this-&gt;buffer)); fclose($f); break; case 'S': // Return as a string return $this-&gt;buffer; default: $this-&gt;Error('Incorrect output destination: '.$dest); } return ''; } </code></pre> <p>How to solve this problem.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload