printing out a pdf file

Hello,

i have created a pdf file and placed it in the view folder of the controller,

now when i tried to output it to the brower i get a popup error

“file does not begin with ‘%PDF-’”

in the controllers action method

i have this




        $this->renderPartial('index'); 

   

in the index view file




     $pdfFile="myPDF.pdf";


$filename = 'TIME_TABLE.pdf';


header('Content-type: application/pdf');

header('Content-Disposition: inline; filename="' . $filename . '"');

header('Content-Transfer-Encoding: binary');

header('Content-Length: ' . strlen($pdfFile));

header('Accept-Ranges: bytes');





//output the document

print($pdfFile); 

   

anyone with ideas ????

Oooooooop ! On one with ideas????

You’re not even dealing directly with the file. You’re quite literally just printing out ‘myPDF.pdf’, which of course isn’t going to render properly as a pdf file. You’re going to have to open the file and output its contents.

Why don’t you just link to the file, or if you want to be able to view the pdf inline utilise something like Google Docs?

I had exactly the same requirement.

How I did it:


header('Content-Type: application/pdf');

readfile($file); 

How about these code:

public void PdfProcessorPrint();

{

PDFInputFile = (@"C:/1.pdf");

Printer = (@"C:/HP Color LaserJet 5550 PCL 6");

};

PDF. PdfProcessorPrint(@"C:/1.pdf", @"C:/HP Color LaserJet 5550 PCL 6");