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 /** 24 * PDF image renderer 25 * 26 * @param ReportTcpdf $renderer 27 */ 28 public function render($renderer) 29 { 30 global $lastpicbottom, $lastpicpage, $lastpicleft, $lastpicright; 31 32 // Check for a pagebreak first 33 if ($renderer->checkPageBreakPDF($this->height + 5)) { 34 $this->y = $renderer->GetY(); 35 } 36 37 $curx = $renderer->GetX(); 38 // If current position (left)set "." 39 if ($this->x == '.') { 40 $this->x = $renderer->GetX(); 41 } else { 42 // For static position add margin 43 $this->x = $renderer->addMarginX($this->x); 44 $renderer->SetX($curx); 45 } 46 if ($this->y == '.') { 47 //-- first check for a collision with the last picture 48 if (isset($lastpicbottom)) { 49 if (($renderer->PageNo() == $lastpicpage) && ($lastpicbottom >= $renderer->GetY()) && ($this->x >= $lastpicleft) && ($this->x <= $lastpicright) 50 ) { 51 $renderer->SetY($lastpicbottom + 5); 52 } 53 } 54 $this->y = $renderer->GetY(); 55 } else { 56 $renderer->SetY($this->y); 57 } 58 if ($renderer->getRTL()) { 59 $renderer->Image( 60 $this->file, 61 $renderer->getPageWidth() - $this->x, 62 $this->y, 63 $this->width, 64 $this->height, 65 '', 66 '', 67 $this->line, 68 false, 69 72, 70 $this->align 71 ); 72 } else { 73 $renderer->Image( 74 $this->file, 75 $this->x, 76 $this->y, 77 $this->width, 78 $this->height, 79 '', 80 '', 81 $this->line, 82 false, 83 72, 84 $this->align 85 ); 86 } 87 $lastpicpage = $renderer->PageNo(); 88 $renderer->lastpicpage = $renderer->getPage(); 89 $lastpicleft = $this->x; 90 $lastpicright = $this->x + $this->width; 91 $lastpicbottom = $this->y + $this->height; 92 // Setup for the next line 93 if ($this->line == 'N') { 94 $renderer->SetY($lastpicbottom); 95 } 96 } 97 98 /** 99 * Get the image height 100 * 101 * @param ReportTcpdf $pdf 102 * 103 * @return float 104 */ 105 public function getHeight($pdf) 106 { 107 return $this->height; 108 } 109 110 /** 111 * Get the image width. 112 * 113 * @param $pdf 114 * 115 * @return float 116 */ 117 public function getWidth($pdf) 118 { 119 return $this->width; 120 } 121} 122