public function write() { parent::write(); if ($this->dataProvider == null) { throw new Exception("DataProvider is NULL"); } $this->generateTableData(); //------- init columns width --------------- $colZero = 0; $colMore = 0; for ($i = 0; $i < count($this->columns); $i++) { if ((double) $this->columns[$i]->width == 0) { $colZero++; } else { $colMore += (double) $this->columns[$i]->width; } } if ($colZero > 0 && $colMore > 0 || $colMore == 0) { $avarage = ($this->width - $colMore) / $colZero; for ($i = 0; $i < count($this->columns); $i++) { if ((double) $this->columns[$i]->width == 0) { $this->columns[$i]->width = $avarage; } } } else { if ($colZero == 0) { for ($i = 0; $i < count($this->columns); $i++) { $perc = (double) $this->columns[$i]->width / $colMore; $this->columns[$i]->width = $this->width * $perc; } } } //------- init columns width --------------- if ($this->contentPageRollover) { $this->componentPdfWriter->SetXY($this->getPageX(), $this->getPageY()); /*int*/ $rowCount = count($this->dataProviderList); /*int*/ $usedRows = 0; if ($rowCount < $this->rowsPerPage()) { $this->writeTable($rowCount); } else { while ($rowCount - $usedRows > $this->rowsPerPage()) { $usedRows = $usedRows + $this->rowsPerPage(); $this->writeTable($this->rowsPerPage()); PDFUtil::startNewPage($this->componentPdfWriter, $this->document); $this->componentPdfWriter->SetXY($this->getPageX(), $this->getPageY()); } $this->writeTable($rowCount - $usedRows); } } else { $this->componentPdfWriter->SetXY($this->getPageX(), $this->getPageY()); $this->writeTable(count($this->dataProviderList)); } }
public function PrintPDF($obj, $fileName = "") { if ($fileName == "") { $fileName = DataUtils::getOutputFileName(); } $path = WebOrbServicesPath . BASE_PDF_SERVICE_PATH . "PDF\\pdf_files\\"; Log::log(LoggingConstants::MYDEBUG, "Save start"); PDFUtil::saveDocument($obj, $path, $fileName); Log::log(LoggingConstants::MYDEBUG, "Save finished"); return self::DOWNLOAD_URL . $fileName; }
/** * Write document to PDF output file * * @param pdfDocument iText {@link com.lowagie.text.Document} * @param pdfWriter iText {@link PdfWriter} * * @throws DocumentException * @throws IOException */ public function write(PDF $pdfWriter) { $pdfWriter->SetAuthor("MeliorSolutions"); // Log::log(LoggingConstants::MYDEBUG, " --- METADATA: " . $this->metadata); if ($this->metadata != null) { /*Property*/ $pageMarginsProperty = $this->metadata->getPropertyByName(Property::$PAGE_MARGINS); if ($pageMarginsProperty != null) { Log::log(LoggingConstants::MYDEBUG, " --- PAGE MARGINS: " . $pageMarginsProperty->value); $this->marginTop = $this->marginLeft = $this->marginRight = $this->marginBottom = $pageMarginsProperty->value; } } if (count($this->pages) == 0) { throw new Exception("Document does not contain any page!"); } foreach ($this->pages as $page) { $page->initComponent($this, $pdfWriter, $this->getMarginTop(), $this->getMarginLeft(), $this->getMarginRight(), $this->getMarginBottom()); } $this->parseMetadata(); foreach ($this->pages as $page) { try { PDFUtil::startNewPage($pdfWriter, $this); $page->write(); } catch (UnlicensedException $e) { break; } } foreach ($this->images as $imageData) { unlink($imageData['fileName']); } // pdfDocument.close(); }