title: Hexadecimal to String PDF
body: <p>I have a hexadecimal value that I need to convert back to a pdf and save it. I have tried to convert to string and display but browser keeps failing to load the pdf. I am retrieving the pdf from a web service and I know the hex is valid.</p>
  
  <p>Below is the function I am using to convert and then to display:</p>
  
  <pre><code>header("Content-type: application/pdf");
  header('Content-Disposition: inline; filename="test.pdf"');
  
  function hex2str($func_string) {
  $func_retVal = '';
  $func_length = strlen($func_string);
  for($func_index = 0; $func_index &lt; $func_length; ++$func_index) $func_retVal .=    chr(hexdec($func_string{$func_index} . $func_string{++$func_index}));
  
  return $func_retVal;
  }
  
  $hex = hex2str($string);
  
  echo $hex;
  </code></pre>
  
  <p>Any help is greatly appreciated. </p>