I need to convert Pdf file to byte array conversion in php. I am looking for like this result.
This result have byte conversation of Pdf file.
What id did:
$file = file_get_contents("pdf.pdf");
$fileData = base64_encode($file);
echo $fileData;
It does not works for me. how to convert PDf file to byte array?
This will get you the whole file into a string:
$fileContents = file_get_contents($file);
If you want an array of one-character strings, you can do this:
$byteArray = str_split($fileContents);
If you want an array of integer ASCII values, you can do this:
$byteArray = unpack('C*', $fileContents);