Skip to content

Commit

Permalink
Better doc
Browse files Browse the repository at this point in the history
  • Loading branch information
f_cellier committed Jan 11, 2017
1 parent 9f4d9ec commit a86db2a
Show file tree
Hide file tree
Showing 10 changed files with 1,233 additions and 48 deletions.
13 changes: 13 additions & 0 deletions EasyPdfBundle.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
/**
*
* @author: Florian CELLIER <chadyred@gmail.com>
* @license: MI
*
*/
namespace Kark\EasyPdfBundle;

use Symfony\Component\HttpKernel\Bundle\Bundle;

class EasyPdfBundle extends Bundle
{}
12 changes: 4 additions & 8 deletions Lib/Barecode/PDF_Code128.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
<?php

/*******************************************************************************
* Script : PDF_Code128
* Version : 1.2
* Date : 2016-01-31
* Auteur : Roland Gautier
*
* Version Date Detail
* 1.2 2016-01-31 Compatibility with FPDF 1.8
Expand Down Expand Up @@ -39,9 +35,9 @@
* 206 FNC1 FNC1
*******************************************************************************/

namespace lib\barecode;
namespace Kark\EasyPdfBundle\Lib\Barecode;

use lib\DecoratorPdf;
use Kark\EasyPdfBundle\Lib\DecoratorPdf;

class PDF_Code128 extends DecoratorPdf {

Expand All @@ -56,7 +52,7 @@ class PDF_Code128 extends DecoratorPdf {
protected $JSwap = array("A"=>101, "B"=>100, "C"=>99); // Caractères de changement de jeu

//____________________________ Extension du constructeur _______________________
function __construct($pdf=NULL, $orientation='P', $unit='mm', $format='A4') {
public function __construct($pdf, $orientation='P', $unit='mm', $format='A4') {

parent::__construct($pdf,$orientation,$unit,$format);

Expand Down Expand Up @@ -205,7 +201,7 @@ function __construct($pdf=NULL, $orientation='P', $unit='mm', $format='A4') {
}

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

namespace lib\cellfit;
namespace Kark\EasyPdfBundle\Lib\Cellfit;

use lib\DecoratorPdf;
use Kark\EasyPdfBundle\Lib\DecoratorPdf;

class FPDF_CellFit extends DecoratorPdf {

Expand Down
4 changes: 2 additions & 2 deletions Lib/DecoratorPdf.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

namespace lib;
namespace Kark\EasyPdfBundle\Lib;

abstract class DecoratorPdf extends \FPDF {
protected $pdf;

public function __construct (\FPDF $pdf=NULL, $orientation='P', $unit='mm', $size='A4') {
public function __construct (\FPDF $pdf, $orientation='P', $unit='mm', $size='A4') {
parent::__construct ($orientation='P', $unit='mm', $size='A4');
$this->pdf = $pdf;
}
Expand Down
30 changes: 15 additions & 15 deletions Lib/Draw/PDF_Draw.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
*
*/

namespace lib\draw;
namespace Kark\EasyPdfBundle\Lib\Draw;

use lib\DecoratorPdf;
use Kark\EasyPdfBundle\Lib\DecoratorPdf;

class PDF_Draw extends DecoratorPdf {
// Sets line style
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)
function SetLineStyle($style) {
protected function SetLineStyle($style) {
extract($style);
if (isset($width)) {
$width_prev = $this->pdf->LineWidth;
Expand Down Expand Up @@ -63,7 +63,7 @@ function SetLineStyle($style) {
// - x1, y1: Start point
// - x2, y2: End point
// - style: Line style. Array like for SetLineStyle
function Line($x1, $y1, $x2, $y2, $style = null) {
protected 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 @@ 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)
function Rect($x, $y, $w, $h, $style = '', $border_style = null, $fill_color = null) {
protected 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 @@ function Rect($x, $y, $w, $h, $style = '', $border_style = null, $fill_color = n
// - 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)
function Curve($x0, $y0, $x1, $y1, $x2, $y2, $x3, $y3, $style = '', $line_style = null, $fill_color = null) {
protected 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 @@ function Curve($x0, $y0, $x1, $y1, $x2, $y2, $x3, $y3, $style = '', $line_style
// - 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
function Ellipse($x0, $y0, $rx, $ry = 0, $angle = 0, $astart = 0, $afinish = 360, $style = '', $line_style = null, $fill_color = null, $nSeg = 8) {
protected 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 @@ function Ellipse($x0, $y0, $rx, $ry = 0, $angle = 0, $astart = 0, $afinish = 360
// - 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
function Circle($x0, $y0, $r, $astart = 0, $afinish = 360, $style = '', $line_style = null, $fill_color = null, $nSeg = 8) {
protected 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 @@ function Circle($x0, $y0, $r, $astart = 0, $afinish = 360, $style = '', $line_st
// . 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)
function Polygon($p, $style = '', $line_style = null, $fill_color = null) {
protected 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 @@ function Polygon($p, $style = '', $line_style = null, $fill_color = null) {
// - 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)
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) {
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) {
if ($ns < 3)
$ns = 3;
if ($circle)
Expand Down Expand Up @@ -360,7 +360,7 @@ function RegularPolygon($x0, $y0, $r, $ns, $angle = 0, $circle = false, $style =
// - 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)
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) {
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) {
if ($nv < 2)
$nv = 2;
if ($circle)
Expand Down Expand Up @@ -395,7 +395,7 @@ function StarPolygon($x0, $y0, $r, $nv, $ng, $angle = 0, $circle = false, $style
// - 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)
function RoundedRect($x, $y, $w, $h, $r, $round_corner = '1111', $style = '', $border_style = null, $fill_color = null) {
protected 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 @@ function RoundedRect($x, $y, $w, $h, $r, $round_corner = '1111', $style = '', $b
// Sets a draw point
// Parameters:
// - x, y: Point
function _Point($x, $y) {
private 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
function _Line($x, $y) {
private 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 @@ function _Line($x, $y) {
// - x1, y1: Control point 1
// - x2, y2: Control point 2
// - x3, y3: End point
function _Curve($x1, $y1, $x2, $y2, $x3, $y3) {
private 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 a86db2a

Please sign in to comment.