PHP : Function Reference : PDF Functions : PDF_lineto
Examples ( Source code ) » PDF_lineto
<?php
//Create & Open PDF-Object
$pdf = pdf_new();
pdf_open_file($pdf);
pdf_set_info($pdf, "Author","Cristian Eugen");
pdf_set_info($pdf, "Title","www.navioo.com");
pdf_set_info($pdf, "Creator", "bob@navioo.com");
pdf_set_info($pdf, "Subject", "pdf-tests");
pdf_begin_page($pdf, 200, 200);
//
pdf_moveto($pdfdoc, 100, 100);
pdf_lineto($pdfdoc, 200, 200);
pdf_lineto($pdfdoc, 100, 200);
pdf_closepath_fill_stroke($pdfdoc);
pdf_circle($pdfdoc, 250, 250, 30);
pdf_stroke($pdfdoc);
pdf_rect($pdfdoc, 100, 210, 120, 120);
pdf_stroke($pdfdoc);
//close it up
pdf_end_page($pdf);
pdf_close($pdf);
$data = pdf_get_buffer($pdf);
header('Content-type: application/pdf');
header('Content-disposition: inline; filename=mytest.pdf');
header('Content-length: ' . strlen($data));
echo $data;
?>
rod-php
function pdf_arrow ($pdfobj, $x1, $y1, $x2, $y2, $dashed) {
// This function will draw, stroke, and fill a line
// from (x1,y1) to (x2,y2) with an arrowhead defined
// by $headangle (in degrees) and $arrowlength.
// If $dashed is nonzero, a dashed line is drawn.
// REQUIRES: find_angle
$headangle = 20;
$arrowlength = 20;
list ($angle, $slope) = find_angle($x1, $y1, $x2, $y2);
pdf_moveto($pdfobj, $x2, $y2);
// Find the two other points of the arrowhead
// using $headangle and $arrowlength.
$xarrow1 = $x2+cos(deg2rad(180+$angle+$headangle/2))*$arrowlength;
$yarrow1 = $y2+sin(deg2rad(180+$angle+$headangle/2))*$arrowlength;
$xarrow2 = $x2+cos(deg2rad(180+$angle-$headangle/2))*$arrowlength;
$yarrow2 = $y2+sin(deg2rad(180+$angle-$headangle/2))*$arrowlength;
// Draw two legs of the arrowhead, close and fill
pdf_lineto($pdfobj, $xarrow1, $yarrow1);
pdf_lineto($pdfobj, $xarrow2, $yarrow2);
pdf_closepath($pdfobj);
pdf_fill($pdfobj);
// Find the point bisecting the short side
// of the arrowhead. This is necessary so
// the end of the line doesn't poke out the
// beyond the arrow point.
$x2line = ($xarrow1+$xarrow2)/2;
$y2line = ($yarrow1+$yarrow2)/2;
// Now draw the "body" line of the arrow
if ($dashed != 0) {
pdf_setdash($pdfobj,5,5);
}
pdf_moveto($pdfobj, $x1, $y1);
pdf_lineto($pdfobj, $x2line, $y2line);
pdf_stroke($pdfobj);
}
|