dolibarrApiService->downloadBillingDocPdf( $uriVariables['dolibarrDocType'], $uriVariables['ref'] ); // Build the response and attach the file to it // @see https://symfony.com/doc/current/components/http_foundation.html#serving-files $response = new Response(base64_decode($data['content'])); $response->headers->set('Charset', 'UTF-8'); $response->headers->set('Access-Control-Expose-Headers', 'Content-Disposition'); $response->headers->set('Content-Type',$data['content-type']); $response->headers->set( 'Content-Disposition', HeaderUtils::makeDisposition(HeaderUtils::DISPOSITION_ATTACHMENT, $data['filename']) ); return $response; } }