1b6f35a76SGreg Roach<?php 2b6f35a76SGreg Roach 3b6f35a76SGreg Roach/** 4b6f35a76SGreg Roach * webtrees: online genealogy 55bfc6897SGreg Roach * Copyright (C) 2022 webtrees development team 6b6f35a76SGreg Roach * This program is free software: you can redistribute it and/or modify 7b6f35a76SGreg Roach * it under the terms of the GNU General Public License as published by 8b6f35a76SGreg Roach * the Free Software Foundation, either version 3 of the License, or 9b6f35a76SGreg Roach * (at your option) any later version. 10b6f35a76SGreg Roach * This program is distributed in the hope that it will be useful, 11b6f35a76SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 12b6f35a76SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13b6f35a76SGreg Roach * GNU General Public License for more details. 14b6f35a76SGreg Roach * You should have received a copy of the GNU General Public License 1589f7189bSGreg Roach * along with this program. If not, see <https://www.gnu.org/licenses/>. 16b6f35a76SGreg Roach */ 17b6f35a76SGreg Roach 18b6f35a76SGreg Roachdeclare(strict_types=1); 19b6f35a76SGreg Roach 20b6f35a76SGreg Roachnamespace Fisharebest\Webtrees\Report; 21b6f35a76SGreg Roach 22b6f35a76SGreg Roachuse Fisharebest\Webtrees\MediaFile; 23b6f35a76SGreg Roachuse Fisharebest\Webtrees\Webtrees; 24b6f35a76SGreg Roach 25b6f35a76SGreg Roachuse function count; 26b6f35a76SGreg Roach 27b6f35a76SGreg Roach/** 28b6f35a76SGreg Roach * Class PdfRenderer 29b6f35a76SGreg Roach */ 30b6f35a76SGreg Roachclass PdfRenderer extends AbstractRenderer 31b6f35a76SGreg Roach{ 32b6f35a76SGreg Roach /** 33b6f35a76SGreg Roach * PDF compression - Zlib extension is required 34b6f35a76SGreg Roach * 35b6f35a76SGreg Roach * @var bool const 36b6f35a76SGreg Roach */ 37b6f35a76SGreg Roach private const COMPRESSION = true; 38b6f35a76SGreg Roach 39b6f35a76SGreg Roach /** 40b6f35a76SGreg Roach * If true reduce the RAM memory usage by caching temporary data on filesystem (slower). 41b6f35a76SGreg Roach * 42b6f35a76SGreg Roach * @var bool const 43b6f35a76SGreg Roach */ 44b6f35a76SGreg Roach private const DISK_CACHE = false; 45b6f35a76SGreg Roach 46b6f35a76SGreg Roach /** 47b6f35a76SGreg Roach * true means that the input text is unicode (PDF) 48b6f35a76SGreg Roach * 49b6f35a76SGreg Roach * @var bool const 50b6f35a76SGreg Roach */ 51b6f35a76SGreg Roach private const UNICODE = true; 52b6f35a76SGreg Roach 53345fcc8aSGreg Roach // Font sub-setting in TCPDF is slow. 54b6f35a76SGreg Roach private const SUBSETTING = false; 55b6f35a76SGreg Roach 56345fcc8aSGreg Roach public TcpdfWrapper $tcpdf; 57b6f35a76SGreg Roach 58345fcc8aSGreg Roach /** @var array<ReportPdfFootnote> Array of elements in the footer notes */ 59345fcc8aSGreg Roach public array $printedfootnotes = []; 60b6f35a76SGreg Roach 610a709a28SGreg Roach // The last cell height 62345fcc8aSGreg Roach public float $lastCellHeight = 0.0; 63b6f35a76SGreg Roach 640a709a28SGreg Roach // The largest font size within a TextBox to calculate the height 65345fcc8aSGreg Roach public float $largestFontHeight = 0.0; 66b6f35a76SGreg Roach 670a709a28SGreg Roach // The last pictures page number 68345fcc8aSGreg Roach public int $lastpicpage = 0; 69b6f35a76SGreg Roach 70b6f35a76SGreg Roach /** 71b6f35a76SGreg Roach * PDF Header -PDF 72b6f35a76SGreg Roach * 73b6f35a76SGreg Roach * @return void 74b6f35a76SGreg Roach */ 75b6f35a76SGreg Roach public function header(): void 76b6f35a76SGreg Roach { 77b6f35a76SGreg Roach foreach ($this->headerElements as $element) { 78b6f35a76SGreg Roach if ($element instanceof ReportBaseElement) { 79b6f35a76SGreg Roach $element->render($this); 80b6f35a76SGreg Roach } elseif ($element === 'footnotetexts') { 81b6f35a76SGreg Roach $this->footnotes(); 82b6f35a76SGreg Roach } elseif ($element === 'addpage') { 83b6f35a76SGreg Roach $this->newPage(); 84b6f35a76SGreg Roach } 85b6f35a76SGreg Roach } 86b6f35a76SGreg Roach } 87b6f35a76SGreg Roach 88b6f35a76SGreg Roach /** 89b6f35a76SGreg Roach * PDF Body -PDF 90b6f35a76SGreg Roach * 91b6f35a76SGreg Roach * @return void 92b6f35a76SGreg Roach */ 93b6f35a76SGreg Roach public function body(): void 94b6f35a76SGreg Roach { 95b6f35a76SGreg Roach $this->tcpdf->AddPage(); 96b6f35a76SGreg Roach 9777bab461SGreg Roach foreach ($this->bodyElements as $element) { 98b6f35a76SGreg Roach if ($element instanceof ReportBaseElement) { 99b6f35a76SGreg Roach $element->render($this); 100b6f35a76SGreg Roach } elseif ($element === 'footnotetexts') { 101b6f35a76SGreg Roach $this->footnotes(); 102b6f35a76SGreg Roach } elseif ($element === 'addpage') { 103b6f35a76SGreg Roach $this->newPage(); 104b6f35a76SGreg Roach } 105b6f35a76SGreg Roach } 106b6f35a76SGreg Roach } 107b6f35a76SGreg Roach 108b6f35a76SGreg Roach /** 10977bab461SGreg Roach * Generate footnotes 110b6f35a76SGreg Roach * 111b6f35a76SGreg Roach * @return void 112b6f35a76SGreg Roach */ 113b6f35a76SGreg Roach public function footnotes(): void 114b6f35a76SGreg Roach { 115b6f35a76SGreg Roach foreach ($this->printedfootnotes as $element) { 11652135727SGreg Roach if ($this->tcpdf->GetY() + $element->getFootnoteHeight($this) > $this->tcpdf->getPageHeight()) { 117b6f35a76SGreg Roach $this->tcpdf->AddPage(); 118b6f35a76SGreg Roach } 119b6f35a76SGreg Roach 120b6f35a76SGreg Roach $element->renderFootnote($this); 121b6f35a76SGreg Roach 122b6f35a76SGreg Roach if ($this->tcpdf->GetY() > $this->tcpdf->getPageHeight()) { 123b6f35a76SGreg Roach $this->tcpdf->AddPage(); 124b6f35a76SGreg Roach } 125b6f35a76SGreg Roach } 126b6f35a76SGreg Roach } 127b6f35a76SGreg Roach 128b6f35a76SGreg Roach /** 129b6f35a76SGreg Roach * PDF Footer -PDF 130b6f35a76SGreg Roach * 131b6f35a76SGreg Roach * @return void 132b6f35a76SGreg Roach */ 133b6f35a76SGreg Roach public function footer(): void 134b6f35a76SGreg Roach { 135b6f35a76SGreg Roach foreach ($this->footerElements as $element) { 136b6f35a76SGreg Roach if ($element instanceof ReportBaseElement) { 137b6f35a76SGreg Roach $element->render($this); 138b6f35a76SGreg Roach } elseif ($element === 'footnotetexts') { 139b6f35a76SGreg Roach $this->footnotes(); 140b6f35a76SGreg Roach } elseif ($element === 'addpage') { 141b6f35a76SGreg Roach $this->newPage(); 142b6f35a76SGreg Roach } 143b6f35a76SGreg Roach } 144b6f35a76SGreg Roach } 145b6f35a76SGreg Roach 146b6f35a76SGreg Roach /** 147b6f35a76SGreg Roach * Remove the header. 148b6f35a76SGreg Roach * 149b6f35a76SGreg Roach * @param int $index 150b6f35a76SGreg Roach * 151b6f35a76SGreg Roach * @return void 152b6f35a76SGreg Roach */ 153b6f35a76SGreg Roach public function removeHeader(int $index): void 154b6f35a76SGreg Roach { 155b6f35a76SGreg Roach unset($this->headerElements[$index]); 156b6f35a76SGreg Roach } 157b6f35a76SGreg Roach 158b6f35a76SGreg Roach /** 159b6f35a76SGreg Roach * Remove the body. 160b6f35a76SGreg Roach * 161b6f35a76SGreg Roach * @param int $index 162b6f35a76SGreg Roach * 163b6f35a76SGreg Roach * @return void 164b6f35a76SGreg Roach */ 165b6f35a76SGreg Roach public function removeBody(int $index): void 166b6f35a76SGreg Roach { 167b6f35a76SGreg Roach unset($this->bodyElements[$index]); 168b6f35a76SGreg Roach } 169b6f35a76SGreg Roach 170b6f35a76SGreg Roach /** 171b6f35a76SGreg Roach * Clear the Header -PDF 172b6f35a76SGreg Roach * 173b6f35a76SGreg Roach * @return void 174b6f35a76SGreg Roach */ 175b6f35a76SGreg Roach public function clearHeader(): void 176b6f35a76SGreg Roach { 177b6f35a76SGreg Roach unset($this->headerElements); 178b6f35a76SGreg Roach $this->headerElements = []; 179b6f35a76SGreg Roach } 180b6f35a76SGreg Roach 181b6f35a76SGreg Roach /** 182b6f35a76SGreg Roach * Get the currently used style name -PDF 183b6f35a76SGreg Roach * 184b6f35a76SGreg Roach * @return string 185b6f35a76SGreg Roach */ 186b6f35a76SGreg Roach public function getCurrentStyle(): string 187b6f35a76SGreg Roach { 188b6f35a76SGreg Roach return $this->currentStyle; 189b6f35a76SGreg Roach } 190b6f35a76SGreg Roach 191b6f35a76SGreg Roach /** 192b6f35a76SGreg Roach * Setup a style for usage -PDF 193b6f35a76SGreg Roach * 194b6f35a76SGreg Roach * @param string $s Style name 195b6f35a76SGreg Roach * 196b6f35a76SGreg Roach * @return void 197b6f35a76SGreg Roach */ 198b6f35a76SGreg Roach public function setCurrentStyle(string $s): void 199b6f35a76SGreg Roach { 200b6f35a76SGreg Roach $this->currentStyle = $s; 201ceab9748SGreg Roach $style = $this->getStyle($s); 202b4c5c807SGreg Roach $this->tcpdf->setFont($style['font'], $style['style'], $style['size']); 203b6f35a76SGreg Roach } 204b6f35a76SGreg Roach 205b6f35a76SGreg Roach /** 206b6f35a76SGreg Roach * Get the style -PDF 207b6f35a76SGreg Roach * 208b6f35a76SGreg Roach * @param string $s Style name 209b6f35a76SGreg Roach * 21076d39c55SGreg Roach * @return array<string,string> 211b6f35a76SGreg Roach */ 212b6f35a76SGreg Roach public function getStyle(string $s): array 213b6f35a76SGreg Roach { 214ceab9748SGreg Roach if (!isset($this->styles[$s])) { 215b6f35a76SGreg Roach $s = $this->getCurrentStyle(); 216ceab9748SGreg Roach $this->styles[$s] = $s; 217b6f35a76SGreg Roach } 218b6f35a76SGreg Roach 219ceab9748SGreg Roach return $this->styles[$s]; 220b6f35a76SGreg Roach } 221b6f35a76SGreg Roach 222b6f35a76SGreg Roach /** 223b6f35a76SGreg Roach * Add margin when static horizontal position is used -PDF 224b6f35a76SGreg Roach * RTL supported 225b6f35a76SGreg Roach * 226b6f35a76SGreg Roach * @param float $x Static position 227b6f35a76SGreg Roach * 228b6f35a76SGreg Roach * @return float 229b6f35a76SGreg Roach */ 230b6f35a76SGreg Roach public function addMarginX(float $x): float 231b6f35a76SGreg Roach { 232b6f35a76SGreg Roach $m = $this->tcpdf->getMargins(); 233b6f35a76SGreg Roach if ($this->tcpdf->getRTL()) { 234b6f35a76SGreg Roach $x += $m['right']; 235b6f35a76SGreg Roach } else { 236b6f35a76SGreg Roach $x += $m['left']; 237b6f35a76SGreg Roach } 238b4c5c807SGreg Roach $this->tcpdf->setX($x); 239b6f35a76SGreg Roach 240b6f35a76SGreg Roach return $x; 241b6f35a76SGreg Roach } 242b6f35a76SGreg Roach 243b6f35a76SGreg Roach /** 244b6f35a76SGreg Roach * Get the maximum line width to draw from the curren position -PDF 245b6f35a76SGreg Roach * RTL supported 246b6f35a76SGreg Roach * 247b6f35a76SGreg Roach * @return float 248b6f35a76SGreg Roach */ 249b6f35a76SGreg Roach public function getMaxLineWidth(): float 250b6f35a76SGreg Roach { 251b6f35a76SGreg Roach $m = $this->tcpdf->getMargins(); 252b6f35a76SGreg Roach if ($this->tcpdf->getRTL()) { 25352135727SGreg Roach return $this->tcpdf->getRemainingWidth() + $m['right']; 254b6f35a76SGreg Roach } 255b6f35a76SGreg Roach 25652135727SGreg Roach return $this->tcpdf->getRemainingWidth() + $m['left']; 257b6f35a76SGreg Roach } 258b6f35a76SGreg Roach 259b6f35a76SGreg Roach /** 260b6f35a76SGreg Roach * Get the height of the footnote. 261b6f35a76SGreg Roach * 262b6f35a76SGreg Roach * @return float 263b6f35a76SGreg Roach */ 264b6f35a76SGreg Roach public function getFootnotesHeight(): float 265b6f35a76SGreg Roach { 266b6f35a76SGreg Roach $h = 0; 267b6f35a76SGreg Roach foreach ($this->printedfootnotes as $element) { 268b6f35a76SGreg Roach $h += $element->getHeight($this); 269b6f35a76SGreg Roach } 270b6f35a76SGreg Roach 271b6f35a76SGreg Roach return $h; 272b6f35a76SGreg Roach } 273b6f35a76SGreg Roach 274b6f35a76SGreg Roach /** 275b6f35a76SGreg Roach * Returns the the current font size height -PDF 276b6f35a76SGreg Roach * 277b6f35a76SGreg Roach * @return float 278b6f35a76SGreg Roach */ 279b6f35a76SGreg Roach public function getCurrentStyleHeight(): float 280b6f35a76SGreg Roach { 281b6f35a76SGreg Roach if ($this->currentStyle === '') { 282ceab9748SGreg Roach return $this->default_font_size; 283b6f35a76SGreg Roach } 284ceab9748SGreg Roach $style = $this->getStyle($this->currentStyle); 285b6f35a76SGreg Roach 286b6f35a76SGreg Roach return (float) $style['size']; 287b6f35a76SGreg Roach } 288b6f35a76SGreg Roach 289b6f35a76SGreg Roach /** 290b6f35a76SGreg Roach * Checks the Footnote and numbers them 291b6f35a76SGreg Roach * 292b6f35a76SGreg Roach * @param ReportPdfFootnote $footnote 293b6f35a76SGreg Roach * 294b6f35a76SGreg Roach * @return ReportPdfFootnote|bool object if already numbered, false otherwise 295b6f35a76SGreg Roach */ 296b6f35a76SGreg Roach public function checkFootnote(ReportPdfFootnote $footnote) 297b6f35a76SGreg Roach { 298b6f35a76SGreg Roach $ct = count($this->printedfootnotes); 299b6f35a76SGreg Roach $val = $footnote->getValue(); 300b6f35a76SGreg Roach $i = 0; 301b6f35a76SGreg Roach while ($i < $ct) { 30277bab461SGreg Roach if ($this->printedfootnotes[$i]->getValue() === $val) { 303b6f35a76SGreg Roach // If this footnote already exist then set up the numbers for this object 304b6f35a76SGreg Roach $footnote->setNum($i + 1); 305b6f35a76SGreg Roach $footnote->setAddlink((string) ($i + 1)); 306b6f35a76SGreg Roach 307b6f35a76SGreg Roach return $this->printedfootnotes[$i]; 308b6f35a76SGreg Roach } 309b6f35a76SGreg Roach $i++; 310b6f35a76SGreg Roach } 311b6f35a76SGreg Roach // If this Footnote has not been set up yet 312b6f35a76SGreg Roach $footnote->setNum($ct + 1); 313b6f35a76SGreg Roach $footnote->setAddlink((string) $this->tcpdf->AddLink()); 314b6f35a76SGreg Roach $this->printedfootnotes[] = $footnote; 315b6f35a76SGreg Roach 316b6f35a76SGreg Roach return false; 317b6f35a76SGreg Roach } 318b6f35a76SGreg Roach 319b6f35a76SGreg Roach /** 320b6f35a76SGreg Roach * Used this function instead of AddPage() 321b6f35a76SGreg Roach * This function will make sure that images will not be overwritten 322b6f35a76SGreg Roach * 323b6f35a76SGreg Roach * @return void 324b6f35a76SGreg Roach */ 325b6f35a76SGreg Roach public function newPage(): void 326b6f35a76SGreg Roach { 327b6f35a76SGreg Roach if ($this->lastpicpage > $this->tcpdf->getPage()) { 328b6f35a76SGreg Roach $this->tcpdf->setPage($this->lastpicpage); 329b6f35a76SGreg Roach } 330b6f35a76SGreg Roach $this->tcpdf->AddPage(); 331b6f35a76SGreg Roach } 332b6f35a76SGreg Roach 333b6f35a76SGreg Roach /** 334b6f35a76SGreg Roach * Add a page if needed -PDF 335b6f35a76SGreg Roach * 336b6f35a76SGreg Roach * @param float $height Cell height 337b6f35a76SGreg Roach * 338b6f35a76SGreg Roach * @return bool true in case of page break, false otherwise 339b6f35a76SGreg Roach */ 340b6f35a76SGreg Roach public function checkPageBreakPDF(float $height): bool 341b6f35a76SGreg Roach { 342b6f35a76SGreg Roach return $this->tcpdf->checkPageBreak($height); 343b6f35a76SGreg Roach } 344b6f35a76SGreg Roach 345b6f35a76SGreg Roach /** 346b6f35a76SGreg Roach * Returns the remaining width between the current position and margins -PDF 347b6f35a76SGreg Roach * 348b6f35a76SGreg Roach * @return float Remaining width 349b6f35a76SGreg Roach */ 350b6f35a76SGreg Roach public function getRemainingWidthPDF(): float 351b6f35a76SGreg Roach { 352b6f35a76SGreg Roach return $this->tcpdf->getRemainingWidth(); 353b6f35a76SGreg Roach } 354b6f35a76SGreg Roach /** 355b6f35a76SGreg Roach * PDF Setup - ReportPdf 356b6f35a76SGreg Roach * 357b6f35a76SGreg Roach * @return void 358b6f35a76SGreg Roach */ 359b6f35a76SGreg Roach public function setup(): void 360b6f35a76SGreg Roach { 361b6f35a76SGreg Roach parent::setup(); 362b6f35a76SGreg Roach 363345fcc8aSGreg Roach $this->tcpdf = new TcpdfWrapper( 364345fcc8aSGreg Roach $this->orientation, 365345fcc8aSGreg Roach self::UNITS, 366345fcc8aSGreg Roach [$this->page_width, $this->page_height], 367345fcc8aSGreg Roach self::UNICODE, 368345fcc8aSGreg Roach 'UTF-8', 369345fcc8aSGreg Roach self::DISK_CACHE 370345fcc8aSGreg Roach ); 371b6f35a76SGreg Roach 372b4c5c807SGreg Roach $this->tcpdf->setMargins($this->left_margin, $this->top_margin, $this->right_margin); 373b6f35a76SGreg Roach $this->tcpdf->setHeaderMargin($this->header_margin); 374b6f35a76SGreg Roach $this->tcpdf->setFooterMargin($this->footer_margin); 375b4c5c807SGreg Roach $this->tcpdf->setAutoPageBreak(true, $this->bottom_margin); 376b6f35a76SGreg Roach $this->tcpdf->setFontSubsetting(self::SUBSETTING); 377b4c5c807SGreg Roach $this->tcpdf->setCompression(self::COMPRESSION); 378b6f35a76SGreg Roach $this->tcpdf->setRTL($this->rtl); 379b4c5c807SGreg Roach $this->tcpdf->setCreator(Webtrees::NAME . ' ' . Webtrees::VERSION); 380b4c5c807SGreg Roach $this->tcpdf->setAuthor($this->rauthor); 381b4c5c807SGreg Roach $this->tcpdf->setTitle($this->title); 382b4c5c807SGreg Roach $this->tcpdf->setSubject($this->rsubject); 383b4c5c807SGreg Roach $this->tcpdf->setKeywords($this->rkeywords); 384b4c5c807SGreg Roach $this->tcpdf->setHeaderData('', 0, $this->title); 385f6351d1fSGreg Roach $this->tcpdf->setHeaderFont([$this->default_font, '', $this->default_font_size]); 386b6f35a76SGreg Roach 387b6f35a76SGreg Roach if ($this->show_generated_by) { 388b6f35a76SGreg Roach // The default style name for Generated by.... is 'genby' 38977bab461SGreg Roach $element = new ReportPdfCell(0.0, 10.0, '', 'C', '', 'genby', 1, ReportBaseElement::CURRENT_POSITION, ReportBaseElement::CURRENT_POSITION, 0, 0, '', '', true); 390b6f35a76SGreg Roach $element->addText($this->generated_by); 391b6f35a76SGreg Roach $element->setUrl(Webtrees::URL); 392345fcc8aSGreg Roach $this->addElementToFooter($element); 393b6f35a76SGreg Roach } 394b6f35a76SGreg Roach } 395b6f35a76SGreg Roach 396b6f35a76SGreg Roach /** 397b6f35a76SGreg Roach * Run the report. 398b6f35a76SGreg Roach * 399b6f35a76SGreg Roach * @return void 400b6f35a76SGreg Roach */ 401b6f35a76SGreg Roach public function run(): void 402b6f35a76SGreg Roach { 403b6f35a76SGreg Roach $this->body(); 404b6f35a76SGreg Roach echo $this->tcpdf->Output('doc.pdf', 'S'); 405b6f35a76SGreg Roach } 406b6f35a76SGreg Roach 407b6f35a76SGreg Roach /** 408b6f35a76SGreg Roach * Create a new Cell object. 409b6f35a76SGreg Roach * 41077bab461SGreg Roach * @param float $width cell width (expressed in points) 41177bab461SGreg Roach * @param float $height cell height (expressed in points) 41277bab461SGreg Roach * @param string $border Border style 41377bab461SGreg Roach * @param string $align Text alignment 414b6f35a76SGreg Roach * @param string $bgcolor Background color code 415b6f35a76SGreg Roach * @param string $style The name of the text style 416b6f35a76SGreg Roach * @param int $ln Indicates where the current position should go after the call 417b6f35a76SGreg Roach * @param mixed $top Y-position 418b6f35a76SGreg Roach * @param mixed $left X-position 419b6f35a76SGreg Roach * @param int $fill Indicates if the cell background must be painted (1) or transparent (0). Default value: 1 420b6f35a76SGreg Roach * @param int $stretch Stretch carachter mode 421b6f35a76SGreg Roach * @param string $bocolor Border color 422b6f35a76SGreg Roach * @param string $tcolor Text color 423b6f35a76SGreg Roach * @param bool $reseth 424b6f35a76SGreg Roach * 425b6f35a76SGreg Roach * @return ReportBaseCell 426b6f35a76SGreg Roach */ 42777bab461SGreg Roach public function createCell(float $width, float $height, string $border, string $align, string $bgcolor, string $style, int $ln, $top, $left, int $fill, int $stretch, string $bocolor, string $tcolor, bool $reseth): ReportBaseCell 428b6f35a76SGreg Roach { 429b6f35a76SGreg Roach return new ReportPdfCell($width, $height, $border, $align, $bgcolor, $style, $ln, $top, $left, $fill, $stretch, $bocolor, $tcolor, $reseth); 430b6f35a76SGreg Roach } 431b6f35a76SGreg Roach 432b6f35a76SGreg Roach /** 433b6f35a76SGreg Roach * Create a new TextBox object. 434b6f35a76SGreg Roach * 435b6f35a76SGreg Roach * @param float $width Text box width 436b6f35a76SGreg Roach * @param float $height Text box height 437b6f35a76SGreg Roach * @param bool $border 438b6f35a76SGreg Roach * @param string $bgcolor Background color code in HTML 439b6f35a76SGreg Roach * @param bool $newline 440b6f35a76SGreg Roach * @param float $left 441b6f35a76SGreg Roach * @param float $top 442b6f35a76SGreg Roach * @param bool $pagecheck 443b6f35a76SGreg Roach * @param string $style 444b6f35a76SGreg Roach * @param bool $fill 445b6f35a76SGreg Roach * @param bool $padding 446b6f35a76SGreg Roach * @param bool $reseth 447b6f35a76SGreg Roach * 448b6f35a76SGreg Roach * @return ReportBaseTextbox 449b6f35a76SGreg Roach */ 450b6f35a76SGreg Roach public function createTextBox( 451b6f35a76SGreg Roach float $width, 452b6f35a76SGreg Roach float $height, 453b6f35a76SGreg Roach bool $border, 454b6f35a76SGreg Roach string $bgcolor, 455b6f35a76SGreg Roach bool $newline, 456b6f35a76SGreg Roach float $left, 457b6f35a76SGreg Roach float $top, 458b6f35a76SGreg Roach bool $pagecheck, 459b6f35a76SGreg Roach string $style, 460b6f35a76SGreg Roach bool $fill, 461b6f35a76SGreg Roach bool $padding, 462b6f35a76SGreg Roach bool $reseth 463b6f35a76SGreg Roach ): ReportBaseTextbox { 464b6f35a76SGreg Roach return new ReportPdfTextBox($width, $height, $border, $bgcolor, $newline, $left, $top, $pagecheck, $style, $fill, $padding, $reseth); 465b6f35a76SGreg Roach } 466b6f35a76SGreg Roach 467b6f35a76SGreg Roach /** 468b6f35a76SGreg Roach * Create a text element. 469b6f35a76SGreg Roach * 470b6f35a76SGreg Roach * @param string $style 471b6f35a76SGreg Roach * @param string $color 472b6f35a76SGreg Roach * 473b6f35a76SGreg Roach * @return ReportBaseText 474b6f35a76SGreg Roach */ 475b6f35a76SGreg Roach public function createText(string $style, string $color): ReportBaseText 476b6f35a76SGreg Roach { 477b6f35a76SGreg Roach return new ReportPdfText($style, $color); 478b6f35a76SGreg Roach } 479b6f35a76SGreg Roach 480b6f35a76SGreg Roach /** 481b6f35a76SGreg Roach * Create a new Footnote object. 482b6f35a76SGreg Roach * 483b6f35a76SGreg Roach * @param string $style Style name 484b6f35a76SGreg Roach * 485b6f35a76SGreg Roach * @return ReportBaseFootnote 486b6f35a76SGreg Roach */ 48724f2a3afSGreg Roach public function createFootnote(string $style): ReportBaseFootnote 488b6f35a76SGreg Roach { 489b6f35a76SGreg Roach return new ReportPdfFootnote($style); 490b6f35a76SGreg Roach } 491b6f35a76SGreg Roach 492b6f35a76SGreg Roach /** 493b6f35a76SGreg Roach * Create a new image object. 494b6f35a76SGreg Roach * 495b6f35a76SGreg Roach * @param string $file Filename 496b6f35a76SGreg Roach * @param float $x 497b6f35a76SGreg Roach * @param float $y 498b6f35a76SGreg Roach * @param float $w Image width 499b6f35a76SGreg Roach * @param float $h Image height 500b6f35a76SGreg Roach * @param string $align L:left, C:center, R:right or empty to use x/y 501b6f35a76SGreg Roach * @param string $ln T:same line, N:next line 502b6f35a76SGreg Roach * 503b6f35a76SGreg Roach * @return ReportBaseImage 504b6f35a76SGreg Roach */ 505b6f35a76SGreg Roach public function createImage(string $file, float $x, float $y, float $w, float $h, string $align, string $ln): ReportBaseImage 506b6f35a76SGreg Roach { 507b6f35a76SGreg Roach return new ReportPdfImage($file, $x, $y, $w, $h, $align, $ln); 508b6f35a76SGreg Roach } 509b6f35a76SGreg Roach 510b6f35a76SGreg Roach /** 511b6f35a76SGreg Roach * Create a new image object from Media Object. 512b6f35a76SGreg Roach * 513b6f35a76SGreg Roach * @param MediaFile $media_file 514b6f35a76SGreg Roach * @param float $x 515b6f35a76SGreg Roach * @param float $y 516b6f35a76SGreg Roach * @param float $w Image width 517b6f35a76SGreg Roach * @param float $h Image height 518b6f35a76SGreg Roach * @param string $align L:left, C:center, R:right or empty to use x/y 519b6f35a76SGreg Roach * @param string $ln T:same line, N:next line 520b6f35a76SGreg Roach * 521b6f35a76SGreg Roach * @return ReportBaseImage 522b6f35a76SGreg Roach */ 523b6f35a76SGreg Roach public function createImageFromObject( 524b6f35a76SGreg Roach MediaFile $media_file, 525b6f35a76SGreg Roach float $x, 526b6f35a76SGreg Roach float $y, 527b6f35a76SGreg Roach float $w, 528b6f35a76SGreg Roach float $h, 529b6f35a76SGreg Roach string $align, 530*9458f20aSGreg Roach string $ln 531b6f35a76SGreg Roach ): ReportBaseImage { 532*9458f20aSGreg Roach return new ReportPdfImage('@' . $media_file->fileContents(), $x, $y, $w, $h, $align, $ln); 533b6f35a76SGreg Roach } 534b6f35a76SGreg Roach 535b6f35a76SGreg Roach /** 536b6f35a76SGreg Roach * Create a line. 537b6f35a76SGreg Roach * 538b6f35a76SGreg Roach * @param float $x1 539b6f35a76SGreg Roach * @param float $y1 540b6f35a76SGreg Roach * @param float $x2 541b6f35a76SGreg Roach * @param float $y2 542b6f35a76SGreg Roach * 543b6f35a76SGreg Roach * @return ReportBaseLine 544b6f35a76SGreg Roach */ 545b6f35a76SGreg Roach public function createLine(float $x1, float $y1, float $x2, float $y2): ReportBaseLine 546b6f35a76SGreg Roach { 547b6f35a76SGreg Roach return new ReportPdfLine($x1, $y1, $x2, $y2); 548b6f35a76SGreg Roach } 549b6f35a76SGreg Roach} 550