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