44 lines
936 B
PHP
44 lines
936 B
PHP
<?php
|
|
|
|
namespace App\Libraries\Pdf;
|
|
|
|
require_once APPPATH . 'ThirdParty/FPDF/fpdf.php';
|
|
|
|
class MyFPDF extends \FPDF
|
|
{
|
|
protected $angle = 0;
|
|
|
|
function Rotate($angle, $x = -1, $y = -1)
|
|
{
|
|
if ($x == -1) $x = $this->x;
|
|
if ($y == -1) $y = $this->y;
|
|
|
|
if ($this->angle != 0) {
|
|
$this->_out('Q');
|
|
}
|
|
|
|
$this->angle = $angle;
|
|
|
|
if ($angle != 0) {
|
|
$angle *= M_PI / 180;
|
|
$c = cos($angle);
|
|
$s = sin($angle);
|
|
|
|
$cx = $x * $this->k;
|
|
$cy = ($this->h - $y) * $this->k;
|
|
|
|
$this->_out(sprintf(
|
|
'q %.5F %.5F %.5F %.5F %.5F %.5F cm 1 0 0 1 %.5F %.5F cm',
|
|
$c, $s, -$s, $c, $cx, $cy, -$cx, -$cy
|
|
));
|
|
}
|
|
}
|
|
|
|
function RotatedText($x, $y, $txt, $angle)
|
|
{
|
|
$this->Rotate($angle, $x, $y);
|
|
$this->Text($x, $y, $txt);
|
|
$this->Rotate(0);
|
|
}
|
|
}
|