When echoing out file_get_contents on an uploaded pdf file, I get a load of nonsense displayed like so:
6}ÕìúÖ
Is there anyway of decoding this infomation?
When echoing out file_get_contents on an uploaded pdf file, I get a load of nonsense displayed like so:
6}ÕìúÖ
Is there anyway of decoding this infomation?
this Code maybe help you
<?php
$file = 'path/to/PDF/file.pdf';
$filename = 'filename.pdf';
header('Content-type: application/pdf');
header('Content-Disposition: inline; filename="' . $filename . '"');
header('Content-Transfer-Encoding: binary');
header('Accept-Ranges: bytes');
@readfile($file);
?>
be successfull
If you want to read/alter the contents of the pdf file you have to use a library like FPDF
If you want to show the pdf you have to set the correct content type:
header('Content-type: application/pdf');
header('Content-Disposition: inline;');
echo file_get_contents('yourpdf.pdf');
(readfile is a better option though)
Try this: http://www.fpdf.org/
It's a library that has also been suggested in other questions identical to this.