"test.pdf", "input" => $list_rpt ); $jsonData = json_encode($merge_input); $jsonDebug = json_encode($merge_input, JSON_PRETTY_PRINT); echo '
' . htmlspecialchars($jsonDebug) . '
'; exit; // Initialize cURL session $target_pdf = "https://" . $_SERVER['SERVER_NAME'] . "/one-api/tools/merge_pdf/merge"; $response = $this->post($target_pdf, $jsonData); $output_file_name = "test_kwitansi.pdf"; header("Content-type: application/pdf"); header( 'Content-Disposition: inline; filename="' . $output_file_name .'"' ); echo ($response); } catch (Exception $exc) { $message = $exc->getMessage(); $this->sys_error($message); } } function post($url, $data) { $ch = curl_init($url); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); //curl_setopt($ch, CURLOPT_VERBOSE, true); curl_setopt( $ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Content-Length: ' . strlen($data) ) ); $result = curl_exec($ch); return $result; } }