Skip to content

Commit

Permalink
Merge pull request #14 from chadyred/lib
Browse files Browse the repository at this point in the history
Lib
  • Loading branch information
Florian C authored Jan 13, 2017
2 parents 6df4f67 + c1a41af commit ddc9afd
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 1,103 deletions.
4 changes: 2 additions & 2 deletions Lib/Barecode/PDF_Code128.php → Lib/Barecode/PdfCode128.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

use Kark\EasyPdfBundle\Lib\DecoratorPdf;

class PDF_Code128 extends DecoratorPdf {
class PdfCode128 extends DecoratorPdf {

protected $T128; // Tableau des codes 128
protected $ABCset = ""; // jeu des caractères éligibles au C128
Expand Down Expand Up @@ -201,7 +201,7 @@ public function __construct($pdf, $orientation='P', $unit='mm', $format='A4') {
}

//________________ Fonction encodage et dessin du code 128 _____________________
public protected function Code128($x, $y, $code, $w, $h) {
public function Code128($x, $y, $code, $w, $h) {
$Aguid = ""; // Création des guides de choix ABC
$Bguid = "";
$Cguid = "";
Expand Down
14 changes: 7 additions & 7 deletions Lib/Cellfit/FPDF_CellFit.php → Lib/Cellfit/FpdfCellfit.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

use Kark\EasyPdfBundle\Lib\DecoratorPdf;

class FPDF_CellFit extends DecoratorPdf {
class FpdfCellfit extends DecoratorPdf {

//Cell with horizontal scaling if text is too wide
function CellFit($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='', $scale=false, $force=true)
public function CellFit($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='', $scale=false, $force=true)
{
//Get string width
$str_width=$this->pdf->GetStringWidth($txt);
Expand Down Expand Up @@ -48,32 +48,32 @@ function CellFit($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $l
}

//Cell with horizontal scaling only if necessary
function CellFitScale($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='')
public function CellFitScale($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='')
{
$this->CellFit($w,$h,$txt,$border,$ln,$align,$fill,$link,true,false);
}

//Cell with horizontal scaling always
function CellFitScaleForce($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='')
public function CellFitScaleForce($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='')
{
$this->CellFit($w,$h,$txt,$border,$ln,$align,$fill,$link,true,true);
}

//Cell with character spacing only if necessary
function CellFitSpace($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='')
public function CellFitSpace($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='')
{
$this->CellFit($w,$h,$txt,$border,$ln,$align,$fill,$link,false,false);
}

//Cell with character spacing always
function CellFitSpaceForce($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='')
public function CellFitSpaceForce($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='')
{
//Same as calling CellFit directly
$this->CellFit($w,$h,$txt,$border,$ln,$align,$fill,$link,false,true);
}

//Patch to also work with CJK double-byte text
function MBGetStringLength($s)
public function MBGetStringLength($s)
{
if($this->CurrentFont['type']=='Type0')
{
Expand Down
28 changes: 14 additions & 14 deletions Lib/Draw/PDF_Draw.php → Lib/Draw/PdfDraw.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

use Kark\EasyPdfBundle\Lib\DecoratorPdf;

class PDF_Draw extends DecoratorPdf {
class PdfDraw extends DecoratorPdf {
// Sets line style
// Parameters:
// - style: Line style. Array with keys among the following:
Expand All @@ -20,7 +20,7 @@ class PDF_Draw extends DecoratorPdf {
// (2,1) is 2 on, 1 off, 2 on, 1 off.. etc
// . phase: Modifier of the dash pattern which is used to shift the point at which the pattern starts
// . color: Draw color. Array with components (red, green, blue)
protected function SetLineStyle($style) {
public function SetLineStyle($style) {
extract($style);
if (isset($width)) {
$width_prev = $this->pdf->LineWidth;
Expand Down Expand Up @@ -63,7 +63,7 @@ protected function SetLineStyle($style) {
// - x1, y1: Start point
// - x2, y2: End point
// - style: Line style. Array like for SetLineStyle
protected function Line($x1, $y1, $x2, $y2, $style = null) {
public function Line($x1, $y1, $x2, $y2, $style = null) {
if ($style)
$this->SetLineStyle($style);
$this->pdf->Line($x1, $y1, $x2, $y2);
Expand All @@ -81,7 +81,7 @@ protected function Line($x1, $y1, $x2, $y2, $style = null) {
// . R: Line style of right border. null (no border) or array like for SetLineStyle
// . B: Line style of bottom border. null (no border) or array like for SetLineStyle
// - fill_color: Fill color. Array with components (red, green, blue)
protected function Rect($x, $y, $w, $h, $style = '', $border_style = null, $fill_color = null) {
public function Rect($x, $y, $w, $h, $style = '', $border_style = null, $fill_color = null) {
if (!(false === strpos($style, 'F')) && $fill_color) {
list($r, $g, $b) = $fill_color;
$this->pdf->SetFillColor($r, $g, $b);
Expand Down Expand Up @@ -132,7 +132,7 @@ protected function Rect($x, $y, $w, $h, $style = '', $border_style = null, $fill
// - style: Style of rectangule (draw and/or fill: D, F, DF, FD)
// - line_style: Line style for curve. Array like for SetLineStyle
// - fill_color: Fill color. Array with components (red, green, blue)
protected function Curve($x0, $y0, $x1, $y1, $x2, $y2, $x3, $y3, $style = '', $line_style = null, $fill_color = null) {
public function Curve($x0, $y0, $x1, $y1, $x2, $y2, $x3, $y3, $style = '', $line_style = null, $fill_color = null) {
if (!(false === strpos($style, 'F')) && $fill_color) {
list($r, $g, $b) = $fill_color;
$this->pdf->SetFillColor($r, $g, $b);
Expand Down Expand Up @@ -168,7 +168,7 @@ protected function Curve($x0, $y0, $x1, $y1, $x2, $y2, $x3, $y3, $style = '', $l
// - line_style: Line style for ellipse. Array like for SetLineStyle
// - fill_color: Fill color. Array with components (red, green, blue)
// - nSeg: Ellipse is made up of nSeg Bézier curves
protected function Ellipse($x0, $y0, $rx, $ry = 0, $angle = 0, $astart = 0, $afinish = 360, $style = '', $line_style = null, $fill_color = null, $nSeg = 8) {
public function Ellipse($x0, $y0, $rx, $ry = 0, $angle = 0, $astart = 0, $afinish = 360, $style = '', $line_style = null, $fill_color = null, $nSeg = 8) {
if ($rx) {
if (!(false === strpos($style, 'F')) && $fill_color) {
list($r, $g, $b) = $fill_color;
Expand Down Expand Up @@ -254,7 +254,7 @@ protected function Ellipse($x0, $y0, $rx, $ry = 0, $angle = 0, $astart = 0, $afi
// - line_style: Line style for circle. Array like for SetLineStyle
// - fill_color: Fill color. Array with components (red, green, blue)
// - nSeg: Ellipse is made up of nSeg Bézier curves
protected function Circle($x0, $y0, $r, $astart = 0, $afinish = 360, $style = '', $line_style = null, $fill_color = null, $nSeg = 8) {
public function Circle($x0, $y0, $r, $astart = 0, $afinish = 360, $style = '', $line_style = null, $fill_color = null, $nSeg = 8) {
$this->Ellipse($x0, $y0, $r, 0, 0, $astart, $afinish, $style, $line_style, $fill_color, $nSeg);
}

Expand All @@ -266,7 +266,7 @@ protected function Circle($x0, $y0, $r, $astart = 0, $afinish = 360, $style = ''
// . all: Line style of all lines. Array like for SetLineStyle
// . 0..np-1: Line style of each line. Item is 0 (not line) or like for SetLineStyle
// - fill_color: Fill color. Array with components (red, green, blue)
protected function Polygon($p, $style = '', $line_style = null, $fill_color = null) {
public function Polygon($p, $style = '', $line_style = null, $fill_color = null) {
$np = count($p) / 2;
if (!(false === strpos($style, 'F')) && $fill_color) {
list($r, $g, $b) = $fill_color;
Expand Down Expand Up @@ -329,7 +329,7 @@ protected function Polygon($p, $style = '', $line_style = null, $fill_color = nu
// - circle_style: Style of circumscribed circle (draw and/or fill) (D, F, DF, FD) (if draw)
// - circle_line_style: Line style for circumscribed circle. Array like for SetLineStyle (if draw)
// - circle_fill_color: Fill color for circumscribed circle. Array with components (red, green, blue) (if draw fill circle)
protected function RegularPolygon($x0, $y0, $r, $ns, $angle = 0, $circle = false, $style = '', $line_style = null, $fill_color = null, $circle_style = '', $circle_line_style = null, $circle_fill_color = null) {
public function RegularPolygon($x0, $y0, $r, $ns, $angle = 0, $circle = false, $style = '', $line_style = null, $fill_color = null, $circle_style = '', $circle_line_style = null, $circle_fill_color = null) {
if ($ns < 3)
$ns = 3;
if ($circle)
Expand Down Expand Up @@ -360,7 +360,7 @@ protected function RegularPolygon($x0, $y0, $r, $ns, $angle = 0, $circle = false
// - circle_style: Style of circumscribed circle (draw and/or fill) (D, F, DF, FD) (if draw)
// - circle_line_style: Line style for circumscribed circle. Array like for SetLineStyle (if draw)
// - circle_fill_color: Fill color for circumscribed circle. Array with components (red, green, blue) (if draw fill circle)
protected function StarPolygon($x0, $y0, $r, $nv, $ng, $angle = 0, $circle = false, $style = '', $line_style = null, $fill_color = null, $circle_style = '', $circle_line_style = null, $circle_fill_color = null) {
public function StarPolygon($x0, $y0, $r, $nv, $ng, $angle = 0, $circle = false, $style = '', $line_style = null, $fill_color = null, $circle_style = '', $circle_line_style = null, $circle_fill_color = null) {
if ($nv < 2)
$nv = 2;
if ($circle)
Expand Down Expand Up @@ -395,7 +395,7 @@ protected function StarPolygon($x0, $y0, $r, $nv, $ng, $angle = 0, $circle = fal
// - style: Style of rectangle (draw and/or fill) (D, F, DF, FD)
// - border_style: Border style of rectangle. Array like for SetLineStyle
// - fill_color: Fill color. Array with components (red, green, blue)
protected function RoundedRect($x, $y, $w, $h, $r, $round_corner = '1111', $style = '', $border_style = null, $fill_color = null) {
public function RoundedRect($x, $y, $w, $h, $r, $round_corner = '1111', $style = '', $border_style = null, $fill_color = null) {
if ('0000' == $round_corner) // Not rounded
$this->Rect($x, $y, $w, $h, $style, $border_style, $fill_color);
else { // Rounded
Expand Down Expand Up @@ -464,14 +464,14 @@ protected function RoundedRect($x, $y, $w, $h, $r, $round_corner = '1111', $styl
// Sets a draw point
// Parameters:
// - x, y: Point
private function _Point($x, $y) {
public function _Point($x, $y) {
$this->pdf->_out(sprintf('%.2F %.2F m', $x * $this->pdf->k, ($this->pdf->h - $y) * $this->pdf->k));
}

// Draws a line from last draw point
// Parameters:
// - x, y: End point
private function _Line($x, $y) {
public function _Line($x, $y) {
$this->pdf->_out(sprintf('%.2F %.2F l', $x * $this->pdf->k, ($this->pdf->h - $y) * $this->pdf->k));
}

Expand All @@ -480,7 +480,7 @@ private function _Line($x, $y) {
// - x1, y1: Control point 1
// - x2, y2: Control point 2
// - x3, y3: End point
private function _Curve($x1, $y1, $x2, $y2, $x3, $y3) {
public function _Curve($x1, $y1, $x2, $y2, $x3, $y3) {
$this->pdf->_out(sprintf('%.2F %.2F %.2F %.2F %.2F %.2F c', $x1 * $this->pdf->k, ($this->pdf->h - $y1) * $this->pdf->k, $x2 * $this->pdf->k, ($this->pdf->h - $y2) * $this->pdf->k, $x3 * $this->pdf->k, ($this->pdf->h - $y3) * $this->pdf->k));
}

Expand Down
Loading

0 comments on commit ddc9afd

Please sign in to comment.