note 57586 added to ref.pdf
| From: | ragnar at deulos dot com | Date: | Sat, 08 Oct 2005 01:19:58 +0000 |
| Subject: | note 57586 added to ref.pdf | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-96645@lists.php.net to get a copy of this message | ||
PART II
<?php
// pdf_color(pdf resource, stroke color, fill color)
// this is used to set the colors, leave like empty string ("") to dont change the color
of what you want. The values are hexadecimal color like in the html (#FF00CC).
function pdf_color($pdf, $trazado, $relleno) {
if ($trazado != "") {
$color = str_replace("#", "", $trazado);
$rojo = (hexdec(substr($color, 0, 2)) / 255);
$verde = (hexdec(substr($color, 2, 2)) / 255);
$azul = (hexdec(substr($color, -2)) / 255);
pdf_setcolor($pdf, "stroke", "rgb", $rojo, $verde, $azul, 0);
}
if ($relleno != "") {
$color = str_replace("#", "", $relleno);
$rojo = (hexdec(substr($color, 0, 2)) / 255);
$verde = (hexdec(substr($color, 2, 2)) / 255);
$azul = (hexdec(substr($color, -2)) / 255);
pdf_setcolor($pdf, "fill", "rgb", $rojo, $verde, $azul, 0);
}
}
// pdf_linea(pdf resource, start x, start y, end x, end y, line width, color of the line)
// draws a line from start to the end with the width and color you want (the color is set in
hexadecimal)
function pdf_linea($pdf, $tx, $ty, $bx, $by, $grosor, $color) {
pdf_color($pdf, $color, "");
pdf_setlinewidth($pdf, $grosor);
pdf_moveto($pdf, $tx, $ty);
pdf_lineto($pdf, $bx, $by);
pdf_stroke($pdf);
}
// pdf_circulo(pdf resource, x, y, radius, stroke width, stroke color, fill color)
// draws a circle. if u dont want to stroke it set stroke width to 0 and if u dont want to fill it
leave the fill color as an empty string.
function pdf_circulo($pdf, $x, $y, $radio, $trazado, $c_trazado, $c_relleno) {
if ($trazado == 0) {
pdf_color($pdf, "", $c_relleno);
pdf_circle($pdf, $x, $y, $radio);
pdf_fill($pdf);
} elseif ($c_relleno == "") {
pdf_color($pdf, $c_trazado, $c_relleno);
pdf_setlinewidth($pdf, $trazado);
pdf_circle($pdf, $x, $y, $radio);
pdf_stroke($pdf);
} else {
pdf_color($pdf, $c_trazado, $c_relleno);
pdf_setlinewidth($pdf, $trazado);
pdf_circle($pdf, $x, $y, $radio);
pdf_fill_stroke($pdf);
}
}
// pdf_angulo(pdf resource, x, y, radius, starting degrees, ending degrees, stroke width, stroke
color, fill color)
// draws an arc. if u dont want to stroke it set stroke width to 0 and if u dont want to fill it
leave the fill color as an empty string.
function pdf_angulo($pdf, $x, $y, $radio, $angulo1, $angulo2, $trazado, $c_trazado, $c_relleno) {
if ($trazado == 0) {
pdf_color($pdf, "", $c_relleno);
pdf_arcn($pdf, $x, $y, $radio, $angulo1, $angulo2);
pdf_fill($pdf);
pdf_arc($pdf, $x, $y, $radio, $angulo1, $angulo2);
pdf_fill($pdf);
} elseif ($c_relleno == "") {
pdf_color($pdf, $c_trazado, $c_relleno);
pdf_setlinewidth($pdf, $trazado);
pdf_arc($pdf, $x, $y, $radio, $angulo1, $angulo2);
pdf_stroke($pdf);
} else {
pdf_color($pdf, $c_trazado, $c_relleno);
pdf_arcn($pdf, $x, $y, $radio, $angulo1, $angulo2);
pdf_fill($pdf);
pdf_setlinewidth($pdf, $trazado);
pdf_arc($pdf, $x, $y, $radio, $angulo1, $angulo2);
pdf_fill_stroke($pdf);
}
}
?>
----
Manual Page -- http://www.php.net/manual/en/ref.pdf.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+57586
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+57586&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+57586&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+57586&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+57586&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+57586&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+57586&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+57586&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+57586&report=yes
Search -- http://master.php.net/manage/user-notes.php