printer_draw_text
(PECL printer SVN)
printer_draw_text — Рисует текст
Описание
void printer_draw_text
( resource
$printer_handle
, string $text
, int $x
, int $y
)
Эта функция рисует текст text
на позиции
x
, y
, используя выбранный
шрифт.
Список параметров
-
printer_handle
-
printer_handle
должен быть действительным дескриптором принтера. -
text
-
Текст, который должен быть отрисован.
-
x
-
Координата
x
места отрисовки текста. -
y
-
Координата
y
места отрисовки текста.
Возвращаемые значения
Эта функция не возвращает значения после выполнения.
Примеры
Пример #1 Пример printer_draw_text()
<?php
$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);
?>
- PHP Руководство
- Функции по категориям
- Индекс функций
- Справочник функций
- Расширения только для Windows
- Принтер
- printer_abort
- printer_close
- printer_create_brush
- printer_create_dc
- printer_create_font
- printer_create_pen
- printer_delete_brush
- printer_delete_dc
- printer_delete_font
- printer_delete_pen
- printer_draw_bmp
- printer_draw_chord
- printer_draw_elipse
- printer_draw_line
- printer_draw_pie
- printer_draw_rectangle
- printer_draw_roundrect
- printer_draw_text
- printer_end_doc
- printer_end_page
- printer_get_option
- printer_list
- printer_logical_fontheight
- printer_open
- printer_select_brush
- printer_select_font
- printer_select_pen
- printer_set_option
- printer_start_doc
- printer_start_page
- printer_write
Коментарии
I've a problem with the right alignment for number with draw_text so I make a small function and it is work for me, hopefully it will help other.
function write_num($input,$printer,$ypos,$xpos){
$s=strlen($input);
$y=$xpos;
for ($i=1;$i<$s+1;$i++){
$u=$i*-1;
printer_draw_text($printer,substr($input,$u,1),$y,$ypos);
$y=$y-15;
}
}
Firman, Indonesia
Placing text or other elements on a page could be a worst thing.
I wrote and use now the following code to print out a page as orientation help.
The creation time will be much shorter...
[CODE]
<?php
$p = printer_open();
printer_set_option($p, PRINTER_PAPER_FORMAT, PRINTER_FORMAT_A4);
printer_start_doc($p, "Testpage");
printer_start_page($p);
$pen = printer_create_pen(PRINTER_PEN_SOLID, 1, "000000");
$font = printer_create_font("Courier", 37, 19, PRINTER_FW_NORMAL, false, false, false, 0);
printer_select_pen($p, $pen);
printer_select_font($p, $font);
for ($i = 0; $i < 4600; $i+=100)
{
printer_draw_line($p, $i,0,$i,6700);
printer_draw_text($p,$i,$i,0);
}
for ($i = 0; $i < 6700; $i+=100)
{
printer_draw_line($p, 0,$i,4600,$i);
printer_draw_text($p,$i,0,$i);
}
printer_delete_font($font);
printer_delete_pen($pen);
printer_end_page($p);
printer_end_doc($p);
printer_close($p);
?>
[/CODE]
btw.
Has anyone a list for character sizes (x,y)? Like:
12px = 50, 12
14px = 60, 20
Frank