変数から変数へ変換する


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 cssj_ob_end_flush_main();
21
22 //セッションの終了
23 cssj_close($session);
24
25 return $output;
26 }
27
28
29 //ドライバの作成
30 $driver = cssj_create_driver_for('localhost', 8099);
31
32 //セッションの開始
33 $session = cssj_create_session($driver, 'user', 'secret') or die('サーバーに接続できません');
34
35 //入力
36 $input = '
37 <html>
38 <head>
39 <meta http-equiv="Content-Type" content="text/html; charset=EUC-JP">
40 <title>Hello CSSJ</title>
41 </head>
42 <body>
43 <h2>ただいまの時刻</h2>
44 <p>'.date("l dS of F Y h:i:s A").'</p>
45 </body>
46 </html>
47 ';
48
49 //変換
50 $output = toPDF($session, $input);
51 echo $output;
52
53 ?>

Documentation generated on Mon, 7 Nov 2005 19:21:26 +0900 by phpDocumentor 1.2.3