diff --git a/htdocs/core/class/pdf_label.class.php b/htdocs/core/class/pdf_label.class.php
new file mode 100644
index 0000000000000000000000000000000000000000..f6b156bb37ae33eb37e1088b6ab220174bc75b7b
--- /dev/null
+++ b/htdocs/core/class/pdf_label.class.php
@@ -0,0 +1,546 @@
+<?php
+/* Copyright (C) 2003 Steve Dillon
+ * Copyright (C) 2003 Laurent Passebecq
+ * Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
+ * Copyright (C) 2002-2003 Jean-Louis Bergamo   <jlb@j1b.org>
+ * Copyright (C) 2006-2013 Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2015 Francis Appels  <francis.appels@yahoo.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* Inspire de PDF_Label
+ * PDF_Label - PDF label editing
+ * @package PDF_Label
+ * @author Laurent PASSEBECQ <lpasseb@numericable.fr>
+ * @copyright 2003 Laurent PASSEBECQ
+ * disponible ici : http://www.fpdf.org/fr/script/script29.php
+ */
+
+//-------------------------------------------------------------------
+// VERSIONS :
+// 1.0  : Initial release
+// 1.1  : +	: Added unit in the constructor
+//	  + : Now Positions start @ (1,1).. then the first image @top-left of a page is (1,1)
+//	  + : Added in the description of a label :
+//		font-size	: defaut char size (can be changed by calling Set_Char_Size(xx);
+//		paper-size	: Size of the paper for this sheet (thanx to Al Canton)
+//		metric		: type of unit used in this description
+//				  You can define your label properties in inches by setting metric to 'in'
+//				  and printing in millimiter by setting unit to 'mm' in constructor.
+//	  Added some labels :
+//	        5160, 5161, 5162, 5163,5164 : thanx to Al Canton : acanton@adams-blake.com
+//		8600 						: thanx to Kunal Walia : kunal@u.washington.edu
+//	  + : Added 3mm to the position of labels to avoid errors
+////////////////////////////////////////////////////
+
+/**
+ *	\file       htdocs/core/class/pdf_label.class.php
+ *	\ingroup    core
+ *	\brief      generate pdf document with labels or cards in Avery or custom format
+ */
+
+require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/format_cards.lib.php';
+
+
+/**
+ *	Class to generate stick sheet with format Avery or other personalised
+ */
+class pdf_label
+{
+
+	var $code;		// Code of format
+	var $format;	// Array with informations
+
+	// Proprietes privees
+	var $_Avery_Name	= '';	// Nom du format de l'etiquette
+	var $_Margin_Left	= 0;	// Marge de gauche de l'etiquette
+	var $_Margin_Top	= 0;	// marge en haut de la page avant la premiere etiquette
+	var $_X_Space 	= 0;	// Espace horizontal entre 2 bandes d'etiquettes
+	var $_Y_Space 	= 0;	// Espace vertical entre 2 bandes d'etiquettes
+	var $_X_Number 	= 0;	// NX Nombre d'etiquettes sur la largeur de la page
+	var $_Y_Number 	= 0;	// NY Nombre d'etiquettes sur la hauteur de la page
+	var $_Width 		= 0;	// Largeur de chaque etiquette
+	var $_Height 		= 0;	// Hauteur de chaque etiquette
+	var $_Char_Size	= 10;	// Hauteur des caracteres
+	var $_Line_Height	= 10;	// Hauteur par defaut d'une ligne
+	var $_Metric 		= 'mm';	// Type of metric.. Will help to calculate good values
+	var $_Metric_Doc 	= 'mm';	// Type of metric for the doc..
+
+	var $_COUNTX = 1;
+	var $_COUNTY = 1;
+	var $_First = 1;
+
+
+
+	/**
+	 *	Constructor
+	 *
+	 *  @param		DoliDB		$db      Database handler
+	 */
+	function __construct($db)
+	{
+		$this->db = $db;
+	}
+
+	/**
+	 * Methode qui permet de modifier la taille des caracteres
+	 * Cela modiera aussi l'espace entre chaque ligne
+	 *
+	 * @param    PDF       &$pdf   PDF reference
+	 * @param    int        $pt    point
+	 * @return   void
+	 */
+	function Set_Char_Size(&$pdf,$pt)
+	{
+		if ($pt > 3) {
+			$this->_Char_Size = $pt;
+			$this->_Line_Height = $this->_Get_Height_Chars($pt);
+			$pdf->SetFont('','',$pt);
+		}
+	}
+
+	/**
+	 * Output a sticker on page at position _COUNTX, _COUNTY (_COUNTX and _COUNTY start from 0)
+	 * - %LOGO% is replace with company logo
+	 * - %PHOTO% is replace with photo provided as parameter
+	 *
+	 * @param   PDF        &$pdf            PDF reference
+	 * @param   string		$textleft       Text left
+	 * @param   string     	$header         Header
+	 * @param   string     	$footer         Footer
+	 * @param   Translate  	$outputlangs    Output langs
+	 * @param   string     	$textright      Text right
+	 * @param   string     	$photo    		Photo (full path to image file used as replacement for key %PHOTOS% into left, right, header or footer text)
+	 * @return  void
+	 */
+	function Add_PDF_card(&$pdf,$textleft,$header,$footer,$outputlangs,$textright='',$photo='')
+	{
+		global $mysoc,$conf,$langs;
+		global $forceimgscalewidth,$forceimgscaleheight;
+
+	 	$imgscalewidth=(empty($forceimgscalewidth)?0.3:$forceimgscalewidth);	// Scale of image for width (1=Full width of sticker)
+	 	$imgscaleheight=(empty($forceimgscalewidth)?0.5:$forceimgscalewidth);	// Scale of image for height (1=Full height of sticker)
+
+	 	// We are in a new page, then we must add a page
+		if (($this->_COUNTX ==0) && ($this->_COUNTY==0) and (!$this->_First==1)) {
+			$pdf->AddPage();
+		}
+		$this->_First=0;
+		$_PosX = $this->_Margin_Left+($this->_COUNTX*($this->_Width+$this->_X_Space));
+		$_PosY = $this->_Margin_Top+($this->_COUNTY*($this->_Height+$this->_Y_Space));
+
+		// Define logo
+		$logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
+		if (! is_readable($logo))
+		{
+			$logo='';
+			if (! empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small))
+			{
+				$logo=$conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small;
+			}
+			elseif (! empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo))
+			{
+				$logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
+			}
+		}
+
+		// Define photo
+		if (! empty($photo))
+		{
+			if (! is_readable($photo)) $photo='';
+		}
+
+		// Define background image
+		$backgroundimage='';
+
+		// Print lines
+		if ($this->code == "CARD")
+		{
+			$this->Tformat=$this->_Avery_Labels["CARD"];
+			//$this->_Pointille($pdf,$_PosX,$_PosY,$_PosX+$this->_Width,$_PosY+$this->_Height,0.3,25);
+			$this->_Croix($pdf,$_PosX,$_PosY,$_PosX+$this->_Width,$_PosY+$this->_Height,0.1,10);
+		}
+
+		// Background
+		if ($backgroundimage)
+		{
+			$pdf->image($backgroundimage,$_PosX,$_PosY,$this->_Width,$this->_Height);
+		}
+
+		$xleft=2; $ytop=2;
+
+		// Top
+		if ($header!='')
+		{
+			if ($this->code == "CARD")
+			{
+				$pdf->SetDrawColor(128,128,128);
+				$pdf->Line($_PosX, $_PosY+$this->_Line_Height+1, $_PosX+$this->_Width, $_PosY+$this->_Line_Height+1); // Only 1 mm and not ytop for top text
+				$pdf->SetDrawColor(0,0,0);
+			}
+			$pdf->SetXY($_PosX+$xleft, $_PosY+1); // Only 1 mm and not ytop for top text
+			$pdf->Cell($this->_Width-2*$xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($header),0,1,'C');
+		}
+
+
+		$ytop+=(empty($header)?0:(1+$this->_Line_Height));
+
+		// Define widthtouse and heighttouse
+		$maxwidthtouse=round(($this->_Width - 2*$xleft)*$imgscalewidth); $maxheighttouse=round(($this->_Height - 2*$ytop)*$imgscaleheight);
+		$defaultratio=($maxwidthtouse/$maxheighttouse);
+		$widthtouse=$maxwidthtouse; $heighttouse=0;		// old value for image
+		$tmp=dol_getImageSize($photo, false);
+		if ($tmp['height'])
+		{
+			$imgratio=$tmp['width']/$tmp['height'];
+			if ($imgratio >= $defaultratio) { $widthtouse = $maxwidthtouse; $heighttouse = round($widthtouse / $imgratio); }
+			else { $heightouse = $maxheighttouse; $widthtouse = round($heightouse * $imgratio); }
+		}
+		//var_dump($this->_Width.'x'.$this->_Height.' with border and scale '.$imgscale.' => max '.$maxwidthtouse.'x'.$maxheighttouse.' => We use '.$widthtouse.'x'.$heighttouse);exit;
+
+		// Center
+		if ($textright=='')	// Only a left part
+		{
+			// Output left area
+			if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
+			else if ($textleft == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
+			else
+			{
+				$pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
+				$pdf->MultiCell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L');
+			}
+		}
+		else if ($textleft!='' && $textright!='')	//
+		{
+			if ($textleft == '%LOGO%' || $textleft == '%PHOTO%')
+			{
+				if ($textleft == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
+				else if ($textleft == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
+				$pdf->SetXY($_PosX+$xleft+$widthtouse+1, $_PosY+$ytop);
+				$pdf->MultiCell($this->_Width-$xleft-$xleft-$widthtouse-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R');
+			}
+			else if ($textright == '%LOGO%' || $textright == '%PHOTO%')
+			{
+				if ($textright == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
+				else if ($textright == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
+				$pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
+				$pdf->MultiCell($this->_Width-$widthtouse-$xleft-$xleft-1, $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L');
+			}
+			else	// text on halft left and text on half right
+			{
+				$pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
+				$pdf->MultiCell(round($this->_Width/2), $this->_Line_Height, $outputlangs->convToOutputCharset($textleft),0,'L');
+				$pdf->SetXY($_PosX+round($this->_Width/2), $_PosY+$ytop);
+				$pdf->MultiCell(round($this->_Width/2)-2, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R');
+			}
+		}
+		else	// Only a right part
+		{
+			// Output right area
+			if ($textright == '%LOGO%' && $logo) $pdf->Image($logo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
+			else if ($textright == '%PHOTO%' && $photo) $pdf->Image($photo,$_PosX+$this->_Width-$widthtouse-$xleft,$_PosY+$ytop,$widthtouse,$heighttouse);
+			else
+			{
+				$pdf->SetXY($_PosX+$xleft, $_PosY+$ytop);
+				$pdf->MultiCell($this->_Width-$xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($textright),0,'R');
+			}
+		}
+
+		// Bottom
+		if ($footer!='')
+		{
+			if ($this->code == "CARD")
+			{
+				$pdf->SetDrawColor(128,128,128);
+				$pdf->Line($_PosX, $_PosY+$this->_Height-$this->_Line_Height-2, $_PosX+$this->_Width, $_PosY+$this->_Height-$this->_Line_Height-2);
+				$pdf->SetDrawColor(0,0,0);
+			}
+			$pdf->SetXY($_PosX, $_PosY+$this->_Height-$this->_Line_Height-1);
+			$pdf->Cell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($footer),0,1,'C');
+		}
+		//print "$_PosY+$this->_Height-$this->_Line_Height-1<br>\n";
+
+		$this->_COUNTY++;
+
+		if ($this->_COUNTY == $this->_Y_Number) {
+			// Si on est en bas de page, on remonte le 'curseur' de position
+			$this->_COUNTX++;
+			$this->_COUNTY=0;
+		}
+
+		if ($this->_COUNTX == $this->_X_Number) {
+			// Si on est en bout de page, alors on repart sur une nouvelle page
+			$this->_COUNTX=0;
+			$this->_COUNTY=0;
+		}
+	}
+
+
+	/**
+	 * Print dot line
+	 *
+	 * @param	PDF    &$pdf                PDF reference
+	 * @param 	int		$x1					X1
+	 * @param 	int		$y1					Y1
+	 * @param 	int		$x2					X2
+	 * @param 	int		$y2					Y2
+	 * @param 	int		$epaisseur			Epaisseur
+	 * @param 	int		$nbPointilles		Nb pointilles
+	 * @return	void
+	 */
+    function _Pointille(&$pdf,$x1=0,$y1=0,$x2=210,$y2=297,$epaisseur=1,$nbPointilles=15)
+	{
+		$pdf->SetLineWidth($epaisseur);
+		$length=abs($x1-$x2);
+		$hauteur=abs($y1-$y2);
+		if($length>$hauteur) {
+			$Pointilles=($length/$nbPointilles)/2; // taille des pointilles
+		}
+		else {
+			$Pointilles=($hauteur/$nbPointilles)/2;
+		}
+		for($i=$x1;$i<=$x2;$i+=$Pointilles+$Pointilles) {
+			for($j=$i;$j<=($i+$Pointilles);$j++) {
+				if($j<=($x2-1)) {
+		$pdf->Line($j,$y1,$j+1,$y1); // on trace le pointill? du haut, point par point
+		$pdf->Line($j,$y2,$j+1,$y2); // on trace le pointill? du bas, point par point
+				}
+			}
+		}
+		for($i=$y1;$i<=$y2;$i+=$Pointilles+$Pointilles) {
+			for($j=$i;$j<=($i+$Pointilles);$j++) {
+				if($j<=($y2-1)) {
+		$pdf->Line($x1,$j,$x1,$j+1); // on trace le pointill? du haut, point par point
+		$pdf->Line($x2,$j,$x2,$j+1); // on trace le pointill? du bas, point par point
+				}
+			}
+		}
+	}
+
+	/**
+	 * Fonction realisant une croix aux 4 coins des cartes
+	 *
+	 * @param PDF  &$pdf   PDF reference
+	 * @param int   $x1					X1
+	 * @param int	$y1					Y1
+	 * @param int	$x2					X2
+	 * @param int	$y2					Y2
+	 * @param int	$epaisseur			Epaisseur
+	 * @param int	$taille             Size
+	 * @return void
+	 */
+	function _Croix(&$pdf,$x1=0,$y1=0,$x2=210,$y2=297,$epaisseur=1,$taille=4)
+	{
+		$pdf->SetDrawColor(192,192,192);
+
+		$pdf->SetLineWidth($epaisseur);
+		$lg=$taille/2;
+		// croix haut gauche
+		$pdf->Line($x1,$y1-$lg,$x1,$y1+$lg);
+		$pdf->Line($x1-$lg,$y1,$x1+$lg,$y1);
+		// croix bas gauche
+		$pdf->Line($x1,$y2-$lg,$x1,$y2+$lg);
+		$pdf->Line($x1-$lg,$y2,$x1+$lg,$y2);
+		// croix haut droit
+		$pdf->Line($x2,$y1-$lg,$x2,$y1+$lg);
+		$pdf->Line($x2-$lg,$y1,$x2+$lg,$y1);
+		// croix bas droit
+		$pdf->Line($x2,$y2-$lg,$x2,$y2+$lg);
+		$pdf->Line($x2-$lg,$y2,$x2+$lg,$y2);
+
+		$pdf->SetDrawColor(0,0,0);
+	}
+
+	/**
+	 * Convert units (in to mm, mm to in)
+	 * $src and $dest must be 'in' or 'mm'
+	 *
+	 * @param int       $value  value
+	 * @param string    $src    from
+	 * @param string    $dest   to
+	 * @return float    value   value after conversion
+	 */
+	function _Convert_Metric ($value, $src, $dest)
+	{
+		if ($src != $dest) {
+			$tab['in'] = 39.37008;
+			$tab['mm'] = 1000;
+			return $value * $tab[$dest] / $tab[$src];
+		} else {
+			return $value;
+		}
+	}
+
+	/**
+	 * Give the height for a char size given.
+	 *
+	 * @param  int    $pt    Point
+	 * @return int           Height chars
+	 */
+	function _Get_Height_Chars($pt)
+	{
+		// Tableau de concordance entre la hauteur des caracteres et de l'espacement entre les lignes
+		$_Table_Hauteur_Chars = array(6=>2, 7=>2.5, 8=>3, 9=>3.5, 10=>4, 11=>6, 12=>7, 13=>8, 14=>9, 15=>10);
+		if (in_array($pt, array_keys($_Table_Hauteur_Chars))) {
+			return $_Table_Hauteur_Chars[$pt];
+		} else {
+			return 100; // There is a prob..
+		}
+	}
+
+	/**
+	 * Set format
+	 *
+	 * @param    PDF      &$pdf     PDF reference
+	 * @param    string    $format  Format
+	 * @return   void
+	 */
+	function _Set_Format(&$pdf, $format)
+	{
+		$this->_Metric 	= $format['metric'];
+		$this->_Avery_Name 	= $format['name'];
+		$this->_Avery_Code	= $format['code'];
+		$this->_Margin_Left	= $this->_Convert_Metric($format['marginLeft'], $this->_Metric, $this->_Metric_Doc);
+		$this->_Margin_Top	= $this->_Convert_Metric($format['marginTop'], $this->_Metric, $this->_Metric_Doc);
+		$this->_X_Space 	= $this->_Convert_Metric($format['SpaceX'], $this->_Metric, $this->_Metric_Doc);
+		$this->_Y_Space 	= $this->_Convert_Metric($format['SpaceY'], $this->_Metric, $this->_Metric_Doc);
+		$this->_X_Number 	= $format['NX'];
+		$this->_Y_Number 	= $format['NY'];
+		$this->_Width 	= $this->_Convert_Metric($format['width'], $this->_Metric, $this->_Metric_Doc);
+		$this->_Height	= $this->_Convert_Metric($format['height'], $this->_Metric, $this->_Metric_Doc);
+		$this->Set_Char_Size($pdf, $format['font-size']);
+	}
+
+
+    /**
+     *  Function to build PDF on disk, then output on HTTP strem.
+     *
+     *  @param	array		$arrayofrecords  	Array of record informations (array('textleft'=>,'textheader'=>, ..., 'id'=>,'photo'=>)
+     *  @param  Translate	$outputlangs     	Lang object for output language
+     *  @param	string		$srctemplatepath	Full path of source filename for generator using a template file
+	 *	@param	string		$outputdir			Output directory for pdf file
+     *  @return int             				1=OK, 0=KO
+     */
+    function write_file($arrayofrecords,$outputlangs,$srctemplatepath,$outputdir='')
+    {
+        global $user,$conf,$langs,$mysoc,$_Avery_Labels;
+
+        $this->code=$srctemplatepath;
+        $this->Tformat = $_Avery_Labels[$this->code];
+        if (empty($this->Tformat)) { dol_print_error('','ErrorBadTypeForCard'.$this->code); exit; }
+        $this->type = 'pdf';
+        $this->format = $this->Tformat['paper-size'];
+
+        if (! is_object($outputlangs)) $outputlangs=$langs;
+		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
+		if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
+
+        $outputlangs->load("main");
+        $outputlangs->load("dict");
+        $outputlangs->load("companies");
+        $outputlangs->load("admin");
+
+        $title=$outputlangs->transnoentities('Labels');
+        $keywords=$title." ".$outputlangs->convToOutputCharset($mysoc->name);
+
+        $dir = (empty($outputdir)?$conf->adherent->dir_temp:$outputdir);
+        $filename='tmp_address_sheet.pdf';
+        $file = $dir."/".$filename;
+
+        if (! file_exists($dir))
+        {
+            if (dol_mkdir($dir) < 0)
+            {
+                $this->error=$langs->trans("ErrorCanNotCreateDir",$dir);
+                return 0;
+            }
+        }
+
+        $pdf=pdf_getInstance($this->format,$this->Tformat['metric']);
+
+        if (class_exists('TCPDF'))
+        {
+            $pdf->setPrintHeader(false);
+            $pdf->setPrintFooter(false);
+        }
+        $pdf->SetFont(pdf_getPDFFont($outputlangs));
+
+        $pdf->SetTitle($title);
+        $pdf->SetSubject($title);
+        $pdf->SetCreator("Dolibarr ".DOL_VERSION);
+        $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
+        $pdf->SetKeyWords($keywords);
+        if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
+
+        $pdf->SetMargins(0,0);
+        $pdf->SetAutoPageBreak(false);
+
+        $this->_Metric_Doc = $this->Tformat['metric'];
+        // Permet de commencer l'impression de l'etiquette desiree dans le cas ou la page a deja servie
+        $posX=1;
+        $posY=1;
+        if ($posX > 0) $posX--; else $posX=0;
+        if ($posY > 0) $posY--; else $posY=0;
+        $this->_COUNTX = $posX;
+        $this->_COUNTY = $posY;
+        $this->_Set_Format($pdf, $this->Tformat);
+
+
+        $pdf->Open();
+        $pdf->AddPage();
+
+
+        // Add each record
+        foreach($arrayofrecords as $val)
+        {
+            // imprime le texte specifique sur la carte
+            $this->Add_PDF_card($pdf,$val['textleft'],$val['textheader'],$val['textfooter'],$langs,$val['textright'],$val['photo']);
+        }
+
+        //$pdf->SetXY(10, 295);
+        //$pdf->Cell($this->_Width, $this->_Line_Height, 'XXX',0,1,'C');
+
+
+        // Output to file
+        $pdf->Output($file,'F');
+
+        if (! empty($conf->global->MAIN_UMASK))
+            @chmod($file, octdec($conf->global->MAIN_UMASK));
+
+
+
+        // Output to http stream
+        clearstatcache();
+
+        $attachment=true;
+        if (! empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment=false;
+        $type=dol_mimetype($filename);
+
+        //if ($encoding)   header('Content-Encoding: '.$encoding);
+        if ($type)       header('Content-Type: '.$type);
+        if ($attachment) header('Content-Disposition: attachment; filename="'.$filename.'"');
+        else header('Content-Disposition: inline; filename="'.$filename.'"');
+
+        // Ajout directives pour resoudre bug IE
+        header('Cache-Control: Public, must-revalidate');
+        header('Pragma: public');
+
+        readfile($file);
+
+        return 1;
+    }
+}
diff --git a/htdocs/core/modules/barcode/doc/tcpdfbarcode.modules.php b/htdocs/core/modules/barcode/doc/tcpdfbarcode.modules.php
new file mode 100644
index 0000000000000000000000000000000000000000..d608543d5f5a58fa5713c38b277e854df5321dc6
--- /dev/null
+++ b/htdocs/core/modules/barcode/doc/tcpdfbarcode.modules.php
@@ -0,0 +1,252 @@
+<?php
+/* Copyright (C) 2005-2009 Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2005      Regis Houssin        <regis@dolibarr.fr>
+ * Copyright (C) 2015 	   Francis Appels       <francis.appels@yahoo.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ *       \file       htdocs/core/modules/barcode/doc/tcpdfbarcode.modules.php
+ *       \ingroup    barcode
+ *       \brief      File of class to manage barcode numbering with tcpdf library
+ */
+
+require_once DOL_DOCUMENT_ROOT.'/core/modules/barcode/modules_barcode.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/barcode.lib.php';    // This is to include def like $genbarcode_loc and $font_loc
+
+/**
+ *	Class to generate barcode images using tcpdf barcode generator
+ */
+class modTcpdfbarcode extends ModeleBarCode
+{
+	var $version='dolibarr';		// 'development', 'experimental', 'dolibarr'
+	var $error='';
+	var $is2d = false;
+	
+    /**
+     *	Return description of numbering model
+     *
+     *  @return     string      Text with description
+     */
+    function info()
+    {
+	 	global $langs;
+
+    	return 'TCPDF-barcode';
+    }
+
+    /**
+	 * 	Return if a module can be used or not
+	 *
+	 *  @return		boolean     true if module can be used
+	 */
+	function isEnabled()
+	{
+		return true;
+	}    
+	
+	/**
+	 *  Test si les numeros deja en vigueur dans la base ne provoquent pas de
+	 *  de conflits qui empechera cette numerotation de fonctionner.
+	 *
+	 *	@return     boolean     false si conflit, true si ok
+	 */
+	function canBeActivated()
+	{
+	    global $langs;
+	
+	    return true;
+	}
+	
+	/**
+	 *	Return true if encoding is supported
+	 *
+	 *	@param	string	$encoding		Encoding norm
+	 *	@return	int						>0 if supported, 0 if not
+	 */
+	function encodingIsSupported($encoding)
+	{
+	    $tcpdfEncoding = $this->getTcpdfEncodingType($encoding);
+	    if (empty($tcpdfEncoding)) {
+	        return 0;
+	    } else {
+	        return 1;
+	    }	    
+	}
+
+    /**
+	 *	Return an image file on the fly (no need to write on disk)
+	 *
+	 *	@param   	String    $code        Value to encode
+	 *	@param   	String    $encoding    Mode of encoding
+	 *	@param   	String    $readable    Code can be read
+	 *	@return		int				<0 if KO, >0 if OK
+     */
+    function buildBarCode($code,$encoding,$readable='Y')
+    {
+        global $_GET;
+        
+        $tcpdfEncoding = $this->getTcpdfEncodingType($encoding);
+        if (empty($tcpdfEncoding)) return -1;
+				
+		$color = array(0,0,0);
+
+		$_GET["code"]=$code;
+		$_GET["type"]=$encoding;
+		$_GET["height"]=$height;
+		$_GET["readable"]=$readable;
+		
+		if ($code) {
+    		// Load the tcpdf barcode class
+    		if ($this->is2d) {
+    		    $height = 3;
+		        $width = 3;
+    		    require_once TCPDF_PATH.'tcpdf_barcodes_2d.php';
+    		    $barcodeobj = new TCPDF2DBarcode($code, $tcpdfEncoding);
+    		} else {
+    		    $height = 50;
+    		    $width = 1;
+    		    require_once TCPDF_PATH.'tcpdf_barcodes_1d.php';
+    		    $barcodeobj = new TCPDFBarcode($code, $tcpdfEncoding);
+    		}	    
+		    
+		    dol_syslog("buildBarCode::TCPDF.getBarcodePNG");
+		    $barcodeobj->getBarcodePNG($width, $height, $color);
+		    
+		    return 1;
+		} else {
+		    return -2;
+		}		
+    }
+
+	/**
+     *	Save an image file on disk (with no output)
+     *
+	 *	@param   	String    $code			Value to encode
+	 *	@param   	String    $encoding		Mode of encoding
+	 *	@param   	String    $readable		Code can be read
+	 *	@return		int				<0 if KO, >0 if OK
+     */
+    function writeBarCode($code,$encoding,$readable='Y')
+    {
+    	global $conf,$_GET;
+
+		dol_mkdir($conf->barcode->dir_temp);
+		$file=$conf->barcode->dir_temp.'/barcode_'.$code.'_'.$encoding.'.png';
+
+		$tcpdfEncoding = $this->getTcpdfEncodingType($encoding);
+        if (empty($tcpdfEncoding)) return -1;
+
+		$color = array(0,0,0);
+
+		$_GET["code"]=$code;
+		$_GET["type"]=$encoding;
+		$_GET["height"]=$height;
+		$_GET["readable"]=$readable;
+
+        if ($code) {
+    		// Load the tcpdf barcode class
+    		if ($this->is2d) {
+    		    $height = 1;
+		        $width = 1;
+    		    require_once TCPDF_PATH.'tcpdf_barcodes_2d.php';
+    		    $barcodeobj = new TCPDF2DBarcode($code, $tcpdfEncoding);
+    		} else {
+    		    $height = 50;
+    		    $width = 1;
+    		    require_once TCPDF_PATH.'tcpdf_barcodes_1d.php';
+    		    $barcodeobj = new TCPDFBarcode($code, $tcpdfEncoding);
+    		}	    
+		    
+		    dol_syslog("writeBarCode::TCPDF.getBarcodePngData");
+		    if ($imageData = $barcodeobj->getBarcodePngData($width, $height, $color)) {
+		        if (function_exists('imagecreate')) {
+		            $imageData = imagecreatefromstring($imageData);
+		        }
+		        if (imagepng($imageData, $file)) {
+		            return 1;
+		        } else {
+		            return -3;
+		        }
+		    } else {
+		        return -4;
+		    }		    
+		} else {
+		    return -2;
+		}
+    }
+    
+    /**
+     *	get available output_modes for tcpdf class wth its translated description
+     *
+     * @param   string $dolEncodingType dolibarr barcode encoding type	
+     * @return	string tcpdf encoding type
+     */
+    private function getTcpdfEncodingType($dolEncodingType)
+    {
+        $tcpdf1dEncodingTypes = array(
+                        'C39' => 'C39',
+                        'C39+' => 'C39+',
+                        'C39E' => 'C39E',
+                        'C39E+' => 'C39E+',
+                        'S25' => 'S25',
+                        'S25+' => 'S25+',
+                        'I25' => 'I25',
+                        'I25+' => 'I25+',
+                        'C128' => 'C128',
+                        'C128A' => 'C128A',
+                        'C128B' => 'C128B',
+                        'C128C' => 'C128C',
+                        'EAN2' => 'EAN2',
+                        'EAN5' => 'EAN5',
+                        'EAN8' => 'EAN8',
+                        'EAN13' => 'EAN13',
+                        'ISBN' => 'EAN13',
+                        'UPC' => 'UPCA',
+                        'UPCE' => 'UPCE',
+                        'MSI' => 'MSI',
+                        'MSI+' => 'MSI+',
+                        'POSTNET' => 'POSTNET',
+                        'PLANET' => 'PLANET',
+                        'RMS4CC' => 'RMS4CC',
+                        'KIX' => 'KIX',
+                        'IMB' => 'IMB',
+                        'CODABAR' => 'CODABAR',
+                        'CODE11' => 'CODE11',
+                        'PHARMA' => 'PHARMA',
+                        'PHARMA2T' => 'PHARMA2T'
+        );
+        
+        $tcpdf2dEncodingTypes = array(
+                        'DATAMATRIX' => 'DATAMATRIX',
+                        'PDF417' => 'PDF417',
+                        'QRCODE' => 'QRCODE,L',
+                        'QRCODE,L' => 'QRCODE,L',
+                        'QRCODE,M' => 'QRCODE,M',
+                        'QRCODE,Q' => 'QRCODE,Q',
+                        'QRCODE,H' => 'QRCODE,H'                        
+        );
+        
+        if (array_key_exists($dolEncodingType, $tcpdf1dEncodingTypes)) {
+            $this->is2d = false;
+            return $tcpdf1dEncodingTypes[$dolEncodingType];
+        } else if (array_key_exists($dolEncodingType, $tcpdf2dEncodingTypes)) {
+            $this->is2d = true;
+            return $tcpdf2dEncodingTypes[$dolEncodingType];
+        } else {
+            return '';
+        }        
+    }
+}
\ No newline at end of file
diff --git a/htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php b/htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php
index 193de960bb89c6cc414472314d6568bdfa8f071f..e8eaeabf12ea05afcd5512405e45abcfb68f598b 100644
--- a/htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php
+++ b/htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php
@@ -4,6 +4,7 @@
  * Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  * Copyright (C) 2002-2003 Jean-Louis Bergamo   <jlb@j1b.org>
  * Copyright (C) 2006-2013 Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2015 Francis Appels  <francis.appels@yahoo.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -50,74 +51,20 @@
  *	\brief      Fichier de la classe permettant d'editer au format PDF des etiquettes au format Avery ou personnalise
  */
 
-require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
-require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
-require_once DOL_DOCUMENT_ROOT.'/core/lib/format_cards.lib.php';
-
+require_once DOL_DOCUMENT_ROOT.'/core/class/pdf_label.class.php';
 
 /**
  *	Class to generate stick sheet with format Avery or other personalised
  */
-class pdf_standardlabel
+class pdf_standardlabel extends pdf_label
 {
 
-	var $code;		// Code of format
-	var $format;	// Array with informations
-
-	// Proprietes privees
-	var $_Avery_Name	= '';	// Nom du format de l'etiquette
-	var $_Margin_Left	= 0;	// Marge de gauche de l'etiquette
-	var $_Margin_Top	= 0;	// marge en haut de la page avant la premiere etiquette
-	var $_X_Space 	= 0;	// Espace horizontal entre 2 bandes d'etiquettes
-	var $_Y_Space 	= 0;	// Espace vertical entre 2 bandes d'etiquettes
-	var $_X_Number 	= 0;	// NX Nombre d'etiquettes sur la largeur de la page
-	var $_Y_Number 	= 0;	// NY Nombre d'etiquettes sur la hauteur de la page
-	var $_Width 		= 0;	// Largeur de chaque etiquette
-	var $_Height 		= 0;	// Hauteur de chaque etiquette
-	var $_Char_Size	= 10;	// Hauteur des caracteres
-	var $_Line_Height	= 10;	// Hauteur par defaut d'une ligne
-	var $_Metric 		= 'mm';	// Type of metric.. Will help to calculate good values
-	var $_Metric_Doc 	= 'mm';	// Type of metric for the doc..
-
-	var $_COUNTX = 1;
-	var $_COUNTY = 1;
-	var $_First = 1;
-
-
-
-	/**
-	 *	Constructor
-	 *
-	 *  @param		DoliDB		$db      Database handler
-	 */
-	function __construct($db)
-	{
-		$this->db = $db;
-	}
-
-	/**
-	 * Methode qui permet de modifier la taille des caracteres
-	 * Cela modiera aussi l'espace entre chaque ligne
-	 *
-	 * @param    PDF    $pdf      PDF
-	 * @param    int    $pt        point
-	 * @return   void
-	 */
-	function Set_Char_Size(&$pdf,$pt)
-	{
-		if ($pt > 3) {
-			$this->_Char_Size = $pt;
-			$this->_Line_Height = $this->_Get_Height_Chars($pt);
-			$pdf->SetFont('','',$pt);
-		}
-	}
-
 	/**
 	 * Output a sticker on page at position _COUNTX, _COUNTY (_COUNTX and _COUNTY start from 0)
 	 * - %LOGO% is replace with company logo
 	 * - %PHOTO% is replace with photo provided as parameter
 	 *
-	 * @param   PDF	    	$pdf		    PDF
+	 * @param   PDF	       &$pdf		    PDF reference
 	 * @param   string		$textleft       Text left
 	 * @param   string     	$header         Header
 	 * @param   string     	$footer         Footer
@@ -289,140 +236,6 @@ class pdf_standardlabel
 	}
 
 
-	/**
-	 * Print dot line
-	 *
-	 * @param	PDF		$pdf				PDF
-	 * @param 	int		$x1					X1
-	 * @param 	int		$y1					Y1
-	 * @param 	int		$x2					X2
-	 * @param 	int		$y2					Y2
-	 * @param 	int		$epaisseur			Epaisseur
-	 * @param 	int		$nbPointilles		Nb pointilles
-	 * @return	void
-	 */
-	function _Pointille(&$pdf,$x1=0,$y1=0,$x2=210,$y2=297,$epaisseur=1,$nbPointilles=15)
-	{
-		$pdf->SetLineWidth($epaisseur);
-		$length=abs($x1-$x2);
-		$hauteur=abs($y1-$y2);
-		if($length>$hauteur) {
-			$Pointilles=($length/$nbPointilles)/2; // taille des pointilles
-		}
-		else {
-			$Pointilles=($hauteur/$nbPointilles)/2;
-		}
-		for($i=$x1;$i<=$x2;$i+=$Pointilles+$Pointilles) {
-			for($j=$i;$j<=($i+$Pointilles);$j++) {
-				if($j<=($x2-1)) {
-		$pdf->Line($j,$y1,$j+1,$y1); // on trace le pointill? du haut, point par point
-		$pdf->Line($j,$y2,$j+1,$y2); // on trace le pointill? du bas, point par point
-				}
-			}
-		}
-		for($i=$y1;$i<=$y2;$i+=$Pointilles+$Pointilles) {
-			for($j=$i;$j<=($i+$Pointilles);$j++) {
-				if($j<=($y2-1)) {
-		$pdf->Line($x1,$j,$x1,$j+1); // on trace le pointill? du haut, point par point
-		$pdf->Line($x2,$j,$x2,$j+1); // on trace le pointill? du bas, point par point
-				}
-			}
-		}
-	}
-
-	/**
-	 * Fonction realisant une croix aux 4 coins des cartes
-	 *
-	 * @param PDF	$pdf				PDF
-	 * @param int	$x1					X1
-	 * @param int	$y1					Y1
-	 * @param int	$x2					X2
-	 * @param int	$y2					Y2
-	 * @param int	$epaisseur			Epaisseur
-	 * @param int	$taille             Size
-	 * @return void
-	 */
-	function _Croix(&$pdf,$x1=0,$y1=0,$x2=210,$y2=297,$epaisseur=1,$taille=4)
-	{
-		$pdf->SetDrawColor(192,192,192);
-
-		$pdf->SetLineWidth($epaisseur);
-		$lg=$taille/2;
-		// croix haut gauche
-		$pdf->Line($x1,$y1-$lg,$x1,$y1+$lg);
-		$pdf->Line($x1-$lg,$y1,$x1+$lg,$y1);
-		// croix bas gauche
-		$pdf->Line($x1,$y2-$lg,$x1,$y2+$lg);
-		$pdf->Line($x1-$lg,$y2,$x1+$lg,$y2);
-		// croix haut droit
-		$pdf->Line($x2,$y1-$lg,$x2,$y1+$lg);
-		$pdf->Line($x2-$lg,$y1,$x2+$lg,$y1);
-		// croix bas droit
-		$pdf->Line($x2,$y2-$lg,$x2,$y2+$lg);
-		$pdf->Line($x2-$lg,$y2,$x2+$lg,$y2);
-
-		$pdf->SetDrawColor(0,0,0);
-	}
-
-	/**
-	 * Convert units (in to mm, mm to in)
-	 * $src and $dest must be 'in' or 'mm'
-	 *
-	 * @param int       $value  value
-	 * @param string    $src    from
-	 * @param string    $dest   to
-	 * @return float    value   value after conversion
-	 */
-	function _Convert_Metric ($value, $src, $dest)
-	{
-		if ($src != $dest) {
-			$tab['in'] = 39.37008;
-			$tab['mm'] = 1000;
-			return $value * $tab[$dest] / $tab[$src];
-		} else {
-			return $value;
-		}
-	}
-
-	/**
-	 * Give the height for a char size given.
-	 *
-	 * @param  int    $pt    Point
-	 * @return int           Height chars
-	 */
-	function _Get_Height_Chars($pt)
-	{
-		// Tableau de concordance entre la hauteur des caracteres et de l'espacement entre les lignes
-		$_Table_Hauteur_Chars = array(6=>2, 7=>2.5, 8=>3, 9=>3.5, 10=>4, 11=>6, 12=>7, 13=>8, 14=>9, 15=>10);
-		if (in_array($pt, array_keys($_Table_Hauteur_Chars))) {
-			return $_Table_Hauteur_Chars[$pt];
-		} else {
-			return 100; // There is a prob..
-		}
-	}
-
-	/**
-	 * Set format
-	 *
-	 * @param    PDF       $pdf    PDF
-	 * @param    string    $format  Format
-	 * @return   void
-	 */
-	function _Set_Format(&$pdf, $format)
-	{
-		$this->_Metric 	= $format['metric'];
-		$this->_Avery_Name 	= $format['name'];
-		$this->_Avery_Code	= $format['code'];
-		$this->_Margin_Left	= $this->_Convert_Metric($format['marginLeft'], $this->_Metric, $this->_Metric_Doc);
-		$this->_Margin_Top	= $this->_Convert_Metric($format['marginTop'], $this->_Metric, $this->_Metric_Doc);
-		$this->_X_Space 	= $this->_Convert_Metric($format['SpaceX'], $this->_Metric, $this->_Metric_Doc);
-		$this->_Y_Space 	= $this->_Convert_Metric($format['SpaceY'], $this->_Metric, $this->_Metric_Doc);
-		$this->_X_Number 	= $format['NX'];
-		$this->_Y_Number 	= $format['NY'];
-		$this->_Width 	= $this->_Convert_Metric($format['width'], $this->_Metric, $this->_Metric_Doc);
-		$this->_Height	= $this->_Convert_Metric($format['height'], $this->_Metric, $this->_Metric_Doc);
-		$this->Set_Char_Size($pdf, $format['font-size']);
-	}
 
 
     /**