0

I have been using codeigniter framework. It was going very with everything except that I can't read my pdf files. When I do try reading, It downloads or saves it instead. I have tried a lot of solutions but didn't work.

Controller

public function read($name)
{

    $url = base_url().'uploads/'.$name;
    header('Content-type: application/pdf');
    header('Content-Disposition: inline; filename="'.$name.'"');
    header('Content-Transfer-Encoding: binary');
    header('Accept-Ranges: bytes');
     @readfile($url);

}
Sagar Gautam
  • 9,049
  • 6
  • 53
  • 84
courage
  • 115
  • 3
  • 20

2 Answers2

1

How can you read a pdf file? If by read you mean to read characters in the pdf file then you need an OCR library to do the same. You can find different libraries like:

http://www.fpdf.org/

informer
  • 821
  • 6
  • 18
0

checkout: How to force files to open in browser instead of download (pdf)?

also if this doesn't help you try using a library like mpdf or dompdf they have good documentation on how to export files to browser or to save it etc

https://github.com/mpdf/mpdf

Parker Dell
  • 472
  • 4
  • 11