Revision #219                                    has been created by  rackycz                                    on Aug 5, 2020, 11:21:05 AM with the memo:
 rackycz                                    on Aug 5, 2020, 11:21:05 AM with the memo:
                                
                                
                                    FPDF                                
                                                                    « previous (#218)                                                                                                    next (#220) »                                                            
                            Changes
                            
    Title
    unchanged
    Yii v2 snippet guide
    Category
    unchanged
    Tutorials
    Yii version
    unchanged
    2.0
    Tags
    unchanged
    tutorial,beginner,yii2
    Content
    changed
    [...]
Summary: 
- Download tFPDF and unpack it.
- use file **tfpdf.php** and folder **font** .. it contains file **ttfonts.php** !!
- Into both mentioned php files add the namespace you are using for your helpers. 
- Do other modifications needed to use it as a Helper. Explained above.
 
 
tFPDF example:
 
 
```php
 
$pdf = new tFPDF();
 
 
$pdf->AddFont('DejaVu','','DejaVuSansCondensed.ttf',true);
 
$pdf->AddFont('DejaVu','B','DejaVuSansCondensed-Bold.ttf',true);
 
$pdf->SetFont('DejaVu','',10);
 
 
$pageWidth = 210;
 
$pageMargin = 10;
 
$maxContentW = $pageWidth - 2*$pageMargin; // = max width of an element
 
 
$pdf->SetAutoPageBreak(true, 0);
 
$pdf->SetMargins($pageMargin, $pageMargin, $pageMargin);
 
$pdf->SetAutoPageBreak(true, $pageMargin);
 
 
// Settings for tables:
 
$pdf->SetLineWidth(0.2);
 
$pdf->SetDrawColor(0, 0, 0);
 
 
$pdf->AddPage();
 
/ $pdf->SetFontSize(8);
 
 
$displayBorders = 1;
 
$valueAlign = "L";
 
$labelAlign = "L";
 
 
$usedHeight = 0;
 
 
// Logo on the 1st line
 
$pdf->SetY($pageMargin);
 
$pdf->SetX($pageMargin);
 
$logoPath = '../tesla.png';
 
$imgWidth = 10;
 
$headerHeight = 10;
 
$pdf->Image($logoPath, null, null, $imgWidth, $headerHeight);
 
 
$pdf->SetY($pageMargin);
 
$pdf->SetX($pageMargin+$imgWidth);
 
$pdf->Cell($maxContentW-$imgWidth, $headerHeight, 'Non English chars: ěščřžýáíéúů', $displayBorders, 0, 'C', false);
 
 
$usedHeight+= $headerHeight;
 
$usedHeight+=10;
 
        
 
$pdf->SetY($pageMargin);
 
$pdf->SetX($pageMargin+$imgWidth);
 
$pdf->Cell($maxContentW-$imgWidth, 10, 'Non English chars: ěščřžýáíéúů', $displayBorders, 0, 'C', false);
 
 
$pdf->SetY($pageMargin + $usedHeight);
 
$pdf->SetX($pageMargin);
 
$pdf->Cell(30, 10, 'Customer number:', $displayBorders, 0, 'R', false);
 
 
$pdf->SetFont('DejaVu','B',14);
 
 
$pdf->SetY($pageMargin + $usedHeight);
 
$pdf->SetX($pageMargin + 30);
 
$pdf->Cell(20, 10, 'ABC123', $displayBorders, 0, 'L', false);
 
 
$pdf->Output('D', 'hello.pdf');
 
```