<?php

class EKPDF extends TCPDF {

    //Page header
    public function Header() {       
        
    }

    // Page footer
    public function Footer() {
        // Position at 15 mm from bottom
        $this->SetY(-15);
        // Set font
        $this->SetFont('helvetica', 'I', 8);
        // Page number
        $this->Cell(0,5, t('Page') . ' ' . $this->getAliasNumPage() . '/' . $this->getAliasNbPages(), 0, 1, 'R');
    }
}

// create new PDF document
$pdf = new EKPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

// set document information
$pdf->SetCreator('EK');
$pdf->SetAuthor(\Drupal::currentUser()->getAccountName());
$pdf->SetTitle($fileName);
$pdf->SetSubject(t('Bank label'));

// set default header data
$pdf->SetHeaderData();

// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);

// set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);

// set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);

// set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);

$pdf->AddPage('P','A4');
$pdf->SetMargins(20,5);

$pdf->SetDrawColor(128, 128, 128); 
$pdf->SetLineStyle(array('width' => 0.1, 'color' => array(130,130,130)));    

//DISPLAY DATA simple

//left right corners
    $pdf->Cell(5);
    $pdf->Cell(5,3,"","LT",0);
    $pdf->Cell(100,3,"",0,0); 
    $pdf->Cell(5,3,"","RT",1);
    
$pdf->SetFont('helvetica','',10);   
    
    $pdf->Cell(9,5,"",0,0);    
    $pdf->MultiCell(100,5, $bank->name ,0,'L');
    $pdf->Cell(5,5,"",0,1);    
$pdf->SetFont('helvetica','',8); 
    $pdf->Cell(9,5,"",0,0);    
    $pdf->Cell(100,5, $bank->address1 ,0,0);
    $pdf->Cell(1,5,"",0,1);   
    if(isset($bank->address2)){
        $pdf->Cell(9,5,"",0,0);    
        $pdf->Cell(100,5, $bank->address2,0,0);
        $pdf->Cell(1,5,"",0,1); 
    }
    $pdf->Cell(9,5,"",0,0);       
    $pdf->Cell(100,5, $bank->postcode . ' ' .  $bank->country ,0,0);         
    $pdf->Cell(1,5,"",0,1);   
         
    $pdf->ln(2);  

$pdf->SetFont('helvetica','',10); 
    $pdf->Cell(9,5,"",0,0);       
    $pdf->Cell(30,5, t('account') ,0,0); 
    $pdf->Cell(70,5, $bank->account_ref ,0,0); 
    $pdf->Cell(1,5,"",0,1);    

    if(!NULL == $bank->beneficiary) {
        $text = $bank->beneficiary;
    } else {
        $text = $bank->company;
    }
    $pdf->Cell(9,5,"",0,0);
    $pdf->Cell(30,5, t('beneficiary') ,0,0); 
    $pdf->MultiCell(70,5, $text ,0,'L');            
    $pdf->Cell(1,5,"",0,1);
    
    $pdf->Cell(9,5,"",0,0);
    $pdf->Cell(30,5, t('currency') ,0,0); 
    $pdf->Cell(70,5, $bank->currency ,0,0);         
    $pdf->Cell(1,5,"",0,1); 

    $pdf->Cell(9,5,"",0,0);
    $pdf->Cell(30,5, t('bank code') ,0,0); 
    $pdf->Cell(70,5, $bank->bank_code ,0,0);            
    $pdf->Cell(1,5,"",0,1);  
    $pdf->Cell(9,5,"",0,0);
    $pdf->Cell(30,5, t('swift') ,0,0); 
    $pdf->Cell(70,5, $bank->swift ,0,0);            
    $pdf->Cell(1,5,"",0,1);    
    
//left right corners
    $pdf->Cell(5,3,"","LB",0);
    $pdf->Cell(100,3,"",0,0); 
    $pdf->Cell(5,3,"","RB",1);





