Specifications

LISTING 30.6 Continued
// create a pdf document in memory
$pdf = pdf_open();
// set up the page size in points
// US letter is 11” x 8.5”
// there are approximately 72 points per inch
$width = 11*72;
$height = 8.5*72;
pdf_begin_page($pdf, $width, $height);
// draw a borders
$inset = 20; // space between border and page edge
$border = 10; // width of main border line
$inner = 2; // gap within the border
//draw outer border
pdf_rect($pdf, $inset-$inner,
$inset-$inner,
$width-2*($inset-$inner),
$height-2*($inset-$inner));
pdf_stroke($pdf);
//draw main border $border points wide
pdf_setlinewidth($pdf, $border);
pdf_rect($pdf, $inset+$border/2,
$inset+$border/2,
$width-2*($inset+$border/2),
$height-2*($inset+$border/2));
pdf_stroke($pdf);
pdf_setlinewidth($pdf, 1.0);
//draw inner border
pdf_rect($pdf, $inset+$border+$inner,
$inset+$border+$inner,
$width-2*($inset+$border+$inner),
$height-2*($inset+$border+$inner));
pdf_stroke($pdf);
//add text
pdf_set_font($pdf, “Times-Roman”, 48, “host”);
$startx = ($width - pdf_stringwidth($pdf, “PHP Certification”))/2;
pdf_show_xy($pdf, “PHP Certification”, $startx, 490);
pdf_set_font($pdf, “Times-Roman”, 26, “host”);
Generating Personalized Documents in Portable Document Format (PDF)
C
HAPTER 30
30
GENERATING
PERSONALIZED
DOCUMENTS IN
PDF
771
36 7842 CH30 3/6/01 3:40 PM Page 771