Index: phpdoc/ja/functions/java.xml +++ phpdoc/ja/functions/java.xml Java PHP / Java の連携 PHPとJavaの連携をとして考えられる手段は2種類あります。JavaをPHPに統合 する手法、この手法はより安定で効率的な手法です、または、PHPをJavaサー ブレット環境に統合する手法です。前者は、ext/java で提供され、後者はサ ーブレットサーバとのインターフェイスであるSAPIモジュールです。 PHP 4 ext/java は、PHPからJavaオブジェクトのメソッドを生成し、コール する簡単で効率的な手段を提供します。このJVMはJNIを用いて作成され、全 てはこのプロセスで動作します。ext/javaの構築手順は、 php4/ext/java/README にあります。 Java の例 <?php // Java クラス java.lang.System のインスタンスをPHPに作成する $system = new Java("java.lang.System"); // プロパティへのアクセスのデモ print "Java version=".$system->getProperty("java.version")." <br>"; print "Java vendor=" .$system->getProperty("java.vendor")." <br>"; print "OS=".$system->getProperty("os.name")." ". $system->getProperty("os.version")." on ". $system->getProperty("os.arch")." <br>"; // java.util.Date の例 $formatter = new Java("java.text.SimpleDateFormat", "EEEE, MMMM dd, yyyy 'at' h:mm:ss a zzzz"); print $formatter->format(new Java("java.util.Date")); ?> AWT の例 <?php // この例は、CGIとして実行されることのみを考慮しています。 $frame = new Java("java.awt.Frame", "Zend"); $button = new Java("java.awt.Button", "Hello Java world!"); $frame->add("North", $button); $frame->validate(); $frame->pack(); $frame->visible = True; $thread = new Java("java.lang.Thread"); $thread->sleep(10000); $frame->dispose(); ?> 注意: new Java() は、有効なコンストラクタある場合、クラスのインスタンス を生成します。引数が指定されない場合には、デフォルトのコンストラ クタにより"java.lang.System"のようなクラスにアクセスするとよいで しょう。このクラスは、静的な手法でそのクラスの機能の多くを公開し ています。 あるインスタンスのメンバーにアクセスする際には、まずbeanプロパティ が探されてから、次にpublicフィールドが探されます。言い換えると、 "print $date.time" はまず "$date.getTime()" と解釈され、続いて "$date.time" と解釈されます。 静的メンバおよびインスタンスメンバは共に同じ構文でアクセス可能です。 さらに、javaオブジェクトが"java.lang.Class"型の場合、このクラスの静 的メンバ(フィールドとメソッド)にアクセス可能です。 例外が発生するとPHPの警告が出力され、結果はNULLとなります。警告は "@"記号を付けてメソッドをコールすることに抑圧できます。以下のAPI を直近のエラーを取得し、リセットするために使用することができます。 java_last_exception_get java_last_exception_clear オーバーロードの解決は、二つの言語の間で型の違いがあるため一般には 困難な問題です。PHP のJava拡張機能は簡単ですが最も一致するオーバー ロードを定義するかなり効率的な手段を使用しています。 加えて、PHPのメソッド名は大文字小文字を区別しないため、選択される オーバーロードの数は増加する傾向があります。 メソッドが一度選択されると、パラメータの値は必要に応じて調整されま す。このため、(倍精度実数が論理値に変換されるといった)データの劣化 が発生する可能性があります。 PHPでは伝統的に配列とハッシュテーブルは相互に完全に可換でした。PHPの ハッシュテーブルは整数または配列の添字のみを使用できることに注意して 下さい。また、Javaのprimitive型の配列は疎とすることができないことに も注意して下さい。これらの構造は値で渡されるため、メモリと時間の消 費量が大きくする可能性があります。 PHP4 sapi/servlet はPHPプロセッサ全体をサーブレットとして実行するために ext//javaにより定義された機構の上に構築されています。 この形態のPHPの側からこの実装が基本的に優れている点は、サーブレットを サポートするWebサーバが通常JVMをプールし、再利用することに注力している ことです。このサーブレットSAPIモジュールの構築手順は、php4/sapi/README にあります。 注意: このコードは、全てのサーブレットエンジンで実行可能であるように作成 されていますが、現在ApacheのJakarta/tomcatでしかテストされていませ ん。他のエンジンでこのコードを実行する際に必要なパッチ、バグレポー ト、成功事例等をお知らせ下さい。 PHP は、動作ディレクトリを変更する特徴があります。sapi/サーブレット はもとに戻そうとしますが、PHPが実行されている間、サーブレットエンジ ンはCLASSPATHい相対ディレクトリにより指定されている全てのクラスをロ ードできないか、管理用およびJSPコンパイル用に使用されている作業ディ レクトリを見つけることができなくなる可能性があります。 java_last_exception_clear 直近の例外をクリアする 説明 void java_last_exception_clear java_last_exception_get 直近のJava例外を取得する 説明 exception java_last_exception_get 以下の例は、Java例外ハンドラをPHPから使用する方法を示すものです。 Java例外ハンドラ pop(); $ex = java_last_exception_get(); if (!$ex) print "$result\n"; // 以下のコードは失敗します (エラー出力は、@により抑制されています) $result = @$stack->pop(); $ex = java_last_exception_get(); if ($ex) print $ex->toString(); // 直近の例外をクリア java_last_exception_clear(); ?> Index: phpdoc/ja/functions/printer.xml +++ phpdoc/ja/functions/printer.xml プリンタ関数 プリンタ 以下の関数は、Windows 9.x, ME, NT4, 2000でのみ利用可能です。これらの 関数は、PHP 4 (4.0.4)で追加されました。 printer_open プリンタへの接続をオープンする 説明 mixed printer_open [string devicename] この関数は、プリンタdevicenameへの接続を試み、成功時にハンドル、失敗時にfalseを返します。 パラメータが指定されない場合、この関数はデフォルトのプリンタへの接続をオープンします。(php.iniにprinter.default_printerとして指定されていない場合は、PHPはデフォルトのプリンタの検出を試みます) printer_open は、デバイスコンテキストも開始します。 <function>printer_open</function> の例 $handle = printer_open("HP Deskjet 930c"); $handle = printer_open(); printer_abort プリンタのスプールファイルを削除する 説明 void printer_abort resource handle この関数は、プリンタのスプールファイルを削除します。 handle には、プリンタへの有効なハンドルを指定する必要があります。 <function>printer_abort</function> の例 $handle = printer_open(); printer_abort($handle); printer_close($handle); printer_close プリンタへの接続を閉じる 説明 void printer_close resource handle この関数は、プリンタへの接続をクローズします。 printer_close は、アクティブなデバイスコンテキストへもクローズします。 handle は、プリンタへの有効なハンドルである必要があります。 <function>printer_close</function> の例 $handle = printer_open(); printer_close($handle); printer_write プリンタへデータを書き込む 説明 bool printer_write resource handle string content content を直接プリンタに書き込み、成功時にtrue、失敗した場合にfalseを返します。 handle は、プリンタへの有効なハンドルである必要があります。 <function>printer_write</function> の例 $handle = printer_open(); printer_write($handle, "Text to print"); printer_close($handle); printer_list サーバで付加されたプリンタの配列を返す 説明 array printer_list int enumtype [string name [int level]] この関数は、利用可能なプリンタとその機能を調べます。 levelには、情報要求のレベルを設定します。 これは、1,2,4 または 5とすることが可能です、enumtype は次の定義済みの定数のどれかとする必要があります。 PRINTER_ENUM_LOCAL: ローカルにインストールされたプリンタを数えます。 PRINTER_ENUM_NAME: nameのサーバ、ドメインまたはプリントプロバイダになることができるものを数えます。 PRINTER_ENUM_SHARED: このパラメータは単独では使用できず、他のパラメータ、共有プリンタを検出するためのPRINTER_ENUM_LOCAL、とともに使用する必要があります。 PRINTER_ENUM_DEFAULT: (Win9.x のみ) デフォルトのプリンタを数えます。 PRINTER_ENUM_CONNECTIONS: (WinNT/2000 のみ) ユーザが接続済みのプリンタを数えます。 PRINTER_ENUM_NETWORK: (WinNT/2000 のみ) コンピュータのドメインにあるネットワークプリンタを数えます。 level が 1の場合のみ有効です。 PRINTER_ENUM_REMOTE: (WinNT/2000 のみ) コンピュータのドメインにあるネットワークプリンタとプリンタサーバを数えます。 level が 1の場合のみ有効です。 <function>printer_list</function> の例 /* ローカルな共有プリンタを検出 */ var_dump( printer_list(PRINTER_ENUM_LOCAL | PRINTER_ENUM_SHARED) ); printer_set_option プリンタの接続を設定する 説明 bool printer_set_option resource handle int option mixed value The function sets the following options for the current connection: handle must be a valid handle to a printer. For option can be one of the following constants: PRINTER_COPIES: sets how many copies should be printed, value must be an integer. PRINTER_MODE: specifies the type of data (text, raw or emf), value must be a string. PRINTER_TITLE: specifies the name of the document, value must be a string. PRINTER_ORIENTATION: specifies the orientation of the paper, value can be either PRINTER_ORIENTATION_PORTRAIT or PRINTER_ORIENTATION_LANDSCAPE PRINTER_RESOLUTION_Y: specifies the y-resolution in DPI, value must be an integer. PRINTER_RESOLUTION_X: specifies the x-resolution in DPI, value must be an integer. PRINTER_PAPER_FORMAT: specifies the a predefined paper format, set value to PRINTER_FORMAT_CUSTOM if you want to specify a custom format with PRINTER_PAPER_WIDTH and PRINTER_PAPER_LENGTH. value can be one of the following constants. PRINTER_FORMAT_CUSTOM: let's you specify a custom paper format. PRINTER_FORMAT_LETTER: specifies standard letter format (8 1/2- by 11-inches). PRINTER_FORMAT_LETTER: specifies standard legal format (8 1/2- by 14-inches). PRINTER_FORMAT_A3: specifies standard A3 format (297- by 420-millimeters). PRINTER_FORMAT_A4: specifies standard A4 format (210- by 297-millimeters). PRINTER_FORMAT_A5: specifies standard A5 format (148- by 210-millimeters). PRINTER_FORMAT_B4: specifies standard B4 format (250- by 354-millimeters). PRINTER_FORMAT_B5: specifies standard B5 format (182- by 257-millimeter). PRINTER_FORMAT_FOLIO: specifies standard FOLIO format (8 1/2- by 13-inch). PRINTER_PAPER_LENGTH: if PRINTER_PAPER_FORMAT is set to PRINTER_FORMAT_CUSTOM, PRINTER_PAPER_LENGTH specifies a custom paper length in mm, value must be an integer. PRINTER_PAPER_WIDTH: if PRINTER_PAPER_FORMAT is set to PRINTER_FORMAT_CUSTOM, PRINTER_PAPER_WIDTH specifies a custom paper width in mm, value must be an integer. PRINTER_SCALE: specifies the factor by which the printed output is to be scaled. the page size is scaled from the physical page size by a factor of scale/100. for example if you set the scale to 50, the output would be half of it's original size. value must be an integer. PRINTER_BACKGROUND_COLOR: specifies the background color for the actual device context, value must be a string containing the rgb information in hex format i.e. "005533". PRINTER_TEXT_COLOR: specifies the text color for the actual device context, value must be a string containing the rgb information in hex format i.e. "005533". PRINTER_TEXT_ALIGN: specifies the text alignment for the actual device context, value can be combined through OR'ing the following constants: PRINTER_TA_BASELINE: text will be aligned at the base line. PRINTER_TA_BOTTOM: text will be aligned at the bottom. PRINTER_TA_TOP: text will be aligned at the top. PRINTER_TA_CENTER: text will be aligned at the center. PRINTER_TA_LEFT: text will be aligned at the left. PRINTER_TA_RIGHT: text will be aligned at the right. <function>printer_set_option</function> example $handle = printer_open(); printer_set_option($handle, PRINTER_SCALE, 75); printer_set_option($handle, PRINTER_TEXT_ALIGN, PRINTER_TA_LEFT); printer_close($handle); printer_get_option プリンタ設定データを取得する 説明 mixed printer_get_option resource handle string option The function retrieves the configuration setting of option. handle must be a valid handle to a printer. Take a look at printer_set_option for the settings that can be retrieved, additionally the following settings can be retrieved: PRINTER_DEVICENAME returns the devicename of the printer. PRINTER_DRIVERVERSION returns the printer driver version. <function>printer_get_option</function> example $handle = printer_open(); print printer_get_option($handle, PRINTER_DRIVERVERSION); printer_close($handle); printer_create_dc 新規デバイスコンテキストを作成する 説明 void printer_create_dc resource handle The function creates a new device context. A device context is used to customize the graphic objects of the document. handle must be a valid handle to a printer. <function>printer_create_dc</function> example $handle = printer_open(); printer_start_doc($handle); printer_start_page($handle); printer_create_dc($handle); /* do some stuff with the dc */ printer_set_option($handle, PRINTER_TEXT_COLOR, "333333"); printer_draw_text($handle, 1, 1, "text"); printer_delete_dc($handle); /* create another dc */ printer_create_dc($handle); printer_set_option($handle, PRINTER_TEXT_COLOR, "000000"); printer_draw_text($handle, 1, 1, "text"); /* do some stuff with the dc */ printer_delete_dc($handle); printer_endpage($handle); printer_end_doc($handle); printer_close($handle); printer_delete_dc デバイスコンテキストを削除する 説明 bool printer_delete_dc resource handle The function deletes the device context and returns true on success, or false if an error occurred. For an example see printer_create_dc. handle must be a valid handle to a printer. printer_start_doc 新規ドキュメントを開始する 説明 bool printer_start_doc resource handle [string document] The function creates a new document in the printer spooler. A document can contain multiple pages, it's used to schedule the print job in the spooler. handle must be a valid handle to a printer. The optional parameter document can be used to set an alternative document name. <function>printer_start_doc</function> example $handle = printer_open(); printer_start_doc($handle, "My Document"); printer_start_page($handle); printer_end_page($handle); printer_end_doc($handle); printer_close($handle); printer_end_doc ドキュメントを閉じる 説明 bool printer_end_doc resource handle The function creates a new document in the printer spooler. A document can contain multiple pages, it's used to schedule the print job in the spooler. For an example see printer_start_doc. handle must be a valid handle to a printer. printer_start_page 新規ページを開始する 説明 bool printer_start_page resource handle The function creates a new page in the active document. For an example see printer_start_doc. handle must be a valid handle to a printer. printer_end_page アクティブなページを閉じる 説明 bool printer_end_page resource handle The function closes the active page in the active document. For an example see printer_start_doc. handle must be a valid handle to a printer. printer_create_pen 新規ペンを作成する 説明 mixed printer_create_pen int style int width string color The function creates a new pen and returns a handle to it. A pen is used to draw lines and curves. For an example see printer_select_pen. color must be a color in RGB hex format, i.e. "000000" for black, width specifies the width of the pen whereas style must be one of the following constants: PRINTER_PEN_SOLID: creates a solid pen. PRINTER_PEN_DASH: creates a dashed pen. PRINTER_PEN_DOT: creates a dotted pen. PRINTER_PEN_DASHDOT: creates a pen with dashes and dots. PRINTER_PEN_DASHDOTDOT: creates a pen with dashes and double dots. PRINTER_PEN_INVISIBLE: creates an invisible pen. printer_delete_pen ペンを削除する 説明 bool printer_delete_pen resource handle The function deletes the selected pen. For an example see printer_select_pen. It returns true on success, or false otherwise. handle must be a valid handle to a pen. printer_select_pen ペンを選択する 説明 void printer_select_pen resource printer_handle resource pen_handle The function selects a pen as the active drawing object of the actual device context. A pen is used to draw lines and curves. I.e. if you draw a single line the pen is used. If you draw an rectangle the pen is used to draw the borders, while the brush is used to fill the shape. If you haven't selected a pen before drawing shapes, the shape won't be outlined. printer_handle must be a valid handle to a printer. pen_handle must be a valid handle to a pen. <function>printer_select_pen</function> example $handle = printer_open(); printer_start_doc($handle, "My Document"); printer_start_page($handle); $pen = printer_create_pen(PRINTER_PEN_SOLID, 30, "2222FF"); printer_select_pen($handle, $pen); printer_draw_line($handle, 1, 60, 500, 60); printer_delete_pen($pen); printer_end_page($handle); printer_end_doc($handle); printer_close($handle); printer_create_brush 新規ブラシを作成する 説明 mixed printer_create_brush int style string color The function creates a new brush and returns a handle to it. A brush is used to fill shapes. For an example see printer_select_brush. color must be a color in RGB hex format, i.e. "000000" for black, style must be one of the following constants: PRINTER_BRUSH_SOLID: creates a brush with a solid color. PRINTER_BRUSH_DIAGONAL: creates a brush with a 45-degree upward left-to-right hatch ( / ). PRINTER_BRUSH_CROSS: creates a brush with a cross hatch ( + ). PRINTER_BRUSH_DIAGCROSS: creates a brush with a 45 cross hatch ( x ). PRINTER_BRUSH_FDIAGONAL: creates a brush with a 45-degree downward left-to-right hatch ( \ ). PRINTER_BRUSH_HORIZONTAL: creates a brush with a horizontal hatch ( - ). PRINTER_BRUSH_VERTICAL: creates a brush with a vertical hatch ( | ). PRINTER_BRUSH_CUSTOM: creates a custom brush from an BMP file. The second parameter is used to specify the BMP instead of the RGB color code. printer_delete_brush ブラシを削除する 説明 bool printer_delete_brush resource handle The function deletes the selected brush. For an example see printer_select_brush. It returns true on success, or false otherwise. handle must be a valid handle to a brush. printer_select_brush ブラシを選択する 説明 void printer_select_brush resource printer_handle resource brush_handle The function selects a brush as the active drawing object of the actual device context. A brush is used to fill shapes. If you draw an rectangle the brush is used to draw the shapes, while the pen is used to draw the border. If you haven't selected a brush before drawing shapes, the shape won't be filled. printer_handle must be a valid handle to a printer. brush_handle must be a valid handle to a brush. <function>printer_select_brush</function> example $handle = printer_open(); printer_start_doc($handle, "My Document"); printer_start_page($handle); $pen = printer_create_pen(PRINTER_PEN_SOLID, 2, "000000"); printer_select_pen($handle, $pen); $brush = printer_create_brush(PRINTER_BRUSH_CUSTOM, "c:\\brush.bmp"); printer_select_brush($handle, $brush); printer_draw_rectangle($handle, 1,1,500,500); printer_delete_brush($brush); $brush = printer_create_brush(PRINTER_BRUSH_SOLID, "000000"); printer_select_brush($handle, $brush); printer_draw_rectangle($handle, 1,501,500,1001); printer_delete_brush($brush); printer_delete_pen($pen); printer_end_page($handle); printer_end_doc($handle); printer_close($handle); printer_create_font 新規フォントを作成する 説明 mixed printer_create_font string face int height int width int font_weight bool italic bool underline bool strikeout int orientaton The function creates a new font and returns a handle to it. A font is used to draw text. For an example see printer_select_font. face must be a string specifying the font face. height specifies the font height, and width the font width. The font_weight specifies the font weight (400 is normal), and can be one of the following predefined constants. PRINTER_FW_THIN: sets the font weight to thin (100). PRINTER_FW_ULTRALIGHT: sets the font weight to ultra light (200). PRINTER_FW_LIGHT: sets the font weight to light (300). PRINTER_FW_NORMAL: sets the font weight to normal (400). PRINTER_FW_MEDIUM: sets the font weight to medium (500). PRINTER_FW_BOLD: sets the font weight to bold (700). PRINTER_FW_ULTRABOLD: sets the font weight to ultra bold (800). PRINTER_FW_HEAVY: sets the font weight to heavy (900). italic can be true or false, and sets whether the font should be italic. underline can be true or false, and sets whether the font should be underlined. strikeout can be true or false, and sets whether the font should be striked out. orientation specifies a rotation. For an example see printer_select_font. printer_delete_font フォントを削除する 説明 bool printer_delete_font resource handle The function deletes the selected font. For an example see printer_select_font. It returns true on success, or false otherwise. handle must be a valid handle to a font. printer_select_font フォントを選択する 説明 void printer_select_font resource printer_handle resource font_handle The function selects a font to draw text. printer_handle must be a valid handle to a printer. font_handle must be a valid handle to a font. <function>printer_select_font</function> example $handle = printer_open(); printer_start_doc($handle, "My Document"); printer_start_page($handle); $font = printer_create_font("Arial", 148, 76, PRINTER_FW_MEDIUM, false, false, false, -50); printer_select_font($handle, $font); printer_draw_text($handle, "PHP is simply cool", 40, 40); printer_delete_font($font); printer_end_page($handle); printer_end_doc($handle); printer_close($handle); printer_logical_fontheight 論理フォントの高さを取得する 説明 int printer_logical_fontheight resource handle int height The function calculates the logical font height of height. handle must be a valid handle to a printer. <function>printer_logical_fontheight</function> example $handle = printer_open(); print printer_logical_fontheight($handle, 72); printer_close($handle); printer_draw_roundrect 角が丸い矩形を描画する 説明 void printer_draw_roundrect resource handle int ul_x int ul_y int lr_x int lr_y int width int height The function simply draws a rectangle with rounded corners. handle must be a valid handle to a printer. ul_x is the upper left x coordinate of the rectangle. ul_y is the upper left y coordinate of the rectangle. lr_x is the lower right x coordinate of the rectangle. lr_y is the lower right y coordinate of the rectangle. width is the width of the ellipse. height is the height of the ellipse. <function>printer_draw_roundrect</function> example $handle = printer_open(); printer_start_doc($handle, "My Document"); printer_start_page($handle); $pen = printer_create_pen(PRINTER_PEN_SOLID, 2, "000000"); printer_select_pen($handle, $pen); $brush = printer_create_brush(PRINTER_BRUSH_SOLID, "2222FF"); printer_select_brush($handle, $brush); printer_draw_roundrect($handle, 1, 1, 500, 500, 200, 200); printer_delete_brush($brush); printer_delete_pen($pen); printer_end_page($handle); printer_end_doc($handle); printer_close($handle); printer_draw_rectangle 矩形を描画する 説明 void printer_draw_rectangle resource handle int ul_x int ul_y int lr_x int lr_y The function simply draws a rectangle. handle must be a valid handle to a printer. ul_x is the upper left x coordinate of the rectangle. ul_y is the upper left y coordinate of the rectangle. lr_x is the lower right x coordinate of the rectangle. lr_y is the lower right y coordinate of the rectangle. <function>printer_draw_rectangle</function> example $handle = printer_open(); printer_start_doc($handle, "My Document"); printer_start_page($handle); $pen = printer_create_pen(PRINTER_PEN_SOLID, 2, "000000"); printer_select_pen($handle, $pen); $brush = printer_create_brush(PRINTER_BRUSH_SOLID, "2222FF"); printer_select_brush($handle, $brush); printer_draw_rectangle($handle, 1, 1, 500, 500); printer_delete_brush($brush); printer_delete_pen($pen); printer_end_page($handle); printer_end_doc($handle); printer_close($handle); printer_draw_elipse 楕円を描画する 説明 void printer_draw_elipse resource handle int ul_x int ul_y int lr_x int lr_y The function simply draws an ellipse. handle must be a valid handle to a printer. ul_x is the upper left x coordinate of the ellipse. ul_y is the upper left y coordinate of the ellipse. lr_x is the lower right x coordinate of the ellipse. lr_y is the lower right y coordinate of the ellipse. <function>printer_draw_elipse</function> example $handle = printer_open(); printer_start_doc($handle, "My Document"); printer_start_page($handle); $pen = printer_create_pen(PRINTER_PEN_SOLID, 2, "000000"); printer_select_pen($handle, $pen); $brush = printer_create_brush(PRINTER_BRUSH_SOLID, "2222FF"); printer_select_brush($handle, $brush); printer_draw_elipse($handle, 1, 1, 500, 500); printer_delete_brush($brush); printer_delete_pen($pen); printer_end_page($handle); printer_end_doc($handle); printer_close($handle); printer_draw_text テキストを描画する 説明 void printer_draw_text resource printer_handle string text int x int y The function simply draws text at position x, y using the selected font. printer_handle must be a valid handle to a printer. <function>printer_draw_text</function> example $handle = printer_open(); printer_start_doc($handle, "My Document"); printer_start_page($handle); $font = printer_create_font("Arial",72,48,400,false,false,false,0); printer_select_font($handle, $font); printer_draw_text($handle, "test", 10, 10); printer_delete_font($font); printer_end_page($handle); printer_end_doc($handle); printer_close($handle); printer_draw_line 線を描画する 説明 void printer_draw_line resource printer_handle int from_x int from_y int to_x int to_y The function simply draws a line from position from_x, from_y to position to_x, to_y using the selected pen. printer_handle must be a valid handle to a printer. <function>printer_draw_line</function> example $handle = printer_open(); printer_start_doc($handle, "My Document"); printer_start_page($handle); $pen = printer_create_pen(PRINTER_PEN_SOLID, 30, 000000"); printer_select_pen($handle, $pen); printer_draw_line($handle, 1, 10, 1000, 10); printer_draw_line($handle, 1, 60, 500, 60); printer_delete_pen($pen); printer_end_page($handle); printer_end_doc($handle); printer_close($handle); printer_draw_chord 弦を描画する 説明 void printer_draw_chord resource handle int rec_x int rec_y int rec_x1 int rec_y1 int rad_x int rad_y int rad_x1 int rad_y1 The function simply draws an chord. handle must be a valid handle to a printer. rec_x is the upper left x coordinate of the bounding rectangle. rec_y is the upper left y coordinate of the bounding rectangle. rec_x1 is the lower right x coordinate of the bounding rectangle. rec_y1 is the lower right y coordinate of the bounding rectangle. rad_x is x coordinate of the radial defining the beginning of the chord. rad_y is y coordinate of the radial defining the beginning of the chord. rad_x1 is x coordinate of the radial defining the end of the chord. rad_y1 is y coordinate of the radial defining the end of the chord. <function>printer_draw_chord</function> example $handle = printer_open(); printer_start_doc($handle, "My Document"); printer_start_page($handle); $pen = printer_create_pen(PRINTER_PEN_SOLID, 2, "000000"); printer_select_pen($handle, $pen); $brush = printer_create_brush(PRINTER_BRUSH_SOLID, "2222FF"); printer_select_brush($handle, $brush); printer_draw_chord($handle, 1, 1, 500, 500, 1, 1, 500, 1); printer_delete_brush($brush); printer_delete_pen($pen); printer_end_page($handle); printer_end_doc($handle); printer_close($handle); printer_draw_pie 円弧を描画する 説明 void printer_draw_pie resource handle int rec_x int rec_y int rec_x1 int rec_y1 int rad1_x int rad1_y int rad2_x int rad2_y The function simply draws an pie. handle must be a valid handle to a printer. rec_x is the upper left x coordinate of the bounding rectangle. rec_y is the upper left y coordinate of the bounding rectangle. rec_x1 is the lower right x coordinate of the bounding rectangle. rec_y1 is the lower right y coordinate of the bounding rectangle. rad1_x is x coordinate of the first radial's ending. rad1_y is y coordinate of the first radial's ending. rad2_x is x coordinate of the second radial's ending. rad2_y is y coordinate of the second radial's ending. <function>printer_draw_chord</function> example $handle = printer_open(); printer_start_doc($handle, "My Document"); printer_start_page($handle); $pen = printer_create_pen(PRINTER_PEN_SOLID, 2, "000000"); printer_select_pen($handle, $pen); $brush = printer_create_brush(PRINTER_BRUSH_SOLID, "2222FF"); printer_select_brush($handle, $brush); printer_draw_pie($handle, 1, 1, 500, 500, 1, 1, 500, 1); printer_delete_brush($brush); printer_delete_pen($pen); printer_end_page($handle); printer_end_doc($handle); printer_close($handle); printer_draw_bmp ビットマップを描画する 説明 void printer_draw_bmp resource handle string filename int x int y この関数は、ビットマップfilenameを座標x, yに描画します。handleはプリンタへの有効なハンドルである必要があります。 この関数は成功時にtrue、それ以外の場合にfalseを返します。 <function>printer_draw_bmp</function> の例 $handle = printer_open(); printer_start_doc($handle, "My Document"); printer_start_page($handle); printer_draw_bmp($handle, "c:\\image.bmp", 1, 1); printer_end_page($handle); printer_end_doc($handle); printer_close($handle);