%PDF
indicates the content of the pdf file because this is the start of the pdf header. You probably need to tell the client that pdf content is coming and not text.
Try something like this:
header('Content-Type: application/pdf');
echo $result;
?>
Good luck!