(PHP 4, PHP 5 <= 5.0.5)
cpdf_rect — Draw a rectangle
Draws a rectangle.
The document handle, returned by cpdf_open().
The x-coordinate of the lower left corner
The y-coordinate of the lower left corner
The rectangle width
The rectangle height
The optional parameter mode determines the unit length. If it is 0 or omitted the default unit as specified for the page is used. Otherwise the coordinates are measured in postscript points disregarding the current unit.
如果成功则返回 TRUE,失败则返回 FALSE。
Example#1 Drawing a rectangle
<?php
$cpdf = cpdf_open(0);
cpdf_page_init($cpdf, 1, 0, 595, 842, 1.0);
// set the fill color to red
cpdf_setrgbcolor($cpdf, 1, 0, 0);
// draw a (180 * 100) rectangle
cpdf_rect($cpdf, 645, 400, 180, 100);
// fill the rectangle
cpdf_fill($cpdf);
cpdf_finalize($cpdf);
Header("Content-type: application/pdf");
cpdf_output_buffer($cpdf);
cpdf_close($cpdf);
?>