title: using header() to rewrite filename in URL for dynamic pdf
body: <p>I have a php script that generates a pdf report. When we go to save the pdf document, the filename that Acrobat suggests is report_pdf, since the php script is named report_pdf.php. I would like to dynamically name the pdf file, so I don't have to type the appropriate name for the report each time that I save it. </p>
  
  <p>Asking on a news group, someone suggested this, where <code>filename="July Report.pdf"</code> is the intended name of the report</p>
  
  <pre><code>&lt;?
  header('Content-Type: application/pdf');
  header('Content-disposition: filename="July Report.pdf"');
  </code></pre>
  
  <p>But it doesn't work. Am I doing it wrong, or will this work at all? Is this a job for mod_rewrite?</p>
  
  <p><HR>
  So I've tried both</p>
  
  <pre><code>header('Content-disposition: inline; filename="July Report.pdf"');
  </code></pre>
  
  <p>and</p>
  
  <pre><code>header('Content-disposition: attachment; filename="July Report.pdf"');
  </code></pre>
  
  <p>( not at the same time ) and neither work for me. Is this a problem with my web host? For this <a href="http://nerdcraft.net/pdf/report.php" rel="noreferrer">url</a>, here's my code:</p>
  
  <pre><code>&lt;?
  header('Content-disposition: inline; filename="July Report.pdf"');
  
  // requires the R&amp;OS pdf class
  require_once('class.ezpdf.php');
  require_once('class.pdf.php');
  
  // make a new pdf object
  $pdf = new Cpdf();
  // select the font
  $pdf-&gt;selectFont('./fonts/Helvetica');
  $pdf-&gt;addText(30,400,30,'Hello World');
  $pdf-&gt;stream();
  
  ?&gt;
  </code></pre>