I get a byte array from the WCF service, which generated a PDF file and converted it to a byte array. I need to get a byte array and use PHP or Javascript (or jQuery) to take this byte array and convert it back to a downloadable PDF file. I would prefer a solution in Javascript, but PHP will work just fine too.
The code I use to get the PDF:
<?php $userPDF = $_POST['username']; $passPDF = $_POST['password']; $idPDF = 'MO-N007175A'; //PDF Function $data = array("id" => $idPDF, "username" => $userPDF, "password" => $passPDF); $data_string = json_encode($data); $ch = curl_init('http://********.com/******/v1/DealPdf'); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); curl_setopt($ch, CURLOPT_VERBOSE, 1 ); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); $result = curl_exec($ch); var_dump($result); ?>
var_dump($result); -
string(1053285) "[37,80,68,70,45,49,46,54,10,37,211,244,204,225, ...
The array has been going on for some time ... therefore I have provided a small part, for example, for purposes.
Where can I start getting pdf from this array?
EDIT To clarify, the WCF service returns the actual PDF file in a byte array only. I need to save this byte array as PDF on the client machine. I used fwrite, etc., but I have to miss something, because I do not see it working.
Also - if I use fwrite, where does it output the file? EDIT