Skip to content

Commit

Permalink
Added methods that can write encoded output.
Browse files Browse the repository at this point in the history
  • Loading branch information
rudissaar committed Dec 28, 2017
1 parent a69fd98 commit 428f36d
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
26 changes: 26 additions & 0 deletions FPDFPlus.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@

class FPDFPlus extends FPDF
{
/**
*
* @param float|null $height
* @param string $text
* @param string $link
* @param string $encoding
*/
public function WriteEncoded($height, $text, $link = '', $encoding = 'UTF-8')
{
$encodedText = iconv($encoding, 'windows-1252', $text);
$this->Write($height, $encodedText, $link);
}

/**
*
* @param float|null $height
Expand All @@ -18,6 +31,19 @@ public function WriteLn($height, $text, $link = '')
$this->Ln();
}

/**
*
* @param float|null $height
* @param string $text
* @param string $link
* @param string $encoding
*/
public function WriteLnEncoded($height, $text, $link = '', $encoding = 'UTF-8')
{
$encodedText = iconv($encoding, 'windows-1252', $text);
$this->WriteLn($height, $encodedText, $link);
}

/**
*
* @param float|null $height
Expand Down
27 changes: 26 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ FPDF plugin and wrapper for Yii2 framework.

### FPDF

`FPDF` is copy of [FPDF](http://www.fpdf.org/) class and it has all methods and properties like original one.
`FPDF` is copy of [FPDF](http://www.fpdf.org/) class and it has all methods and properties like original one.
To include FPDF class add following line to your PHP file:

`use rudissaar\fpdf\FPDF;`
Expand All @@ -31,6 +31,31 @@ $pdf->Output('F', '/tmp/hello.pdf');
...
```
### FPDFPlus (enchanted class)

This package comes with extra methods that can be very useful for you.

View source: [FPDFPlus](https://github.com/rudissaar/yii2-fpdf/blob/master/FPDFPlus.php)

#### Basic usage
```
<?php
...
use rudissaar\fpdf\FPDFPlus;
...
$pdf = new FPDFPlus();
$pdf->AddPage();
$pdf->SetFont('Arial', 'B', 15);
$pdf->WriteLnEncoded(10, 'Apple: £10');
$pdf->Output('F', '/tmp/price.pdf');
...
```


## Reference Manual

Expand Down

0 comments on commit 428f36d

Please sign in to comment.