0

I have a service from angular.js that call directly to node.js and everything is fine, the pdf file is application/pdf.

when I added php as middle server I run this code :

$output = callToExport();
header('Content-type: application/pdf');
header("Cache-Control: no-cache");
header("Pragma: no-cache");
header("Content-Disposition: inline;filename=myfile.pdf'");
header("Content-length: ".strlen($output));
echo $output;

then in angularjs the result is a BLOB but the type is text/HTML

how can I fix that? I just need to get result from pdf service and returned it back

Tuz
  • 1,810
  • 5
  • 29
  • 58
  • Possible duplicate of [correct PHP headers for pdf file download](https://stackoverflow.com/questions/20080341/correct-php-headers-for-pdf-file-download) –  Jan 21 '19 at 10:23

1 Answers1

0

Maybe you forgot the Encode transfer ? Like that :

        $response->setStatusCode(200);
        $response->headers->set('Content-Transfer-Encoding', 'binary');
        $response->headers->set('Pragma', 'no-cache');
        $response->headers->set('Expires', '0');
Gustin Tang
  • 85
  • 1
  • 1
  • 12