สร้าง PDF ด้วย Zend Framework

หมวดสำหรับแบ่งบันความ รู้ต่างๆ จะมีหมวดย่อยๆ ในหมวดนี้ เช่น php, SQL, XML, CSS

Moderator: mindphp, ผู้ดูแลกระดาน

zend_framework
PHP Full Member
PHP Full Member
โพสต์: 41
ลงทะเบียนเมื่อ: 08/03/2011 11:22 pm

สร้าง PDF ด้วย Zend Framework

โพสต์ที่ยังไม่ได้อ่าน โดย zend_framework »

สร้าง PDF ด้วย Zend Framework

โค้ด: เลือกทั้งหมด

//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>";

 
  • Similar Topics
    ตอบกลับ
    แสดง
    โพสต์ล่าสุด

ผู้ใช้งานขณะนี้

สมาชิกกำลังดูบอร์ดนี้: ไม่มีสมาชิกใหม่ และบุคลทั่วไป 71