This commit is contained in:
Laurent Destailleur 2013-07-13 21:14:05 +02:00
parent 0f1c4032ab
commit 3a9ffb19c3
18 changed files with 117 additions and 83 deletions

View File

@ -1553,4 +1553,31 @@ function pdf_getLinkedObjects($object,$outputlangs)
return $linkedobjects; return $linkedobjects;
} }
/**
* Return dimensions to use for images onto PDF
*
* @param string $realpath Full path to photo file to use
* @return array Height/Width to use to output image (in pixel)
*/
function pdf_getHeightForImage($realpath)
{
$maxheight=12; $maxwidth=16;
include_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
$tmp=dol_getImageSize($realpath);
if ($tmp['height'])
{
$width=(int) round($maxheight*$tmp['width']/$tmp['height']);
if ($width > $maxwidth)
{
$height=(int) round($height*$maxwidth/$width);
$width=$maxwidth;
}
else
{
$height=$maxheight;
}
}
return array('width'=>$width,'height'=>$height);
}
?> ?>

View File

@ -380,11 +380,18 @@ class pdf_azur extends ModelePDFPropales
if (!empty($realpath)) if (!empty($realpath))
{ {
//$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
$tmp=pdf_getHeightForImage($realpath); $tmp=pdf_getHeightForImage($realpath);
//var_dump($tmp['height']);exit; //var_dump(constant('PDF_IMAGE_SCALE_RATIO'));var_dump($pdf->getImageScale());var_dump($tmp['width']);var_dump($pdf->pixelsToUnits($tmp['width']));exit;
$pdf->Image($realpath, $curX, $curY-1, $tmp['width'], $tmp['height'],'','','',2, 300); // Use 300 dpi // measures 1/72 of an inch, i.e. approximately 0.0139 inch or 25.4/72 = 0.3528 mm
var_dump($this->page_largeur);exit;
//var_dump(tmp['height']);exit;
$pdf->Line($this->posxtva,10,$this->posxtva+0.5,10);
$pdf->Image($realpath, $this->posxtva, 10, $tmp['width'], $tmp['height'],'','','',2,0); // Use 300 dpi
$pdf->Line($this->posxtva+$pdf->pixelsToUnits($tmp['width']),10,$this->posxtva+$pdf->pixelsToUnits($tmp['width'])+0.5,10);
$pdf->Image($realpath, $curX + ($this->posxtva-$this->posxpicture-($pdf->pixelsToUnits($tmp['width'])))/2, $curY-1, $tmp['width'], $tmp['height'],'','','',2, 300); // Use 300 dpi
//$nexY += 7; // +7 for height = 12 //$nexY += 7; // +7 for height = 12
$nexY += round($tmp['height'] / 12 * 7); $nexY += round($pdf->pixelsToUnits($tmp['height']));
//var_dump($nexY);exit; //var_dump($nexY);exit;
} }
} }