I have a hexadecimal value that is a PDF that I am getting from a web service that I am trying to save locally using PHP. The below is a snippet of the value.
I have tried to achieve this using pack in PHP either receive an error that "x" is not valid or the pdf will not save correctly. It will be empty or says error opening.
Partial Value is: "0x255044462D312E340A0A322030206F626A0A3C3C2F5479"
I have tried the following unsuccessfully after searching google for some time:
$pack = pack("h*", $string);
file_put_contents('my.pdf', $pack);
header('Content-type: application/pdf');
header('Content-Disposition: attachment; filename="my.pdf"');
echo $pack;
Can anyone tell me what I am doing incorrectly? I realize this is not the entire PDF but I cant put entire online.
Thanks for any help
0xusingstr_replace.pack('h*',$string)it'spack('H*',$string), with uppercase.str_replace("0x", "", $string);:P