note 25025 deleted from function.cpdf-rect by didou
| From: | didou@php.net | Date: | Fri, 15 Aug 2003 13:54:06 +0000 |
| Subject: | note 25025 deleted from function.cpdf-rect by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-54197@lists.php.net to get a copy of this message | ||
Note Submitter: mikkel@hostpartner.dk
----
To draw a rectangle, remember to set the fill color using the function cpdf_setrgbcolor(int pdf
document, float red color, float green color, float blue color); before calling the cpdf_rect()
function.
After calling the cpdf_rect() function, call the cpdf_fill(int pdf document), to fill the rectangle.
Example:
<?php
$cpdf = cpdf_open(0);
cpdf_page_init($cpdf, 1, 0, 595, 842, 1.0);
// Set the fill color (grey)
cpdf_setrgbcolor($cpdf, 0.9, 0.9, 0.9);
// Draw a rectangle (x-coor 645, y-coor 400, height 180, width 180)
cpdf_rect($cpdf, 645, 400, 180, 180);
// Fill the rectangle
cpdf_fill($cpdf);
cpdf_finalize($cpdf);
Header("Content-type: application/pdf");
cpdf_output_buffer($cpdf);
cpdf_close($cpdf);
?>
Notice that the color set with the cpdf_setrgbcolor(), as mentioned above, is used until another
color is applied to the document.