getService(substr($arrService[0][0],11 ,strlen($arrService[0][0])-12))->getSource() ,$json); } } $json = str_replace('http://localhost/','http://'.$_SERVER["HTTP_HOST"].'/',$json); // Generate the PDF ob_start(); $objCurl = curl_init(); curl_setopt($objCurl, CURLOPT_URL, "http://localhost:9998/print-servlet-1.2-SNAPSHOT/pdf/create.json"); curl_setopt($objCurl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($objCurl, CURLOPT_POST, 1); curl_setopt($objCurl, CURLOPT_POSTFIELDS, $json); curl_setopt($objCurl, CURLOPT_HTTPHEADER, array('Content-Type: text/plain')); $res = curl_exec($objCurl); // Depending on service, either a simple string of the path is returned, like // http://localhost:9998/print-servlet-1.2-SNAPSHOT/pdf/7333684022721464475.pdf" // Or a JSON objet of the form // {"getURL":"http://localhost:9998/print-servlet-1.2-SNAPSHOT/pdf/7333684022721464475.pdf"} // This is what we test here $path = json_decode($res); if ($path == null || !isset($path->getURL)) $path = $res; else $path = $path->getURL; curl_close($objCurl); // Get the PDF file echo file_get_contents($path); header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Cache-Control: no-cache"); header("Pragma: no-cache"); header("Content-type: application/pdf"); header('Content-Disposition: inline; filename="pdfprint.pdf"'); ob_end_flush(); ?>