Php – Flex problem in saving PDF at server


I am a new bee to flex.
What i am trying to do is to generate and save the layout design which nothing but canvas to a pdf format at the server. Currently i am able to display the pdf in browser (see the function below:) but cannot save the file at the server.

  private function continueToPdf():void{
            myPDF = new PDF(  Orientation.LANDSCAPE, Unit.MM, Size.A4 );
            myPDF.setDisplayMode ( Display.FULL_WIDTH ); 
   Method.REMOTE, "",Download.INLINE ,"drawing.pdf" );

where layout_cnv is a canvas.Also i am using AlivePDF.swc lbrary for this.
The php file at server is create.php

                 $method = $_GET['method'];
                 $name = $_GET['name'];

                 if ( isset ( $GLOBALS["HTTP_RAW_POST_DATA"] )) {

// get bytearray

// add headers for download dialog-box
header('Content-Type: application/pdf');
header('Content-Length: '.strlen($pdf));
header('Content-disposition:'.$method.'; filename="'.$name.'"');
echo $pdf;

     }  else echo 'An error occured.';


Can someone help me please.

Best Solution

I'm not familiar with the AlivePDF library, but the WebORB PDF Generator is excellent for this task (I'm not affiliated with The Midnight Coders or WebORB, just making a recommendation.)