print '<input type="hidden" name="action" value="confirm_resize" />'; print '<input type="hidden" name="product" value="' . $id . '" />'; print '<input type="hidden" name="id" value="' . $id . '" />'; print '<br>'; print '<input class="button" id="submitresize" name="sendit" value="' . dol_escape_htmltag($langs->trans("Resize")) . '" type="submit" />'; print ' '; print '<input type="submit" id="cancelresize" name="cancel" class="button" value="' . dol_escape_htmltag($langs->trans("Cancel")) . '" />'; print '</fieldset>' . "\n"; print '</form>'; print '<br>' . "\n"; /* * Crop image */ print '<br>' . "\n"; if (!empty($conf->use_javascript_ajax)) { $infoarray = dol_getImageSize($dir . "/" . urldecode($_GET["file"])); $height = $infoarray['height']; $width = $infoarray['width']; $widthforcrop = $width; $refsizeforcrop = 'orig'; $ratioforcrop = 1; if (!empty($_SESSION['dol_screenwidth']) && $widthforcrop > round($_SESSION['dol_screenwidth'] / 2)) { $widthforcrop = min(round($_SESSION['dol_screenwidth'] / 2), $widthforcrop); $refsizeforcrop = 'screenwidth'; $ratioforcrop = 2; } print '<!-- Form to crop -->' . "\n"; print '<fieldset id="redim_file">'; print '<legend>' . $langs->trans("Recenter") . '</legend>'; print $langs->trans("DefineNewAreaToPick") . '...<br>'; print '<br><div class="center">';
/** * Return dimensions to use for images onto PDF checking that width and height are not higher than * maximum (16x32 by default). * * @param string $realpath Full path to photo file to use * @return array Height and width to use to output image (in pdf user unit, so mm) */ function pdf_getSizeForImage($realpath) { global $conf; $maxwidth = empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH; $maxheight = empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_HEIGHT) ? 32 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_HEIGHT; 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']); // I try to use maxheight if ($width > $maxwidth) { $width = $maxwidth; $height = (int) round($maxwidth * $tmp['height'] / $tmp['width']); } else { $height = $maxheight; } } return array('width' => $width, 'height' => $height); }
print '<input type="hidden" name="product" value="'.$_REQUEST['id'].'" />'; print '<input type="hidden" name="id" value="'.$_REQUEST['id'].'" />'; print '<br><input class="button" name="sendit" value="'.dol_escape_htmltag($langs->trans("Resize")).'" type="submit" />'; print '</fieldset>'; print '<br></form>'; /* * Recadrage d'une image */ print '<br>'."\n"; if (! empty($conf->use_javascript_ajax)) { $infoarray=dol_getImageSize($conf->product->dir_output."/".urldecode($_GET["file"])); $height=$infoarray['height']; $width=$infoarray['width']; print '<!-- Form to crop -->'."\n"; print '<fieldset id="redim_file">'; print '<legend>'.$langs->trans("Recenter").'</legend>'; print $langs->trans("DefineNewAreaToPick").'...<br>'; print '<br><center>'; print '<div style="border: 1px solid #888888; width: '.$width.'px;"><img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&file='.$original_file.'" alt="" id="cropbox" /></div>'; print '</center><br>'; print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$_GET['id'].'" method="post" onsubmit="return checkCoords();"> <div class="jc_coords"> '.$langs->trans("NewSizeAfterCropping").': <label>X1 <input type="text" size="4" id="x" name="x" /></label> <label>Y1 <input type="text" size="4" id="y" name="y" /></label>
/** * Show photos of a product (nbmax maximum), into several columns * TODO Move this into html.formproduct.class.php * * @param string $sdir Directory to scan * @param int $size 0=original size, 1 use thumbnail if possible * @param int $nbmax Nombre maximum de photos (0=pas de max) * @param int $nbbyrow Number of image per line or -1 to use div. Used only if size=1. * @param int $showfilename 1=Show filename * @param int $showaction 1=Show icon with action links (resize, delete) * @param int $maxHeight Max height of image when size=1 * @param int $maxWidth Max width of image when size=1 * @return string Html code to show photo. Number of photos shown is saved in this->nbphoto */ function show_photos($sdir, $size = 0, $nbmax = 0, $nbbyrow = 5, $showfilename = 0, $showaction = 0, $maxHeight = 120, $maxWidth = 160) { global $conf, $user, $langs; include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; include_once DOL_DOCUMENT_ROOT . '/core/lib/images.lib.php'; $dir = $sdir . '/'; $pdir = '/'; if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) { $dir .= get_exdir($this->id, 2, 0, 0, $this, 'product') . $this->id . "/photos/"; $pdir .= get_exdir($this->id, 2, 0, 0, $this, 'product') . $this->id . "/photos/"; } else { $dir .= $this->ref . '/'; $pdir .= $this->ref . '/'; } $dirthumb = $dir . 'thumbs/'; $pdirthumb = $pdir . 'thumbs/'; $return = '<!-- Photo -->' . "\n"; $nbphoto = 0; $dir_osencoded = dol_osencode($dir); if (file_exists($dir_osencoded)) { $handle = opendir($dir_osencoded); if (is_resource($handle)) { while (($file = readdir($handle)) != false) { $photo = ''; if (!utf8_check($file)) { $file = utf8_encode($file); } // To be sure file is stored in UTF8 in memory if (dol_is_file($dir . $file) && preg_match('/(' . $this->regeximgext . ')$/i', $dir . $file)) { $nbphoto++; $photo = $file; $viewfilename = $file; if ($size == 1) { // Format vignette // On determine nom du fichier vignette $photo_vignette = ''; if (preg_match('/(\\.jpg|\\.bmp|\\.gif|\\.png|\\.tiff)$/i', $photo, $regs)) { $photo_vignette = preg_replace('/' . $regs[0] . '/i', '', $photo) . "_small" . $regs[0]; if (!dol_is_file($dirthumb . $photo_vignette)) { $photo_vignette = ''; } } // Get filesize of original file $imgarray = dol_getImageSize($dir . $photo); if ($nbbyrow > 0) { if ($nbphoto == 1) { $return .= '<table width="100%" valign="top" align="center" border="0" cellpadding="2" cellspacing="2">'; } if ($nbphoto % $nbbyrow == 1) { $return .= '<tr align=center valign=middle border=1>'; } $return .= '<td width="' . ceil(100 / $nbbyrow) . '%" class="photo">'; } else { if ($nbbyrow < 0) { $return .= '<div class="inline-block">'; } } $return .= "\n"; $return .= '<a href="' . DOL_URL_ROOT . '/viewimage.php?modulepart=product&entity=' . $this->entity . '&file=' . urlencode($pdir . $photo) . '" class="aphoto" target="_blank">'; // Show image (width height=$maxHeight) // Si fichier vignette disponible et image source trop grande, on utilise la vignette, sinon on utilise photo origine $alt = $langs->transnoentitiesnoconv('File') . ': ' . $pdir . $photo; $alt .= ' - ' . $langs->transnoentitiesnoconv('Size') . ': ' . $imgarray['width'] . 'x' . $imgarray['height']; if ($photo_vignette && $imgarray['height'] > $maxHeight) { $return .= '<!-- Show thumb -->'; $return .= '<img class="photo photowithmargin" border="0" ' . ($conf->dol_use_jmobile ? 'max-height' : 'height') . '="' . $maxHeight . '" src="' . DOL_URL_ROOT . '/viewimage.php?modulepart=product&entity=' . $this->entity . '&file=' . urlencode($pdirthumb . $photo_vignette) . '" title="' . dol_escape_htmltag($alt) . '">'; } else { $return .= '<!-- Show original file -->'; $return .= '<img class="photo photowithmargin" border="0" ' . ($conf->dol_use_jmobile ? 'max-height' : 'height') . '="' . $maxHeight . '" src="' . DOL_URL_ROOT . '/viewimage.php?modulepart=product&entity=' . $this->entity . '&file=' . urlencode($pdir . $photo) . '" title="' . dol_escape_htmltag($alt) . '">'; } $return .= '</a>' . "\n"; if ($showfilename) { $return .= '<br>' . $viewfilename; } if ($showaction) { $return .= '<br>'; // On propose la generation de la vignette si elle n'existe pas et si la taille est superieure aux limites if ($photo_vignette && preg_match('/(' . $this->regeximgext . ')$/i', $photo) && ($product->imgWidth > $maxWidth || $product->imgHeight > $maxHeight)) { $return .= '<a href="' . $_SERVER["PHP_SELF"] . '?id=' . $this->id . '&action=addthumb&file=' . urlencode($pdir . $viewfilename) . '">' . img_picto($langs->trans('GenerateThumb'), 'refresh') . ' </a>'; } if ($user->rights->produit->creer || $user->rights->service->creer) { // Link to resize $return .= '<a href="' . DOL_URL_ROOT . '/core/photos_resize.php?modulepart=' . urlencode('produit|service') . '&id=' . $this->id . '&file=' . urlencode($pdir . $viewfilename) . '" title="' . dol_escape_htmltag($langs->trans("Resize")) . '">' . img_picto($langs->trans("Resize"), DOL_URL_ROOT . '/theme/common/transform-crop-and-resize', '', 1) . '</a> '; // Link to delete $return .= '<a href="' . $_SERVER["PHP_SELF"] . '?id=' . $this->id . '&action=delete&file=' . urlencode($pdir . $viewfilename) . '">'; $return .= img_delete() . '</a>'; } } $return .= "\n"; if ($nbbyrow > 0) { $return .= '</td>'; if ($nbphoto % $nbbyrow == 0) { $return .= '</tr>'; } } else { if ($nbbyrow < 0) { $return .= '</div>'; } } } if ($size == 0) { // Format origine $return .= '<img class="photo photowithmargin" border="0" src="' . DOL_URL_ROOT . '/viewimage.php?modulepart=product&entity=' . $this->entity . '&file=' . urlencode($pdir . $photo) . '">'; if ($showfilename) { $return .= '<br>' . $viewfilename; } if ($showaction) { if ($user->rights->produit->creer || $user->rights->service->creer) { // Link to resize $return .= '<a href="' . DOL_URL_ROOT . '/core/photos_resize.php?modulepart=' . urlencode('produit|service') . '&id=' . $this->id . '&file=' . urlencode($pdir . $viewfilename) . '" title="' . dol_escape_htmltag($langs->trans("Resize")) . '">' . img_picto($langs->trans("Resize"), DOL_URL_ROOT . '/theme/common/transform-crop-and-resize', '', 1) . '</a> '; // Link to delete $return .= '<a href="' . $_SERVER["PHP_SELF"] . '?id=' . $this->id . '&action=delete&file=' . urlencode($pdir . $viewfilename) . '">'; $return .= img_delete() . '</a>'; } } } // On continue ou on arrete de boucler ? if ($nbmax && $nbphoto >= $nbmax) { break; } } } } if ($size == 1) { if ($nbbyrow > 0) { // Ferme tableau while ($nbphoto % $nbbyrow) { $return .= '<td width="' . ceil(100 / $nbbyrow) . '%"> </td>'; $nbphoto++; } if ($nbphoto) { $return .= '</table>'; } } } closedir($handle); } $this->nbphoto = $nbphoto; return $return; }
/** * Show photos of a product (nbmax maximum), into several columns * TODO Move this into html.formproduct.class.php * * @param string $sdir Directory to scan * @param int $size 0=original size, 1 use thumbnail if possible * @param int $nbmax Nombre maximum de photos (0=pas de max) * @param int $nbbyrow Nombre vignettes par ligne (si mode vignette) * @param int $showfilename 1=Show filename * @param int $showaction 1=Show icon with action links (resize, delete) * @param int $maxHeight Max height of image when size=1 * @param int $maxWidth Max width of image when size=1 * @return string Html code to show photo. Number of photos shown is saved in this->nbphoto */ function show_photos($sdir,$size=0,$nbmax=0,$nbbyrow=5,$showfilename=0,$showaction=0,$maxHeight=120,$maxWidth=160) { global $conf,$user,$langs; include_once(DOL_DOCUMENT_ROOT ."/core/lib/files.lib.php"); include_once(DOL_DOCUMENT_ROOT ."/core/lib/images.lib.php"); $pdir = get_exdir($this->id,2) . $this->id ."/photos/"; $dir = $sdir . '/'. $pdir; $dirthumb = $dir.'thumbs/'; $pdirthumb = $pdir.'thumbs/'; $return ='<!-- Photo -->'."\n"; /*$return.="<script type=\"text/javascript\"> jQuery(function() { jQuery('a.lightbox').lightBox({ overlayBgColor: '#888', overlayOpacity: 0.6, imageLoading: '".DOL_URL_ROOT."/theme/eldy/img/working.gif', imageBtnClose: '".DOL_URL_ROOT."/theme/eldy/img/previous.png', imageBtnPrev: '".DOL_URL_ROOT."/theme/eldy/img/1leftarrow.png', imageBtnNext: '".DOL_URL_ROOT."/theme/eldy/img/1rightarrow.png', containerResizeSpeed: 350, txtImage: '".$langs->trans("Image")."', txtOf: '".$langs->trans("on")."', fixedNavigation:false }); }); </script>\n"; */ $nbphoto=0; $dir_osencoded=dol_osencode($dir); if (file_exists($dir_osencoded)) { $handle=opendir($dir_osencoded); if (is_resource($handle)) { while (($file = readdir($handle)) != false) { $photo=''; if (! utf8_check($file)) $file=utf8_encode($file); // To be sure file is stored in UTF8 in memory if (dol_is_file($dir.$file) && preg_match('/(\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i', $dir.$file)) { $nbphoto++; $photo = $file; $viewfilename = $file; if ($size == 1) { // Format vignette // On determine nom du fichier vignette $photo_vignette=''; if (preg_match('/(\.jpg|\.bmp|\.gif|\.png|\.tiff)$/i', $photo, $regs)) { $photo_vignette=preg_replace('/'.$regs[0].'/i', '', $photo)."_small".$regs[0]; if (! dol_is_file($dirthumb.$photo_vignette)) $photo_vignette=''; } // Get filesize of original file $imgarray=dol_getImageSize($dir.$photo); if ($nbbyrow && $nbphoto == 1) $return.= '<table width="100%" valign="top" align="center" border="0" cellpadding="2" cellspacing="2">'; if ($nbbyrow && ($nbphoto % $nbbyrow == 1)) $return.= '<tr align=center valign=middle border=1>'; if ($nbbyrow) $return.= '<td width="'.ceil(100/$nbbyrow).'%" class="photo">'; $return.= "\n"; $return.= '<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&entity='.$this->entity.'&file='.urlencode($pdir.$photo).'" class="lightbox" target="_blank">'; // Show image (width height=$maxHeight) // Si fichier vignette disponible et image source trop grande, on utilise la vignette, sinon on utilise photo origine $alt=$langs->transnoentitiesnoconv('File').': '.$pdir.$photo; $alt.=' - '.$langs->transnoentitiesnoconv('Size').': '.$imgarray['width'].'x'.$imgarray['height']; if ($photo_vignette && $imgarray['height'] > $maxHeight) { $return.= '<!-- Show thumb -->'; $return.= '<img class="photo" border="0" height="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&entity='.$this->entity.'&file='.urlencode($pdirthumb.$photo_vignette).'" title="'.dol_escape_htmltag($alt).'">'; } else { $return.= '<!-- Show original file -->'; $return.= '<img class="photo" border="0" height="'.$maxHeight.'" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&entity='.$this->entity.'&file='.urlencode($pdir.$photo).'" title="'.dol_escape_htmltag($alt).'">'; } $return.= '</a>'."\n"; if ($showfilename) $return.= '<br>'.$viewfilename; if ($showaction) { $return.= '<br>'; // On propose la generation de la vignette si elle n'existe pas et si la taille est superieure aux limites if ($photo_vignette && preg_match('/(\.bmp|\.gif|\.jpg|\.jpeg|\.png)$/i', $photo) && ($product->imgWidth > $maxWidth || $product->imgHeight > $maxHeight)) { $return.= '<a href="'.$_SERVER["PHP_SELF"].'?id='.$_GET["id"].'&action=addthumb&file='.urlencode($pdir.$viewfilename).'">'.img_picto($langs->trans('GenerateThumb'),'refresh').' </a>'; } if ($user->rights->produit->creer || $user->rights->service->creer) { // Link to resize $return.= '<a href="'.DOL_URL_ROOT.'/core/photos_resize.php?modulepart='.urlencode('produit|service').'&id='.$_GET["id"].'&file='.urlencode($pdir.$viewfilename).'" title="'.dol_escape_htmltag($langs->trans("Resize")).'">'.img_picto($langs->trans("Resize"),DOL_URL_ROOT.'/theme/common/transform-crop-and-resize','',1).'</a> '; // Link to delete $return.= '<a href="'.$_SERVER["PHP_SELF"].'?id='.$_GET["id"].'&action=delete&file='.urlencode($pdir.$viewfilename).'">'; $return.= img_delete().'</a>'; } } $return.= "\n"; if ($nbbyrow) $return.= '</td>'; if ($nbbyrow && ($nbphoto % $nbbyrow == 0)) $return.= '</tr>'; } if ($size == 0) { // Format origine $return.= '<img class="photo" border="0" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&entity='.$this->entity.'&file='.urlencode($pdir.$photo).'">'; if ($showfilename) $return.= '<br>'.$viewfilename; if ($showaction) { if ($user->rights->produit->creer || $user->rights->service->creer) { // Link to resize $return.= '<a href="'.DOL_URL_ROOT.'/core/photos_resize.php?modulepart='.urlencode('produit|service').'&id='.$_GET["id"].'&file='.urlencode($pdir.$viewfilename).'" title="'.dol_escape_htmltag($langs->trans("Resize")).'">'.img_picto($langs->trans("Resize"),DOL_URL_ROOT.'/theme/common/transform-crop-and-resize','',1).'</a> '; // Link to delete $return.= '<a href="'.$_SERVER["PHP_SELF"].'?id='.$_GET["id"].'&action=delete&file='.urlencode($pdir.$viewfilename).'">'; $return.= img_delete().'</a>'; } } } // On continue ou on arrete de boucler ? if ($nbmax && $nbphoto >= $nbmax) break; } } } if ($nbbyrow && $size==1) { // Ferme tableau while ($nbphoto % $nbbyrow) { $return.= '<td width="'.ceil(100/$nbbyrow).'%"> </td>'; $nbphoto++; } if ($nbphoto) $return.= '</table>'; } closedir($handle); } $this->nbphoto = $nbphoto; return $return; }
/** * 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_label(&$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 == '') { // 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 { $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 { // 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; } }
/** * Return height to use for Logo onot PDF * * @param string $logo Full path to logo file to use * @return number */ function pdf_getHeightForLogo($logo) { $height = 22; $maxwidth = 130; include_once DOL_DOCUMENT_ROOT . '/core/lib/images.lib.php'; $tmp = dol_getImageSize($logo); if ($tmp['height']) { $width = round($height * $tmp['width'] / $tmp['height']); if ($width > $maxwidth) { $height = $height * $maxwidth / $width; } } //print $tmp['width'].' '.$tmp['height'].' '.$width; exit; return $height; }
/** * testDolCountNbOfLine * * @return int */ public function testgetImageSize() { $file=dirname(__FILE__).'/img250x50.jpg'; $tmp=dol_getImageSize($file); print __METHOD__." result=".$tmp['width'].'/'.$tmp['height']."\n"; $this->assertEquals($tmp['width'],250); $this->assertEquals($tmp['height'],50); $file=dirname(__FILE__).'/img250x20.png'; $tmp=dol_getImageSize($file); print __METHOD__." result=".$tmp['width'].'/'.$tmp['height']."\n"; $this->assertEquals($tmp['width'],250); $this->assertEquals($tmp['height'],20); /*$file=dirname(__FILE__).'/filenotfound.png'; $tmp=dol_getImageSize($file); print __METHOD__." result=".$tmp['width'].'/'.$tmp['height']."\n"; $this->assertEquals($tmp['width'],250); $this->assertEquals($tmp['height'],20);*/ return $result; }