Пример #1
0
<?php

// use these require statements if you point your http server directly to this folder.
require "../Fpdf.php";
require "../JsonPDF.php";
// use this require statement instead if you install JsonPDF via composer
// and comment out the above require statements.
//require 'vendor/autoload.php';
$footer_start = 212.2;
$footer_row = $footer_start;
$signature_row = 250;
$document = array('header' => array(array('type' => 'image', 'url' => 'img/rbb_logo.png', 'x' => 10, 'y' => 5, 'width' => 20, 'render-as' => 'form'), array('type' => 'text', 'text' => '{report_name}', 'font' => 'THSarabun', 'font-style' => 'B', 'font-size' => 24, 'y' => 13, 'align' => 'R', 'render-as' => 'form'), array('type' => 'text', 'text' => 'M U I  Rubber Belt Co., Ltd.', 'font' => 'THSarabun', 'font-style' => 'b', 'font-size' => 20, 'x' => 33, 'y' => 13, 'width' => 80, 'render-as' => 'form'), array('type' => 'text', 'text' => 'บริษัท เอ็ม ยู ไอ รับเบอร์เบลท์ จำกัด', 'font' => 'THSarabun', 'font-size' => 16, 'x' => 33, 'y' => 20, 'width' => 80, 'render-as' => 'form'), array('type' => 'text', 'text' => '51/231 หมู่ 2 ซ.งามวงศ์วาน 8 ถ.งามวงศ์วาน ต.บางเขน อ.เมือง จ.นนทบุรี 11000', 'font' => 'THSarabun', 'font-size' => 12, 'x' => 10, 'y' => 28, 'width' => 80, 'render-as' => 'form'), array('type' => 'text', 'text' => 'Tel. 036-329546, 036-329559  Fax. 036-329xxx, 036-329XXX', 'font' => 'THSarabun', 'font-size' => 12, 'x' => 10, 'y' => 32, 'width' => 80, 'render-as' => 'form'), array('type' => 'text', 'text' => 'เลขประจำตัวผู้เสียภาษี {tax_id} / {branch}', 'font' => 'THSarabun', 'font-size' => 12, 'x' => 10, 'y' => 38, 'width' => 80, 'render-as' => 'form'), array('type' => 'line', 'x1' => 10, 'y1' => 24, 'draw-color' => '100', 'render-as' => 'form'), array('type' => 'rect', 'x' => 10, 'y' => 42, 'width' => 110, 'height' => 40, 'radius' => 2, 'draw-color' => '0,0,0', 'render-as' => 'form'), array('type' => 'rect', 'x' => 122, 'y' => 42, 'width' => 78, 'height' => 40, 'radius' => 2, 'render-as' => 'form'), array('type' => 'text', 'text' => 'รหัสลูกค้า', 'font' => 'THSarabun', 'font-size' => 12, 'x' => 11, 'y' => 46, 'render-as' => 'form'), array('type' => 'text', 'text' => '{ar_code}', 'font-size' => 12, 'x' => 30, 'y' => 46, 'render-as' => 'data'), array('type' => 'text', 'text' => 'เลขประจำตัวผู้เสียภาษี', 'font-size' => 12, 'x' => 42, 'y' => 46, 'render-as' => 'form'), array('type' => 'text', 'text' => '{ar_tax_id} / {ar_branch}', 'font-size' => 12, 'x' => 70, 'y' => 46, 'render-as' => 'data'), array('type' => 'text', 'text' => 'นามลูกค้า', 'font-size' => 12, 'x' => 11, 'y' => 52, 'render-as' => 'form'), array('type' => 'text', 'text' => '{ar_name}', 'font-size' => 12, 'x' => 30, 'y' => 52, 'render-as' => 'data'), array('type' => 'text', 'text' => 'ที่อยู่', 'font-size' => 12, 'x' => 11, 'y' => 58, 'render-as' => 'form'), array('type' => 'text', 'text' => '{ar_addr1}', 'font-size' => 12, 'x' => 30, 'y' => 58, 'render-as' => 'data'), array('type' => 'text', 'text' => '{ar_addr2}', 'font-size' => 12, 'x' => 30, 'y' => 64, 'render-as' => 'data'), array('type' => 'text', 'text' => 'เลขที่ใบสั่งซื้อ', 'font-size' => 12, 'x' => 11, 'y' => 70, 'render-as' => 'form'), array('type' => 'text', 'text' => '{po_no}', 'font-size' => 12, 'x' => 30, 'y' => 70, 'render-as' => 'data'), array('type' => 'text', 'text' => 'หมายเหตุ', 'font-size' => 12, 'x' => 11, 'y' => 76, 'render-as' => 'form'), array('type' => 'text', 'text' => '{remark}', 'font-size' => 12, 'x' => 30, 'y' => 76, 'render-as' => 'data'), array('type' => 'text', 'text' => 'วันที่', 'font-size' => 12, 'x' => 123, 'y' => 46, 'render-as' => 'form'), array('type' => 'text', 'text' => '{doc_date}', 'font-size' => 12, 'x' => 150, 'y' => 46, 'render-as' => 'data'), array('type' => 'text', 'text' => 'เลขที่ใบกำกับ', 'font-size' => 12, 'x' => 123, 'y' => 52, 'render-as' => 'form'), array('type' => 'text', 'text' => 'พนักงานขาย', 'font-size' => 12, 'x' => 123, 'y' => 58, 'render-as' => 'form'), array('type' => 'text', 'text' => 'การชำระเงิน', 'font-size' => 12, 'x' => 123, 'y' => 64, 'render-as' => 'form'), array('type' => 'text', 'text' => 'วันที่ครบกำหนด', 'font-size' => 12, 'x' => 123, 'y' => 70, 'render-as' => 'form'), array('type' => 'text', 'text' => 'จัดส่งโดย', 'font-size' => 12, 'x' => 123, 'y' => 76, 'render-as' => 'form'), array('type' => 'text', 'text' => '{doc_no}', 'font-size' => 12, 'x' => 150, 'y' => 52, 'render-as' => 'data'), array('type' => 'text', 'text' => '{sale_id}', 'font-size' => 12, 'x' => 150, 'y' => 58, 'render-as' => 'data'), array('type' => 'text', 'text' => '{pay_terms}', 'font-size' => 12, 'x' => 150, 'y' => 64, 'render-as' => 'data'), array('type' => 'text', 'text' => '{duedate}', 'font-size' => 12, 'x' => 150, 'y' => 70, 'render-as' => 'data'), array('type' => 'text', 'text' => '{delivery}', 'font-size' => 12, 'x' => 150, 'y' => 76, 'render-as' => 'data'), array('type' => 'table-header', 'render-as' => 'form', 'y' => 85, 'x' => 10, 'table' => 'items_table', 'font' => 'THSarabun', 'font-size' => 20, 'style' => array('title-row' => array('height' => 8)))), 'footer' => array(array('type' => 'rect', 'x' => 10, 'y' => $footer_row, 'width' => 110, 'height' => 10, 'render-as' => 'form'), array('type' => 'text', 'text' => '{baht_text}', 'font-size' => 12, 'x' => 11, 'y' => $footer_row + 5, 'render-as' => 'data'), array('type' => 'rect', 'x' => 120, 'y' => $footer_row, 'width' => 50, 'height' => 10, 'render-as' => 'form'), array('type' => 'text', 'text' => 'รวมเงิน', 'font-size' => 12, 'x' => 121, 'y' => $footer_row + 5, 'render-as' => 'form'), array('type' => 'rect', 'x' => 170, 'y' => $footer_row, 'width' => 30, 'height' => 10, 'render-as' => 'form'), array('type' => 'text', 'text' => '{total}', 'font-size' => 12, 'x' => 171, 'y' => $footer_row + 5, 'width' => 29, 'align' => 'R', 'render-as' => 'data'), array('type' => 'rect', 'x' => 120, 'y' => $footer_row += 10, 'width' => 50, 'height' => 10, 'render-as' => 'form'), array('type' => 'text', 'text' => 'ภาษีมูลค่าเพิ่ม', 'font-size' => 12, 'x' => 121, 'y' => $footer_row + 5, 'render-as' => 'form'), array('type' => 'text', 'text' => '{vat_rate}', 'font-size' => 12, 'x' => 150, 'y' => $footer_row + 5, 'width' => 20, 'align' => 'R', 'render-as' => 'data'), array('type' => 'rect', 'x' => 170, 'y' => $footer_row, 'width' => 30, 'height' => 10, 'render-as' => 'form'), array('type' => 'text', 'text' => '{vat_amount}', 'font-size' => 12, 'x' => 171, 'y' => $footer_row + 5, 'width' => 29, 'align' => 'R', 'render-as' => 'data'), array('type' => 'rect', 'x' => 120, 'y' => $footer_row += 10, 'width' => 50, 'height' => 10, 'render-as' => 'form'), array('type' => 'text', 'text' => 'ยอดเงินสุทธิ', 'font-size' => 12, 'x' => 121, 'y' => $footer_row + 5, 'render-as' => 'form'), array('type' => 'rect', 'x' => 170, 'y' => $footer_row, 'width' => 30, 'height' => 10, 'render-as' => 'form'), array('type' => 'text', 'text' => '{net_total}', 'font-size' => 12, 'x' => 171, 'y' => $footer_row + 5, 'width' => 29, 'align' => 'R', 'render-as' => 'data'), array('type' => 'text', 'text' => 'Remark: แพนงเชิญเซฟตี้นายแบบแฮนด์ ฮาลาลม็อบแหวว อพาร์ทเมนต์จ๊อกกี้ดีพาร์ตเมนต์แหม็บ ล้มเหลวโหงวเฮ้ง ว้าวสันทนาการหม่านโถว แชมเปญเอ็นทรานซ์เซฟตี้อินดอร์ พาสตาฮิปฮอป แมมโบ้แพนงเชิญฮิต ไคลแม็กซ์วิภัชภาค ซูม แทกติครีไทร์หน่อมแน้มรัม ท็อปบู๊ท ซาตานเที่ยงคืนไฮกุไฟแนนซ์เสือโคร่ง คาร์โคโยตีบุ๋นฮัลโหล แมกกาซีนก๊วนแฟร์', 'multiline' => true, 'font-size' => 12, 'x' => 10, 'y' => $footer_start + 13, 'width' => 110, 'height' => 4, 'align' => 'L', 'render-as' => 'form'), array('type' => 'rect', 'x' => 10, 'y' => $signature_row, 'width' => 62, 'height' => 30, 'radius' => 2, 'render-as' => 'form'), array('type' => 'line', 'x1' => 12, 'y1' => $signature_row + 22, 'x2' => 70, 'y2' => $signature_row + 22, 'draw-color' => '100', 'render-as' => 'form'), array('type' => 'text', 'text' => 'ผู้รับสินค้า', 'font-size' => 10, 'x' => 12, 'y' => $signature_row + 26, 'width' => 58, 'align' => 'C', 'render-as' => 'form'), array('type' => 'rect', 'x' => 74, 'y' => $signature_row, 'width' => 62, 'height' => 30, 'radius' => 2, 'render-as' => 'form'), array('type' => 'line', 'x1' => 76, 'y1' => $signature_row + 22, 'x2' => 134, 'y2' => $signature_row + 22, 'draw-color' => '100', 'render-as' => 'form'), array('type' => 'text', 'text' => 'ผู้ส่งสินค้า', 'font-size' => 10, 'x' => 76, 'y' => $signature_row + 26, 'width' => 58, 'align' => 'C', 'render-as' => 'form'), array('type' => 'rect', 'x' => 138, 'y' => $signature_row, 'width' => 62, 'height' => 30, 'radius' => 2, 'render-as' => 'form'), array('type' => 'text', 'text' => 'ในนาม หจก.สระบุรียูเนี่ยน', 'font-size' => 10, 'x' => 140, 'y' => $signature_row + 3, 'width' => 58, 'align' => 'C', 'render-as' => 'form'), array('type' => 'line', 'x1' => 140, 'y1' => $signature_row + 22, 'x2' => 198, 'y2' => $signature_row + 22, 'draw-color' => '100', 'render-as' => 'form'), array('type' => 'text', 'text' => 'ผู้มีอำนาจลงนาม', 'font-size' => 10, 'x' => 140, 'y' => $signature_row + 26, 'width' => 58, 'align' => 'C', 'render-as' => 'form'), array('type' => 'text', 'y' => -15, 'width' => 0, 'height' => 10, 'font' => 'Arial', 'font-style' => 'I', 'font-size' => 8, 'draw-color' => '0,0,0', 'text' => 'Page {page}/{nb}', 'border' => 'T', 'align' => 'C', 'render-as' => 'form'), array('type' => 'text', 'x' => -25, 'y' => 25, 'width' => 0, 'height' => 10, 'font-size' => 8, 'draw-color' => '0,0,0', 'text' => 'Page {page}/{nb}', 'render-as' => 'form')), 'body' => array(array('type' => 'table-body', 'table' => 'items_table', 'font' => 'THSarabun', 'font-size' => 20, 'style' => array('data-row' => array()))), 'tables' => array('items_table' => array('rows-per-page' => 17, 'columns' => array(array('name' => 'item_code', 'width' => 20, 'title' => 'รหัสสินค้า', 'title-align' => 'L', 'data-align' => 'L'), array('name' => 'item_desc', 'width' => 70, 'title' => 'รายละเอียดสินค้า', 'data-align' => 'L'), array('name' => 'item_qty', 'width' => 20, 'title' => 'จำนวน', 'title-align' => 'C', 'data-align' => 'R'), array('name' => 'item_price', 'width' => 30, 'title' => 'หน่วยละ', 'title-align' => 'C', 'data-align' => 'R'), array('name' => 'item_disc', 'width' => 20, 'title' => 'ส่วนลด', 'title-align' => 'C', 'data-align' => 'R'), array('name' => 'item_amount', 'width' => 30, 'title' => 'จำนวนเงิน', 'title-align' => 'C', 'data-align' => 'R')), 'data' => 'bill_items', 'style' => array('border-color' => '0,0,0', 'title-row' => array('height' => 8, 'text-color' => '200, 100, 50', 'fill-color' => false, 'font-size' => 14), 'data-row' => array('font-size' => 12, 'height' => 7, 'text-color' => '0,0,0', 'fill-color' => '224,235,255', 'striped' => true)))), 'settings' => array('title' => 'Test PDF', 'author' => 'Rati Wannapanop', 'subject' => 'Test Creating PDF', 'keywords' => 'test pdf fpdf ratiw', 'default-font' => array('name' => 'THSarabun', 'size' => 30), 'header-height' => 93.2, 'auto-pagebreak' => true, 'auto-pagebreak-margin' => 82), 'fonts' => array(array('THSarabun', '', 'THSarabun.php'), array('THSarabun', 'B', 'THSarabun Bold.php'), array('THSarabun', 'I', 'THSarabun Italic.php'), array('THSarabun', 'BI', 'THSarabun Bold Italic.php')));
$data = array('name' => 'รติ วรรณภานพ', 'date' => '09/11/2556', 'report_name' => 'ใบส่งสินค้า/ใบกำกับภาษี', 'tax_id' => '0193626000226', 'branch' => 'สำนักงานใหญ่', 'ar_code' => 'D007', 'ar_tax_id' => '1005425879654', 'ar_branch' => 'สำนักงานใหญ่', 'ar_name' => 'บริษัท ดิสเพลย์เซลแอนด์เซอร์วิส', 'ar_addr1' => '333/3 ถ.เจริญกรุง บางรัก', 'ar_addr2' => 'กรุงเทพฯ 10800', 'po_no' => 'PO14/2051', 'remark' => '', 'doc_date' => '02/08/56', 'doc_no' => '56/1187', 'sale_id' => 'เกียรติยศ', 'pay_terms' => '15 วัน', 'duedate' => '17/08/56', 'delivery' => 'บขส.', 'bill_items' => array(array('item_code' => 'ประเทศไทย', 'item_desc' => 'กรุงเทพฯ', 'item_qty' => '83,859', 'item_price' => '8,075', 'item_disc' => '', 'item_amount' => '3,750.00'), array('item_code' => 'Austria', 'item_desc' => 'Vienna', 'item_qty' => '83,859', 'item_price' => '8,075', 'item_disc' => '', 'item_amount' => '3,750.00'), array('item_code' => 'Austria', 'item_desc' => 'Vienna', 'item_qty' => '83,859', 'item_price' => '8,075', 'item_disc' => '', 'item_amount' => '3,750.00'), array('item_code' => 'Austria', 'item_desc' => 'Vienna', 'item_qty' => '83,859', 'item_price' => '8,075', 'item_disc' => '', 'item_amount' => '3,750.00'), array('item_code' => 'Austria', 'item_desc' => 'Vienna', 'item_qty' => '83,859', 'item_price' => '8,075', 'item_disc' => '', 'item_amount' => '3,750.00'), array('item_code' => 'Austria', 'item_desc' => 'Vienna', 'item_qty' => '83,859', 'item_price' => '8,075', 'item_disc' => '', 'item_amount' => '3,750.00'), array('item_code' => 'Austria', 'item_desc' => 'Vienna', 'item_qty' => '83,859', 'item_price' => '8,075', 'item_disc' => '', 'item_amount' => '3,750.00'), array('item_code' => 'Austria', 'item_desc' => 'Vienna', 'item_qty' => '83,859', 'item_price' => '8,075', 'item_disc' => '', 'item_amount' => '3,750.00'), array('item_code' => 'Austria', 'item_desc' => 'Vienna', 'item_qty' => '83,859', 'item_price' => '8,075', 'item_disc' => '', 'item_amount' => '3,750.00'), array('item_code' => 'Austria', 'item_desc' => 'Vienna', 'item_qty' => '83,859', 'item_price' => '8,075', 'item_disc' => '', 'item_amount' => '3,750.00'), array('item_code' => 'Austria', 'item_desc' => 'Vienna', 'item_qty' => '83,859', 'item_price' => '8,075', 'item_disc' => '', 'item_amount' => '3,750.00'), array('item_code' => 'Austria', 'item_desc' => 'Vienna', 'item_qty' => '83,859', 'item_price' => '8,075', 'item_disc' => '', 'item_amount' => '3,750.00'), array('item_code' => 'ประเทศไทย', 'item_desc' => 'กรุงเทพฯ', 'item_qty' => '83,859', 'item_price' => '8,075', 'item_disc' => '', 'item_amount' => '3,750.00'), array('item_code' => 'Austria', 'item_desc' => 'Vienna', 'item_qty' => '83,859', 'item_price' => '8,075', 'item_disc' => '', 'item_amount' => '3,750.00'), array('item_code' => 'Austria', 'item_desc' => 'Vienna', 'item_qty' => '83,859', 'item_price' => '8,075', 'item_disc' => '', 'item_amount' => '3,750.00'), array('item_code' => 'Austria', 'item_desc' => 'Vienna', 'item_qty' => '83,859', 'item_price' => '8,075', 'item_disc' => '', 'item_amount' => '3,750.00'), array('item_code' => 'Austria', 'item_desc' => 'Vienna', 'item_qty' => '83,859', 'item_price' => '8,075', 'item_disc' => '', 'item_amount' => '3,750.00'), array('item_code' => 'Austria', 'item_desc' => 'Vienna', 'item_qty' => '83,859', 'item_price' => '8,075', 'item_disc' => '', 'item_amount' => '3,750.00'), array('item_code' => 'Austria', 'item_desc' => 'Vienna', 'item_qty' => '83,859', 'item_price' => '8,075', 'item_disc' => '', 'item_amount' => '3,750.00'), array('item_code' => 'Austria', 'item_desc' => 'Vienna', 'item_qty' => '83,859', 'item_price' => '8,075', 'item_disc' => '', 'item_amount' => '3,750.00'), array('item_code' => 'Austria', 'item_desc' => 'Vienna', 'item_qty' => '83,859', 'item_price' => '8,075', 'item_disc' => '', 'item_amount' => '3,750.00'), array('item_code' => 'Austria', 'item_desc' => 'Vienna', 'item_qty' => '83,859', 'item_price' => '8,075', 'item_disc' => '', 'item_amount' => '3,750.00'), array('item_code' => 'Austria', 'item_desc' => 'Vienna', 'item_qty' => '83,859', 'item_price' => '8,075', 'item_disc' => '', 'item_amount' => '3,750.00'), array('item_code' => 'Austria', 'item_desc' => 'Vienna', 'item_qty' => '83,859', 'item_price' => '8,075', 'item_disc' => '', 'item_amount' => '3,750.00')));
$pdf = new ratiw\JsonPDF\JsonPDF('P', 'mm', 'A4');
$pdf->make(json_encode($document), json_encode($data), 'both');
$pdf->render();
Пример #2
0
<?php

// use these require statements if you point your http server directly to this folder.
require "../Fpdf.php";
require "../JsonPDF.php";
// use this require statement instead if you install JsonPDF via composer
// and comment out the above require statements.
//require 'vendor/autoload.php';
$document = array('header' => array(array('type' => 'image', 'url' => 'img/rbb_logo.png', 'x' => 10, 'y' => 5, 'width' => 20), array('type' => 'text', 'text' => '{report_name}', 'font' => 'THSarabun', 'font-style' => 'B', 'font-size' => 26, 'y' => 13, 'align' => 'R'), array('type' => 'text', 'text' => 'M U I  Rubber Belt Co., Ltd.', 'font' => 'THSarabun', 'font-style' => 'b', 'font-size' => 20, 'x' => 33, 'y' => 13, 'width' => 80), array('type' => 'text', 'text' => 'บริษัท เอ็ม ยู ไอ รับเบอร์เบลท์ จำกัด', 'font' => 'THSarabun', 'font-size' => 16, 'x' => 33, 'y' => 20, 'width' => 80), array('type' => 'line', 'x1' => 10, 'y1' => 28, 'draw-color' => '100'), array('type' => 'table-header', 'y' => 35, 'x' => 10, 'table' => 'world_info_table', 'font' => 'THSarabun', 'font-size' => 20)), 'footer' => array(array('type' => 'text', 'y' => -15, 'width' => 0, 'height' => 10, 'font' => 'Arial', 'font-style' => 'I', 'font-size' => 8, 'draw-color' => '0,0,0', 'text' => 'Page {page}/{nb}', 'border' => 'T', 'align' => 'C')), 'body' => array(array('type' => 'table-body', 'table' => 'world_info_table', 'font' => 'THSarabun', 'font-size' => 20)), 'tables' => array('world_info_table' => array('columns' => array(array('name' => 'country', 'width' => 45, 'title' => 'Country', 'title-align' => 'L', 'data-align' => 'L'), array('name' => 'capital', 'width' => 40, 'title' => 'Capital', 'data-align' => 'L'), array('name' => 'area', 'width' => 45, 'title' => 'Area (sq km)', 'title-align' => 'C', 'data-align' => 'R'), array('name' => 'pop', 'width' => 50, 'title' => 'Pop. (thousands)', 'title-align' => 'C', 'data-align' => 'R')), 'data' => 'world_info', 'style' => array('border' => '', 'title-row' => array('height' => 8, 'text-color' => '200, 100, 50'), 'data-row' => array('height' => 8, 'text-color' => '0,0,0')))), 'settings' => array('title' => 'Test PDF', 'author' => 'Rati Wannapanop', 'subject' => 'Test Creating PDF', 'keywords' => 'test pdf fpdf ratiw', 'default-font' => array('name' => 'THSarabun', 'size' => 30)), 'fonts' => array(array('THSarabun', '', 'THSarabun.php'), array('THSarabun', 'B', 'THSarabun Bold.php'), array('THSarabun', 'I', 'THSarabun Italic.php'), array('THSarabun', 'BI', 'THSarabun Bold Italic.php')));
$data = array('name' => 'รติ วรรณภานพ', 'date' => '09/11/2556', 'report_name' => 'World Info Report', 'world_info' => array(array('country' => 'Austria', 'capital' => 'Vienna', 'area' => '83,859', 'pop' => '8,075'), array('country' => 'Belgium', 'capital' => 'Brussels', 'area' => '30,518', 'pop' => '10,192'), array('country' => 'Denmark', 'capital' => 'Copenhagen', 'area' => '43,094', 'pop' => '5,295'), array('country' => 'Finland', 'capital' => 'Helsinki', 'area' => '304,529', 'pop' => '5,147'), array('country' => 'Franch', 'capital' => 'Paris', 'area' => '543,965', 'pop' => '58,728'), array('country' => 'Germany', 'capital' => 'Berlin', 'area' => '357,22', 'pop' => '82,057'), array('country' => 'Greece', 'capital' => 'Athens', 'area' => '131,625', 'pop' => '10,511'), array('country' => 'Ireland', 'capital' => 'Dublin', 'area' => '70,723', 'pop' => '3,694'), array('country' => 'Italy', 'capital' => 'Roma', 'area' => '301,316', 'pop' => '57,563'), array('country' => 'Lunxembourg', 'capital' => 'Luxembourg', 'area' => '2,586', 'pop' => '424'), array('country' => 'Netherlands', 'capital' => 'Amsterdam', 'area' => '41,526', 'pop' => '15,654'), array('country' => 'Portugal', 'capital' => 'Lisbon', 'area' => '91,906', 'pop' => '9,957'), array('country' => 'Spain', 'capital' => 'Madrid', 'area' => '504,790', 'pop' => '39,348'), array('country' => 'Sweden', 'capital' => 'Stockholm', 'area' => '410,934', 'pop' => '8,839'), array('country' => 'United Kingdom', 'capital' => 'London', 'area' => '243,820', 'pop' => '58,862'), array('country' => 'Austria', 'capital' => 'Vienna', 'area' => '83,859', 'pop' => '8,075'), array('country' => 'Belgium', 'capital' => 'Brussels', 'area' => '30,518', 'pop' => '10,192'), array('country' => 'Denmark', 'capital' => 'Copenhagen', 'area' => '43,094', 'pop' => '5,295'), array('country' => 'Finland', 'capital' => 'Helsinki', 'area' => '304,529', 'pop' => '5,147'), array('country' => 'Franch', 'capital' => 'Paris', 'area' => '543,965', 'pop' => '58,728'), array('country' => 'Germany', 'capital' => 'Berlin', 'area' => '357,22', 'pop' => '82,057'), array('country' => 'Greece', 'capital' => 'Athens', 'area' => '131,625', 'pop' => '10,511'), array('country' => 'Ireland', 'capital' => 'Dublin', 'area' => '70,723', 'pop' => '3,694'), array('country' => 'Italy', 'capital' => 'Roma', 'area' => '301,316', 'pop' => '57,563'), array('country' => 'Lunxembourg', 'capital' => 'Luxembourg', 'area' => '2,586', 'pop' => '424'), array('country' => 'Netherlands', 'capital' => 'Amsterdam', 'area' => '41,526', 'pop' => '15,654'), array('country' => 'Portugal', 'capital' => 'Lisbon', 'area' => '91,906', 'pop' => '9,957'), array('country' => 'Spain', 'capital' => 'Madrid', 'area' => '504,790', 'pop' => '39,348'), array('country' => 'Sweden', 'capital' => 'Stockholm', 'area' => '410,934', 'pop' => '8,839'), array('country' => 'United Kingdom', 'capital' => 'London', 'area' => '243,820', 'pop' => '58,862'), array('country' => 'Austria', 'capital' => 'Vienna', 'area' => '83,859', 'pop' => '8,075'), array('country' => 'Belgium', 'capital' => 'Brussels', 'area' => '30,518', 'pop' => '10,192'), array('country' => 'Denmark', 'capital' => 'Copenhagen', 'area' => '43,094', 'pop' => '5,295'), array('country' => 'Finland', 'capital' => 'Helsinki', 'area' => '304,529', 'pop' => '5,147'), array('country' => 'Franch', 'capital' => 'Paris', 'area' => '543,965', 'pop' => '58,728'), array('country' => 'Germany', 'capital' => 'Berlin', 'area' => '357,22', 'pop' => '82,057'), array('country' => 'Greece', 'capital' => 'Athens', 'area' => '131,625', 'pop' => '10,511'), array('country' => 'Ireland', 'capital' => 'Dublin', 'area' => '70,723', 'pop' => '3,694'), array('country' => 'Italy', 'capital' => 'Roma', 'area' => '301,316', 'pop' => '57,563'), array('country' => 'Lunxembourg', 'capital' => 'Luxembourg', 'area' => '2,586', 'pop' => '424'), array('country' => 'Netherlands', 'capital' => 'Amsterdam', 'area' => '41,526', 'pop' => '15,654'), array('country' => 'Portugal', 'capital' => 'Lisbon', 'area' => '91,906', 'pop' => '9,957'), array('country' => 'Spain', 'capital' => 'Madrid', 'area' => '504,790', 'pop' => '39,348'), array('country' => 'Sweden', 'capital' => 'Stockholm', 'area' => '410,934', 'pop' => '8,839'), array('country' => 'United Kingdom', 'capital' => 'London', 'area' => '243,820', 'pop' => '58,862')));
$pdf = new ratiw\JsonPDF\JsonPDF('P', 'mm', 'A4');
$pdf->make(json_encode($document), json_encode($data));
$pdf->render();
Пример #3
0
<?php

// use these require statements if you point your http server directly to this folder.
require "../Fpdf.php";
require "../JsonPDF.php";
// use this require statement instead if you install JsonPDF via composer
// and comment out the above require statements.
//require 'vendor/autoload.php';
$document = array('body' => array(array('type' => 'text', 'width' => 40, 'height' => 10, 'text' => 'Hello World!', 'font' => 'Arial', 'font-style' => 'B', 'font-size' => 16), array('type' => 'text', 'text' => 'Hi, there!')));
$pdf = new ratiw\JsonPDF\JsonPDF('P', 'mm', 'A4');
$pdf->make(json_encode($document));
$pdf->render();
Пример #4
0
<?php

// use these require statements if you point your http server directly to this folder.
require "../Fpdf.php";
require "../JsonPDF.php";
// use this require statement instead if you install JsonPDF via composer
// and comment out the above require statements.
//require 'vendor/autoload.php';
$data = array('header' => array(array('type' => 'image', 'url' => 'img/logo.gif', 'x' => 10, 'y' => 10, 'width' => 20), array('type' => 'text', 'text' => 'Country Data', 'font' => 'THSarabun', 'font-style' => 'B', 'font-size' => 26, 'y' => 13, 'align' => 'R'), array('type' => 'text', 'text' => 'World Infomation Corp.', 'font' => 'THSarabun', 'font-style' => 'b', 'font-size' => 22, 'x' => 33, 'y' => 13, 'width' => 80), array('type' => 'text', 'text' => 'All the information at your reach.', 'font' => 'THSarabun', 'font-size' => 16, 'x' => 33, 'y' => 20, 'width' => 80), array('type' => 'line', 'x1' => 10, 'y1' => 28, 'draw-color' => '100')), 'footer' => array(array('type' => 'text', 'y' => -15, 'width' => 0, 'height' => 10, 'font' => 'Arial', 'font-style' => 'I', 'font-size' => 8, 'draw-color' => '0,0,0', 'text' => 'Page {page}/{nb}', 'border' => 'T', 'align' => 'C')), 'body' => array(array('type' => 'text', 'x' => 10, 'y' => 20, 'multiline' => true, 'font' => 'THSarabun', 'font-size' => 20, 'text' => 'Hello, {name}. Today is {date}', 'align' => 'L', 'y' => 35, 'width' => 150, 'height' => 10, 'text-color' => '0,0,0', 'fill-color' => '255,125,125'), array('type' => 'table-header', 'y' => 90, 'table' => 'world_info_table'), array('type' => 'tableBody', 'table' => 'world_info_table'), array('type' => 'line', 'x1' => 10, 'y1' => 190, 'x2' => 150, 'y2' => 190, 'draw-color' => '255,128,128'), array('type' => 'rect', 'x' => 10, 'y' => 60, 'width' => 50, 'height' => 20, 'draw-color' => '255,128,128'), array('type' => 'text', 'multiline' => true, 'x' => 10, 'y' => 200, 'font' => 'THSarabun', 'font-size' => 16, 'text' => "Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Typi non habent claritatem insitam; est usus legentis in iis qui facit eorum claritatem. Investigationes demonstraverunt lectores legere me lius quod ii legunt saepius. Claritas est etiam processus dynamicus, qui sequitur mutationem consuetudium lectorum. Mirum est notare quam littera gothica, quam nunc putamus parum claram, anteposuerit litterarum formas humanitatis per seacula quarta decima et quinta decima. Eodem modo typi, qui nunc nobis videntur parum clari, fiant sollemnes in futurum.", 'align' => 'L', 'width' => 180, 'height' => 8)), 'tables' => array('world_info_table' => array('max-rows' => 10, 'columns' => array(array('name' => 'country', 'width' => 45, 'title' => 'Country', 'title-align' => 'L', 'data-align' => 'L'), array('name' => 'capital', 'width' => 40, 'title' => 'Capital', 'data-align' => 'L'), array('name' => 'area', 'width' => 45, 'title' => 'Area (sq km)', 'title-align' => 'C', 'data-align' => 'R'), array('name' => 'pop', 'width' => 50, 'title' => 'Pop. (thousands)', 'title-align' => 'C', 'data-align' => 'R')), 'data' => 'world_info', 'style' => array('border-color' => '50,55,200', 'title-row' => array('text-color' => '200, 100, 50', 'fill-color' => '100,50,50'), 'data-row' => array('height' => 8, 'text-color' => '0,0,0', 'fill-color' => '224,235,255', 'striped' => true)))), 'settings' => array('title' => 'Test PDF', 'author' => 'Rati Wannapanop', 'subject' => 'Test Creating PDF', 'keywords' => 'test pdf fpdf ratiw', 'default-font' => array('name' => 'THSarabun', 'size' => 30), 'header-height' => 30), 'fonts' => array(array('THSarabun', '', 'THSarabun.php'), array('THSarabun', 'B', 'THSarabun Bold.php'), array('THSarabun', 'I', 'THSarabun Italic.php'), array('THSarabun', 'BI', 'THSarabun Bold Italic.php')), 'data' => array('name' => 'Rati', 'date' => date('l jS \\of F Y h:i:s A'), 'world_info' => array(array('country' => 'Austria', 'capital' => 'Vienna', 'area' => '83,859', 'pop' => '8,075'), array('country' => 'Belgium', 'capital' => 'Brussels', 'area' => '30,518', 'pop' => '10,192'), array('country' => 'Denmark', 'capital' => 'Copenhagen', 'area' => '43,094', 'pop' => '5,295'), array('country' => 'Finland', 'capital' => 'Helsinki', 'area' => '304,529', 'pop' => '5,147'), array('country' => 'Franch', 'capital' => 'Paris', 'area' => '543,965', 'pop' => '58,728'), array('country' => 'Germany', 'capital' => 'Berlin', 'area' => '357,22', 'pop' => '82,057'))));
$pdf = new ratiw\JsonPDF\JsonPDF('P', 'mm', 'A4');
$pdf->make(json_encode($data));
$pdf->render();