変数から変数へ変換する

  1. <?php
  2. require_once ('../code/cssj_driver.php');
  3. header("Content-Type: application/pdf");
  4.  
  5. /**
  6.  * 与えられたデータをPDFに変換して返します。
  7.  * 
  8.  * @param $session セッション
  9.  * @param $input 元のデータ
  10.  * @return 変換結果PDF 
  11.  */
  12. function &toPDF(&$session$input{
  13.   //出力先
  14.   $output '';//nullの場合標準出力となるので、必ず文字列を代入しておく必要がある
  15.   cssj_set_output($session$output);
  16.  
  17.   //変換
  18.   cssj_ob_start_main($session'file:/test.html');
  19.   echo $input;
  20.  
  21.   //セッションの終了
  22.   cssj_close($session);
  23.   
  24.   return $output;
  25. }
  26.  
  27.  
  28. //ドライバの作成
  29. $driver cssj_create_driver_for('localhost'8099);
  30.  
  31. //セッションの開始
  32. $session cssj_create_session($driver'user''kappa'or die('サーバーに接続できません');
  33.  
  34. //入力
  35. $input '
  36. <html>
  37.   <head>
  38.     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  39.     <title>Hello CSSJ</title>
  40.   </head>
  41.   <body>
  42.     <h2>ただいまの時刻</h2>
  43.     <p>'.date("l dS of F Y h:i:s A").'</p>
  44.   </body>
  45. </html>
  46. ';
  47.  
  48. //変換
  49. $output toPDF($session$input);
  50. echo $output;
  51.  
  52. ?>

Documentation generated on Wed, 10 Jun 2009 13:44:38 +0900 by phpDocumentor 1.4.1