<?php
require_once('tcpdf.php');
class MYPDFO extends TCPDF {

    //Page header
    public function Header() {
        if(isset($_GET['pad'])){
            $this->Image('logo.png',165,10,0, 15, 'PNG', 'https://www.codewareltd.com');
        }
        //            $style = array('width' => 0.5, 'cap' => 'square', 'join' => 'miter', 'dash' => 0, 'phase' => 0, 'color' => array(0,205,50));
    }
    // Page footer
    public function Footer() {

    }

    public function CreateTextBox($textval, $x = 0, $y, $width = 0, $height = 10, $fontsize = 8, $fontstyle = '', $align = 'L') {
        $this->SetXY($x+20, $y); // 20 = margin left
        $this->SetFont(PDF_FONT_NAME_MAIN, $fontstyle, $fontsize);
        $this->Cell($width, $height, $textval, 0, false, $align);
    }

}

$pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('ABDUS SALAM');
$pdf->SetTitle('PDF Try');
$pdf->SetSubject('Unique CRM');
$pdf->SetKeywords('Unique CRM , optimal');

$pdf->SetMargins(20, 30, PDF_MARGIN_RIGHT);

$pdf->SetAutoPageBreak(TRUE, 45);

$pdf->AddPage();

$pdf->Ln(10);

// Set font
$pdf->SetFont('helvetica', '', 9);

/*************************************/
/***             TABLE             ***/
/*************************************/

$st=25;
$fs=10;
$pdf->CreateTextBox('Ref No. UBS/93/101.',0,$st,80,10,$fs,'B');
$st+=4;
$pdf->CreateTextBox('Date: 4th October 2014',0,$st,80,10,$fs);
$st+=8;
$pdf->CreateTextBox('Procurement Unit', 0, $st, 80, 10, $fs);
$st+=4;
$pdf->CreateTextBox('American Embassy Dhaka,',0,$st,80,10,$fs);
$st+=4;
$pdf->CreateTextBox('Bangladesh',0,$st,80,10,$fs);
$st+=4;
$pdf->CreateTextBox('E-mail: DordanaSX@state.gov',0,$st,80,10,$fs);
$st+=8;
$pdf->CreateTextBox('Contact: Ms.Sohana Dordana',0,$st,80,10,$fs);
$st+=8;
$pdf->CreateTextBox('Sub:',0,$st,80,10,$fs);
$pdf->CreateTextBox('Quotation for Apollo Motorized Screen',8,$st,80,10,$fs,'BU');
$st+=8;
$pdf->CreateTextBox('Dear Sir,',0,$st,80,10,$fs);
$st+=8;
$pdf->CreateTextBox('With Reference to your recent inquiry regarding the Motorized screen dated 4th October 2009, Unique',0,$st,80,10,$fs);
$st+=4;
$pdf->CreateTextBox('Systems would like to express our sincere gratitude for showing the interest on our product.',0,$st,80,10,$fs);
$st+=8;
$pdf->CreateTextBox('You will be pleased to know that Unique Business Systems is the authorized distributor of Apollo',0,$st,80,10,$fs);
$st+=4;
$pdf->CreateTextBox('Presentation Ltd. Unique Business Systems is having 60% market share in the training equipment for last ',0,$st,80,10,$fs);
$st+=4;
$pdf->CreateTextBox('15 years.',0,$st,80,10,$fs);
$st+=8;
$pdf->CreateTextBox('With reference to your recent inquiry on the above subject. we are pleased to submit our quotation as ',0,$st,80,10,$fs);
$st+=4;
$pdf->CreateTextBox('follows for your kind acceptance:',0,$st,80,10,$fs);

$st+=15;$pdf->CreateTextBox('',0,$st,80,10,$fs);

$w=12;
$x=20;
//This line use for html table set to right place;
$pdf->MultiCell(.5,.5,"",array('LTRB' => array('width' => 2,'color' => array(255,255,255))),'', true, 1, $x, $st, true, 0);
$tbl = 
<<<EOD
    <style type=text/css>
    .sl_no{
        width:35px;
        text-align:left;
    } 
    .invoice_pt{
        width:200px;
        text-align:left;
    }
    .invoice_qt{
        width:50px;
        text-align:right;
    }
    .invoice_up{
        width:80px;
        text-align:right;
    }
    .invoice_tp{
        width:75px;
        text-align:right;
    }
    </style>
<table class="invoice_main" border="1" align="center" cellspacing="0" cellpadding="60%">
    <tr>
    <th class="sl_no">Sl.No.</th>
    <th class="invoice_pt">Particulars</th>
    <th class="invoice_qt">Qty</th>
    <th class="invoice_up">Unit Price<br> (Tk.)</th>
    <th class="invoice_tp">Total Price<br> (Tk.)</th>
    </tr>
   
    
EOD;

for($i=0;$i<10;$i++){

    $tbl.=<<<eod
    <tr nobr="true">
    <td class="sl_no">01</td>
    <td class="invoice_pt">
    Motorized Projection Screen:<br>
    Brand: Apollo, Size: 70" x 70"<br>
    Type: Tripod, Made in USA<br>
    Remote controller<br>
    Input power: 220 volt and 50 hz.
    </td>
    <td class="invoice_qt">01</td>
    <td class="invoice_up">
    <strong>18,500.00</strong><br>
    (Eighteen thousand five hundred only)
    </td>
    <td class="invoice_tp">
    <strong>18,500.00</strong><br>
    (Eighteen thousand five hundred only)
    </td>
    </tr>
eod;
}

$tbl.=<<<eod
    
    <tr>
    <td>&nbsp;</td>
    <td colspan="3" style="text-align:right;">
    <strong>Total Price = </strong>
    </td>
    <td style="text-align:right;">
    37,000.00
    </td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td colspan="3" style="text-align:right;">
    <strong>Total Price in Word = </strong>
    </td>
    <td style="text-align:right;">
    37,000.00
    </td>
    </tr>
    </table>
eod;

$pdf->writeHTML($tbl, true, false, true, false, 'L');

//Close and output PDF document
$pdf->Output('test.pdf', 'I');


?>