โค้ด: เลือกทั้งหมด
//Create a new PDF and add a letter-sized page
$pdf = new Zend_Pdf();
$n=0;
for($i=0; $i<10 ; $i++) {
$n++;
$pdf->pages[] = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
//Get a reference to that page
$page = $pdf->pages[$i];
//Create a graphics style and set options
$style = new Zend_Pdf_Style();
//Set the font color to black
$style->setLineColor(new Zend_Pdf_Color_Rgb(0,0,0));
//Load a font and add it to the style at size 12
$fontPath1 = "/usr/share/fonts/truetype/thai/Garuda.ttf";
$fontPath2 = "/usr/share/fonts/truetype/thai/Garuda-Bold.ttf";
$font1 = Zend_Pdf_Font::fontWithPath($fontPath1);
$font2 = Zend_Pdf_Font::fontWithPath($fontPath2);
//Header
$style->setFont($font2, 12);
$page->setStyle($style);
$page->drawText("หน้า $n/3", 210, 800, 'TIS-620');
$style->setFont($font1, 12);
$page->setStyle($style);
$page->drawText($n.'. เขียนโปรแกรมด้วย Zend Framework โดย อ.สาทิศ เพิ่มสว่าง 24กย52', 100, 750, 'TIS-620');
$pdf->save("/var/www/htdocs/tmp/test1.pdf");
}//for
echo "<h1>PDF Created!</h1>";