PHP: PDF_rect - Manual

downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

PDF_restore PDF_process_pdi

Last updated: Fri, 26 Jan 2007

view this page in

# PDF_rect

(PHP 3 >= 3.0.6, PHP 4, PECL)

PDF_rect -- Draw rectangle

## Описание

bool PDF_rect ( resource p, float x, float y, float width, float height )

Draws a rectangle. Возвращает `TRUE` в случае успешного завершения или `FALSE` в случае возникновения ошибки.

add a note User Contributed Notes
PDF_rect
stuart at horuskol dot co dot uk
09-Jun-2006 02:14
`This section of the manual is really sparse, and there don't seem to be any tutorials out there that go beyond adding a single line of text, so I found this piece of information out by trial and error.
The function only specifies that you want a rectangle at those co-ordinates, and must be followed by a stroke command:
pdf_rect($pdf, 100, 100, 50, 50);
pdf_stroke($pdf);
This completes the process of placing the rectangle on the page.`
ragnar at deulos dot com
04-Oct-2005 11:09
`Be sure of adding a pdf_stroke(resource_pdf) after the pdf_rect function or will take an error in the PDFlib.`
tobias at midas dot se
16-May-2002 02:31
`Round rectangles
My function to create rectangles width round corners:
<?php
function pdf_roundrect($pdfobj, $xpos, $ypos, $xsize, $ysize, $radius)
{
$ypos = $ypos+$ysize;
pdf_moveto($pdfobj, $xpos, $ypos-$radius);
pdf_lineto($pdfobj, $xpos, $ypos-$ysize+$radius);
pdf_arc($pdfobj, $xpos+$radius, $ypos-$ysize+$radius, $radius, 180, 270);
pdf_lineto($pdfobj, $xpos+$xsize-$radius, $ypos-$ysize);
pdf_arc($pdfobj, $xpos+$xsize-$radius, $ypos-$ysize+$radius, $radius, 270, 360);
pdf_lineto($pdfobj, $xpos+$xsize, $ypos-$radius);
pdf_arc($pdfobj, $xpos+$xsize-$radius, $ypos-$radius, $radius,0,90);
pdf_lineto($pdfobj, $xpos+$radius, $ypos);
pdf_arc($pdfobj, $xpos+$radius, $ypos-$radius, $radius,90,180);
}
?>`
02-Aug-2001 05:26
`This will draw a simple rectangle...
...with a few extras.
<?php
//Create & Open PDF-Object
$pdf = pdf_new();
pdf_open_file($pdf);
pdf_set_info($pdf, "Author","Bob Nijman");
pdf_set_info($pdf, "Title","www.nijman.de");
pdf_set_info($pdf, "Creator", "bob@nijman.de");
pdf_set_info($pdf, "Subject", "pdf-stuff");
pdf_begin_page($pdf, 200, 200);
// just a simple rectangle
pdf_setlinewidth($pdf, 5); //make the border of the rectangle a bit wider
pdf_rotate($pdf, 5); //rotate the coordinate system (NOT THE RECTANGLE !!!!!)
pdf_rect($pdf, 100, 100, 50, 50); //draw the rectangle
pdf_stroke($pdf); //stroke the path with the current color(not yet :-)) and line width
//note: the rect is not drawn untill we use pdf_stroke - try it out!!!
//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=invoice.pdf');
header('Content-length: ' . strlen($data));
echo $data;
?>
Thanx to:
http://www.dynamicwebpages.de/50.tutorials.php?dwp_tutorialID=11
Great german (!!!) tutorial`
add a note
PDF_restore PDF_process_pdi

Last updated: Fri, 26 Jan 2007
show source | credits | stats | sitemap | contact | advertising | mirror sites
Copyright © 2001-2007 The PHP Group
All rights reserved.
This mirror generously provided by: Yahoo! Inc.
Last updated: Sat Mar 10 10:36:09 2007 PST