Cannot load a PDF file for inline viewing

Permalink
I have a script that dynamically generates a PDF file. My intent is to have the user view the file inline. The file is contained in the variable temp and I use the following header constructs:

$temp = $pdf->generate();
header('Content-Length: ' . strlen($temp));
header("Content-type: application/pdf");
header("Content-Disposition: inline; filename=Greater Bend Rotary Roster.pdf");

print $temp;

I get an error that the file cannot be loaded. For debugging I wrote the data to a file and it is a correct PDF file.

Many thanks...

Todd

rtcary