1<?php 2namespace Fisharebest\Webtrees\Report; 3 4/** 5 * webtrees: online genealogy 6 * Copyright (C) 2015 webtrees development team 7 * This program is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation, either version 3 of the License, or 10 * (at your option) any later version. 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * You should have received a copy of the GNU General Public License 16 * along with this program. If not, see <http://www.gnu.org/licenses/>. 17 */ 18 19/** 20 * Class ReportPdfImage 21 */ 22class ReportPdfImage extends ReportBaseImage { 23 /** 24 * PDF image renderer 25 * 26 * @param ReportTcpdf $renderer 27 */ 28 public function render($renderer) { 29 global $lastpicbottom, $lastpicpage, $lastpicleft, $lastpicright; 30 31 // Check for a pagebreak first 32 if ($renderer->checkPageBreakPDF($this->height + 5)) { 33 $this->y = $renderer->GetY(); 34 } 35 36 $curx = $renderer->GetX(); 37 // If current position (left)set "." 38 if ($this->x == ".") { 39 $this->x = $renderer->GetX(); 40 } // For static position add margin 41 else { 42 $this->x = $renderer->addMarginX($this->x); 43 $renderer->SetX($curx); 44 } 45 if ($this->y == ".") { 46 //-- first check for a collision with the last picture 47 if (isset($lastpicbottom)) { 48 if (($renderer->PageNo() == $lastpicpage) && ($lastpicbottom >= $renderer->GetY()) && ($this->x >= $lastpicleft) && ($this->x <= $lastpicright) 49 ) { 50 $renderer->SetY($lastpicbottom + 5); 51 } 52 } 53 $this->y = $renderer->GetY(); 54 } else { 55 $renderer->SetY($this->y); 56 } 57 if ($renderer->getRTL()) { 58 $renderer->Image( 59 $this->file, 60 $renderer->getPageWidth() - $this->x, 61 $this->y, 62 $this->width, 63 $this->height, 64 "", 65 "", 66 $this->line, 67 false, 68 72, 69 $this->align 70 ); 71 } else { 72 $renderer->Image( 73 $this->file, 74 $this->x, 75 $this->y, 76 $this->width, 77 $this->height, 78 "", 79 "", 80 $this->line, 81 false, 82 72, 83 $this->align 84 ); 85 } 86 $lastpicpage = $renderer->PageNo(); 87 $renderer->lastpicpage = $renderer->getPage(); 88 $lastpicleft = $this->x; 89 $lastpicright = $this->x + $this->width; 90 $lastpicbottom = $this->y + $this->height; 91 // Setup for the next line 92 if ($this->line == "N") { 93 $renderer->SetY($lastpicbottom); 94 } 95 } 96 97 /** 98 * Get the image height 99 * 100 * @param ReportTcpdf $pdf 101 * 102 * @return float 103 */ 104 public function getHeight($pdf) { 105 return $this->height; 106 } 107 108 /** 109 * @param $pdf 110 * 111 * @return float 112 */ 113 public function getWidth($pdf) { 114 return $this->width; 115 } 116} 117