Skip to content

Commit

Permalink
Fix: A lot of fix into sticker sheet dimension management.
Browse files Browse the repository at this point in the history
Fix: Size of font too large to print sticker pages.

Conflicts:
	htdocs/core/modules/member/doc/pdf_standard.class.php
	htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php
  • Loading branch information
eldy committed Jan 8, 2014
1 parent 6e5f3b8 commit c0c555b
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 48 deletions.
76 changes: 42 additions & 34 deletions htdocs/core/lib/format_cards.lib.php
Expand Up @@ -27,56 +27,59 @@

global $_Avery_Labels;


// Unit of metric are defined into field 'metric' in mm.
// To get into inch, just /25.4
// Size of pages available on: http://www.worldlabel.com/Pages/pageaverylabels.htm
// _PosX = marginLeft+(_COUNTX*(width+SpaceX));
$_Avery_Labels = array (
'5160'=>array('name'=>'5160 (Letter)',
'5160'=>array('name'=>'Avery-5160, WL-875WX',
'paper-size'=>'letter',
'metric'=>'mm',
'marginLeft'=>1.762,
'marginTop'=>10.7,
'marginLeft'=>5.58165, // 0.21975 inch
'marginTop'=>12.7, // 0.5 inch
'NX'=>3,
'NY'=>10,
'SpaceX'=>3.175,
'SpaceX'=>3.556, // 0.14 inch
'SpaceY'=>0,
'width'=>66.675,
'height'=>25.4,
'font-size'=>8),
'5161'=>array('name'=>'5161 (Letter)',
'width'=>65.8749, // 2.59350 inch
'height'=>25.4, // 1 inch
'font-size'=>7),
'5161'=>array('name'=>'Avery-5161, WL-75WX',
'paper-size'=>'letter',
'metric'=>'mm',
'marginLeft'=>0.967,
'marginTop'=>10.7,
'marginLeft'=>4.445, // 0.175 inch
'marginTop'=>12.7,
'NX'=>2,
'NY'=>10,
'SpaceX'=>3.967,
'SpaceX'=>3.968, // 0.15625 inch
'SpaceY'=>0,
'width'=>101.6,
'height'=>25.4,
'font-size'=>8),
'5162'=>array('name'=>'5162 (Letter)',
'width'=>101.6, // 4 inch
'height'=>25.4, // 1 inch
'font-size'=>7),
'5162'=>array('name'=>'Avery-5162, WL-100WX',
'paper-size'=>'letter',
'metric'=>'mm',
'marginLeft'=>0.97,
'marginTop'=>20.224,
'marginLeft'=>3.8735, // 0.1525 inch
'marginTop'=>22.352, // 0.88 inch
'NX'=>2,
'NY'=>7,
'SpaceX'=>4.762,
'SpaceX'=>4.954, // 0.195 inch
'SpaceY'=>0,
'width'=>100.807,
'height'=>35.72,
'width'=>101.6, // 4 inch
'height'=>33.781, // 1.33 inch
'font-size'=>8),
'5163'=>array('name'=>'5163 (Letter)',
'5163'=>array('name'=>'Avery-5163, WL-125WX',
'paper-size'=>'letter',
'metric'=>'mm',
'marginLeft'=>1.762,
'marginTop'=>10.7,
'marginLeft'=>4.572, // 0.18 inch
'marginTop'=>12.7, // 0.5 inch
'NX'=>2,
'NY'=>5,
'SpaceX'=>3.175,
'SpaceX'=>3.556, // 0.14 inch
'SpaceY'=>0,
'width'=>101.6,
'height'=>50.8,
'font-size'=>8),
'width'=>101.6, // 4 inch
'height'=>50.8, // 2 inch
'font-size'=>10),
/* Bugged '5164'=>array('name'=>'5164 (Letter)',
'paper-size'=>'letter',
'metric'=>'in',
Expand All @@ -89,7 +92,7 @@
'width'=>4.0,
'height'=>3.33,
'font-size'=>12), */
'8600'=>array('name'=>'8600 (Letter)',
'8600'=>array('name'=>'Avery-8600',
'paper-size'=>'letter',
'metric'=>'mm',
'marginLeft'=>7.1,
Expand All @@ -100,8 +103,8 @@
'SpaceY'=>3.1,
'width'=>66.6,
'height'=>25.4,
'font-size'=>8),
'L7163'=>array('name'=>'L7163 (A4)',
'font-size'=>7),
'L7163'=>array('name'=>'Avery-L7163',
'paper-size'=>'A4',
'metric'=>'mm',
'marginLeft'=>5,
Expand All @@ -112,8 +115,9 @@
'SpaceY'=>0,
'width'=>99.1,
'height'=>38.1,
'font-size'=>10),
'AVERYC32010'=>array('name'=>'AVERY-C32010 (A4)',
'font-size'=>8),
// 85.0 x 54.0 mm
'AVERYC32010'=>array('name'=>'Avery-C32010',
'paper-size'=>'A4',
'metric'=>'mm',
'marginLeft'=>15,
Expand All @@ -125,7 +129,7 @@
'width'=>85,
'height'=>54,
'font-size'=>10),
'CARD'=>array('name'=>'Dolibarr Business cards (A4)',
'CARD'=>array('name'=>'Dolibarr Business cards',
'paper-size'=>'A4',
'metric'=>'mm',
'marginLeft'=>15,
Expand All @@ -139,5 +143,9 @@
'font-size'=>10)
);

foreach($_Avery_Labels as $key => $val)
{
$_Avery_Labels[$key]['name'].=' ('.$_Avery_Labels[$key]['paper-size'].' - '.$_Avery_Labels[$key]['NX'].'x'.$_Avery_Labels[$key]['NY'].')';
}

?>
18 changes: 11 additions & 7 deletions htdocs/core/modules/member/doc/pdf_standard.class.php
Expand Up @@ -114,7 +114,9 @@ function Set_Char_Size(&$pdf,$pt)


/**
* On imprime une etiquette
* 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 string $textleft Textleft
Expand Down Expand Up @@ -184,25 +186,27 @@ function Add_PDF_card(&$pdf,$textleft,$header,$footer,$outputlangs,$textright=''
$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);
$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, $_PosY+1);
$pdf->Cell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($header),0,1,'C');
$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');
}


$xleft=2; $ytop=2+(empty($header)?0:1+$this->_Line_Height);
$maxwidthtouse=round(($this->_Width - 2*$xleft)*$imgscalewidth); $maxheighttouse=round(($this->_Height - 2*$ytop)*$imgscaleheight);
$defaultratio=($maxwidthtouse/$maxheighttouse);
$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'])
Expand Down
18 changes: 11 additions & 7 deletions htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php
Expand Up @@ -113,7 +113,9 @@ function Set_Char_Size(&$pdf,$pt)
}

/**
* On imprime une etiquette
* 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 string $textleft Text left
Expand Down Expand Up @@ -172,25 +174,27 @@ function Add_PDF_card(&$pdf,$textleft,$header,$footer,$outputlangs,$textright=''
$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);
$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, $_PosY+1);
$pdf->Cell($this->_Width, $this->_Line_Height, $outputlangs->convToOutputCharset($header),0,1,'C');
$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');
}


$xleft=2; $ytop=2+(empty($header)?0:1+$this->_Line_Height);
$maxwidthtouse=round(($this->_Width - 2*$xleft)*$imgscalewidth); $maxheighttouse=round(($this->_Height - 2*$ytop)*$imgscaleheight);
$defaultratio=($maxwidthtouse/$maxheighttouse);
$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'])
Expand Down

0 comments on commit c0c555b

Please sign in to comment.