Index: phpdoc/ja/functions/java.xml
+++ phpdoc/ja/functions/java.xml
JavaPHP / 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_getjava_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_clearjava_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 は、デバイスコンテキストも開始します。
printer_open の例
$handle = printer_open("HP Deskjet 930c");
$handle = printer_open();
printer_abortプリンタのスプールファイルを削除する説明void printer_abortresource handle
この関数は、プリンタのスプールファイルを削除します。
handle には、プリンタへの有効なハンドルを指定する必要があります。
printer_abort の例
$handle = printer_open();
printer_abort($handle);
printer_close($handle);
printer_closeプリンタへの接続を閉じる説明void printer_closeresource handle
この関数は、プリンタへの接続をクローズします。
printer_close は、アクティブなデバイスコンテキストへもクローズします。
handle は、プリンタへの有効なハンドルである必要があります。
printer_close の例
$handle = printer_open();
printer_close($handle);
printer_writeプリンタへデータを書き込む説明bool printer_writeresource handlestring contentcontent を直接プリンタに書き込み、成功時にtrue、失敗した場合にfalseを返します。
handle は、プリンタへの有効なハンドルである必要があります。
printer_write の例
$handle = printer_open();
printer_write($handle, "Text to print");
printer_close($handle);
printer_listサーバで付加されたプリンタの配列を返す説明array printer_listint 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の場合のみ有効です。
printer_list の例
/* ローカルな共有プリンタを検出 */
var_dump( printer_list(PRINTER_ENUM_LOCAL | PRINTER_ENUM_SHARED) );
printer_set_optionプリンタの接続を設定する説明bool printer_set_optionresource handleint optionmixed 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.
printer_set_option 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_optionresource handlestring 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.
printer_get_option example
$handle = printer_open();
print printer_get_option($handle, PRINTER_DRIVERVERSION);
printer_close($handle);
printer_create_dc新規デバイスコンテキストを作成する説明void printer_create_dcresource 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.
printer_create_dc 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_dcresource 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_docresource 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.
printer_start_doc 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_docresource 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_pageresource 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_pageresource 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_penint styleint widthstring 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_penresource 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_penresource printer_handleresource 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.
printer_select_pen 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_brushint stylestring 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_brushresource 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_brushresource printer_handleresource 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.
printer_select_brush 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_fontstring faceint heightint widthint font_weightbool italicbool underlinebool strikeoutint 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_fontresource 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_fontresource printer_handleresource 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.
printer_select_font 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_fontheightresource handleint height
The function calculates the logical font height of
height. handle must
be a valid handle to a printer.
printer_logical_fontheight example
$handle = printer_open();
print printer_logical_fontheight($handle, 72);
printer_close($handle);
printer_draw_roundrect角が丸い矩形を描画する説明void printer_draw_roundrectresource handleint ul_xint ul_yint lr_xint lr_yint widthint 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.
printer_draw_roundrect 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_rectangleresource handleint ul_xint ul_yint lr_xint 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.
printer_draw_rectangle 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_elipseresource handleint ul_xint ul_yint lr_xint 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.
printer_draw_elipse 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_textresource printer_handlestring textint xint y
The function simply draws text at position
x, y using the selected
font. printer_handle must be a valid handle to
a printer.
printer_draw_text 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_lineresource printer_handleint from_xint from_yint to_xint 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.
printer_draw_line 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_chordresource handleint rec_xint rec_yint rec_x1int rec_y1int rad_xint rad_yint rad_x1int 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.
printer_draw_chord 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_pieresource handleint rec_xint rec_yint rec_x1int rec_y1int rad1_xint rad1_yint rad2_xint 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.
printer_draw_chord 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_bmpresource handlestring filenameint xint y
この関数は、ビットマップfilenameを座標x, yに描画します。handleはプリンタへの有効なハンドルである必要があります。
この関数は成功時にtrue、それ以外の場合にfalseを返します。
printer_draw_bmp の例
$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);