Posted By

cburyta on 01/15/10


Tagged

header file buffer output serve obclean


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

jlan
kairog
tspitzr


Serve PDF file with PHP


 / Published in: PHP
 

Quick basic way to serve a string or a file through PHP

  1. // pdfString is the *contents* of a file.
  2. // to serve a file that exists on the file system, use readfile() instead of print $pdfString
  3.  
  4. header('Content-Description: File Transfer');
  5. header('Content-Type: application/pdf');
  6. header('Content-Length: ' . strlen($pdfString));
  7. header('Content-Disposition: attachment; filename=' . 'pdf_dynamic.pdf');
  8. print $pdfString;

Report this snippet  

You need to login to post a comment.