Sunucuda PDF tasarruf Flex sorun

2 Cevap php

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 ); 
			myPDF.addPage();
			myPDF.addImage(layout_cnv);
			myPDF.save( Method.REMOTE, "http://flexindia.org/designtool/upload/create.php",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

                   <?php
                 $method = $_GET['method'];
                 $name = $_GET['name'];

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

// get bytearray
$pdf = $GLOBALS["HTTP_RAW_POST_DATA"];

// 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.';

           ?>

Birisi bana lütfen yardımcı olabilir.

2 Cevap

Finally after few days I've discovered the solution for the aforesaid problem. Here for saving the file locally at server i just need to do some changes in the following function as:

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

Create.php aşağıdaki gibi tanımlanan sunucu betik Nerede:

     <?php

      $fp = fopen( 'upload/drawing.pdf', 'wb' );
       fwrite( $fp, $GLOBALS['HTTP_RAW_POST_DATA' ] );
       fclose( $fp ); 
       ?>

    cheers :-) !!!

Ben AlivePDF kütüphaneye aşina değilim, ama WebORB PDF Generator bu görev için mükemmel (ben sadece bir öneri yapma, Midnight Kodlayıcılarda veya WebORB bağlı değilim.)

http://www.themidnightcoders.com/products/pdf-generator/overview.html