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