Specifications

pdf_rect($pdf, $inset+$border/2,
$inset+$border/2,
$width-2*($inset+$border/2),
$height-2*($inset+$border/2));
pdf_stroke($pdf);
After we have drawn our one wide line, we need to remember to set the line width back to 1
with this code:
pdf_setlinewidth($pdf, 1.0);
We are going to use pdf_show_xy() to position each line of text on the certificate. For most
lines of text, we are using a configurable left margin ($startx) as the x coordinate and a value
chosen by eye as the y coordinate. As we want the heading centered on the page, we need to
know its width in order to position the left hand side of it. We can get the width using
pdf_stringwidth(). The call
pdf_stringwidth($pdf, “PHP Certification”);
will return the width of the string “PHP Certification” in the current font and font size.
As with the other versions of the certificate, we will include a signature as a scanned bitmap.
The following three statements
$signature = pdf_open_image_file($pdf, “tiff”,
“/htdocs/book/chapter30/signature.tif”);
pdf_place_image($pdf, $signature, 200, 75, 1);
pdf_close_image($pdf, $signature);
will open a TIFF file containing the signature, add the image to the page at the specified loca-
tion, and close the TIFF file. Other file types can also be used. The only parameter that might
not be self explanatory is the fifth parameter to pdf_place_image(). This function is not lim-
ited to inserting the image at its original size. The fifth parameter is a scale factor. We have
chosen to display the image at full size and used 1 as the scale factor, but could have used a
larger number to enlarge the image, or a fraction to shrink it.
The hardest item to add to our certificate using PDFlib is the rosette. We cannot automatically
open and include a Windows Meta File containing the rosette we already have, but we are free
to draw any shapes we like.
In order to draw a filled shape such as one of the ribbons, we can write the following code.
Here we set the stroke or line color to be black and the fill or interior color to be a navy blue:
pdf_setrgbcolor_fill($pdf, 0, 0, .4); //dark blue
pdf_setrgbcolor_stroke($pdf, 0, 0, 0); // black
Here we set up a five-sided polygon to be one of our ribbons and then fill it:
Building Practical PHP and MySQL Projects
P
ART V
776
36 7842 CH30 3/6/01 3:40 PM Page 776