Why wont the header() parse the pdf? It shows up as encripted with weird characters. If $type = 1, it is a pdf and i have to parse it with a PDF header, else if it is $type = 2 do something else.

My issue is with this header, does it have to appear on the first line on the page? how can i have a script switch out header() types for different types of content?

Code PHP:
$type = $_GET['type']; 
if ( $_SESSION['valid_user'] ) 	{ 
	if ($type == "1"){
	$fileName = "pdf/filename.pdf";	
	header("Content-type: application/pdf");  
	} else if ($type == "2"){
} else { 
echo "You do not have permision to view this page";