diff --git a/Lib/Barecode/PDF_Code128.php b/Lib/Barecode/PdfCode128.php similarity index 99% rename from Lib/Barecode/PDF_Code128.php rename to Lib/Barecode/PdfCode128.php index f89c7af..8b99fa1 100644 --- a/Lib/Barecode/PDF_Code128.php +++ b/Lib/Barecode/PdfCode128.php @@ -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 @@ -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 = ""; diff --git a/Lib/Cellfit/FPDF_CellFit.php b/Lib/Cellfit/FpdfCellfit.php similarity index 73% rename from Lib/Cellfit/FPDF_CellFit.php rename to Lib/Cellfit/FpdfCellfit.php index 29091a0..42fa7d1 100644 --- a/Lib/Cellfit/FPDF_CellFit.php +++ b/Lib/Cellfit/FpdfCellfit.php @@ -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); @@ -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') { diff --git a/Lib/Draw/PDF_Draw.php b/Lib/Draw/PdfDraw.php similarity index 89% rename from Lib/Draw/PDF_Draw.php rename to Lib/Draw/PdfDraw.php index 25885d0..a90c1d2 100644 --- a/Lib/Draw/PDF_Draw.php +++ b/Lib/Draw/PdfDraw.php @@ -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: @@ -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; @@ -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); @@ -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); @@ -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); @@ -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; @@ -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); } @@ -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; @@ -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) @@ -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) @@ -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 @@ -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)); } @@ -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)); } diff --git a/Resources/doc/installation.html b/Resources/doc/installation.html deleted file mode 100644 index 10bb9ed..0000000 --- a/Resources/doc/installation.html +++ /dev/null @@ -1,1067 +0,0 @@ -installation

Installation

-

Symfony 3. or 2.

-

Require the bundle in your composer.json file:

-
{
-    "require": {
-        "chadyred/fpdf-fpdi-symfony2": "dev-master",
-    }
-}
-
- -

Instance it on your Kernel

-

Open your app/AppKernel.php and instance it like this

-
<?php
-// app/AppKernel.php
-
-public function registerBundles()
-{
-    $bundles = array(
-        // ...
-        new Kark\EasyPdfBundle\EasyPdfBundle(),
-        // ...
-    );
-}
-
- -

Create your PDF class

-

The goal of this bundle is to decorate a PDF that extend

-

The bundle provide base lib. Show the doc session for that.

-
<?php
-
-namespace Acme\DemoBundle\Lib\Entity;
-
-use Kark\EasyPdfBundle\Lib\Draw\PDF_Draw;
-use Kark\EasyPdfBundle\Lib\Cellfit\FPDF_CellFit;
-use Kark\EasyPdfBundle\Lib\Barecode\PDF_Code128;
-
-class Pdf extends \FPDI
-{
-
-    /**
-    * Write text at position XY in a rectangle with (width, height, $string)
-    */
-    public function destinataireDenomination($string)
-    { 
-
-        $this->SetXY(102, 47);
-        $this->Cell(200,10,$string,0,0,'l',0); 
-    } 
-}
-
-
\ No newline at end of file diff --git a/Resources/doc/installation.md b/Resources/doc/installation.md index 3ad1672..58cfab2 100755 --- a/Resources/doc/installation.md +++ b/Resources/doc/installation.md @@ -7,7 +7,7 @@ Require the bundle in your composer.json file: ``` { "require": { - "chadyred/fpdf-fpdi-symfony2": "dev-master", + "chadyred/easy-pdf-bundle": "dev-master", } } ``` diff --git a/Resources/example/Lib/Entity/Pdf.php b/Resources/example/Lib/Entity/Pdf.php index 771555a..974362e 100644 --- a/Resources/example/Lib/Entity/Pdf.php +++ b/Resources/example/Lib/Entity/Pdf.php @@ -2,9 +2,9 @@ namespace Acme\DemoBundle\Lib\Entity; -use Kark\EasyPdfBundle\Lib\Draw\PDF_Draw; -use Kark\EasyPdfBundle\Lib\Cellfit\FPDF_CellFit; -use Kark\EasyPdfBundle\Lib\Barecode\PDF_Code128; +use Kark\EasyPdfBundle\Lib\Draw\PdfDraw; +use Kark\EasyPdfBundle\Lib\Cellfit\FpdfCellfit; +use Kark\EasyPdfBundle\Lib\Barecode\PdfCode128; class Pdf extends \FPDI { @@ -48,7 +48,7 @@ public function checkboxDemandeDtDictConjointe() $style = array('width' => 0.75, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'phase' => 10, 'color' => array(0, 0, 0)); //PdfDraw enrichie avec la pattern Decorator mon PDF - $draw = new PDF_Draw($pdf=$this); + $draw = new PdfDraw($pdf=$this); $draw->Line(11.3, 69.8, 13, 72.5, $style); $draw->Line(13, 72.5, 15, 68.5, $style); @@ -60,7 +60,7 @@ public public function numeroTelephone($string) { // Helvetica 12 $this->SetFont('Helvetica',"",10); - $cellfit = new FPDF_CellFit($pdf=$this); + $cellfit = new FpdfCellfit($pdf=$this); //Sinon seul la première ligne existe $this->SetXY(90.3, 120); @@ -75,7 +75,7 @@ public public function barecodeTest($code) $this->SetFont('Arial','',10); - $barecode = new PDF_Code128($pdf=$this); + $barecode = new PdfCode128($pdf=$this); $barecode->Code128(90,5,$code,110,20); $this->SetXY(90,30); diff --git a/Resources/example/Lib/app.php b/Resources/example/Lib/app.php new file mode 100644 index 0000000..db56736 --- /dev/null +++ b/Resources/example/Lib/app.php @@ -0,0 +1,13 @@ +indexAction(); \ No newline at end of file diff --git a/composer.json b/composer.json index 562d0cf..4c921c5 100644 --- a/composer.json +++ b/composer.json @@ -1,9 +1,9 @@ { - "name": "chadyred/EasyPdfBundle", + "name": "chadyred/easy-pdf-bundle", "type": "library", "description": "fpdf vendor for use with Symfony3", "keywords": ["fpdf", "fpdi", "pdf"], - "homepage": "http://github.com/chadyred/EasyPdfBundle", + "homepage": "https://github.com/chadyred/EasyPdfBundle", "license": "MIT", "version": "2.0", "authors": [ @@ -18,10 +18,7 @@ }, "autoload": { "psr-4": { - "Kark\\EasyPdfBundle\\Lib":"", - "Kark\\EasyPdfBundle\\Lib\\Barecode":"", - "Kark\\EasyPdfBundle\\Lib\\Cellfit":"", - "Kark\\EasyPdfBundle\\Lib\\Barecode":"" + "Kark\\EasyPdfBundle\\":"" } } }