public function format_root_set($open, $name, $attrs, $props) { if ($open) { parent::newChunk(); $this->cchunk = $this->dchunk; $pdfDoc = new PdfWriter(); try { $pdfDoc->setCompressionMode(\HaruDoc::COMP_ALL); } catch (\HaruException $e) { v("PDF Compression failed, you need to compile libharu with Zlib...", E_USER_WARNING); } parent::setPdfDoc($pdfDoc); if (isset($attrs[Reader::XMLNS_XML]["base"]) && ($base = $attrs[Reader::XMLNS_XML]["base"])) { parent::setChunkInfo("xml-base", $base); } $id = $attrs[Reader::XMLNS_XML]["id"]; $this->cchunk["root-outline"] = $this->cchunk["id-to-outline"][$id] = $pdfDoc->createOutline(Format::getShortDescription($id), null, true); $this->setIdToPage($id); } else { $this->resolveLinks($this->cchunk["setname"]); $pdfDoc = parent::getPdfDoc(); v("Writing Full PDF Manual (%s)", $this->cchunk["setname"], VERBOSE_TOC_WRITING); $filename = $this->getOutputDir(); if (Config::output_filename()) { $filename .= Config::output_filename(); } else { $filename .= strtolower($this->getFormatName()) . $this->getExt(); } $pdfDoc->saveToFile($filename); unset($pdfDoc); } return ""; }
function generarFactura($reserva, $hotel) { try { global $template_dir; global $template_url; $pdfWriter = new PdfWriter(); $pdfWriter->Header(); $pdfWriter->printHeaderRow(1, 'Factura', $reserva->localizador); $ruta = ' '; if ($hotel->logoId) { $ruta = ' img(' . $hotel->logo->ruta . ') '; } else { $ruta = ' img(' . $template_url . '/images/logo.png) '; } $pdfWriter->printHeaderRow(2, $ruta . ' ' . $smarty->getConfigVariable('sistema_nombre'), '', 90, 'R'); $pdfWriter->printRow(1, '', "Nombre: " . $reserva->usuario->nombre . "\nApellido: " . $reserva->usuario->apellido . "\nEmail: " . $reserva->usuario->email . "\nTelefono: " . $reserva->usuario->telefono . "\n"); $pdfWriter->printRow(2, '', "Distribuidor:" . $hotel->distribuidor->nombreComercial . "\nCIF: " . $hotel->distribuidor->numeroFiscal . "\nDireccion: " . $hotel->distribuidor->direccion->descripcion . "\nTelefono: " . $hotel->distribuidor->telefonoReservas . "\nEmail: " . $hotel->distribuidor->emailReservas . "\n"); $pdfWriter->PrintBorderTableRow('Cargos facturados:'); $total = 0; foreach ($reserva->alojamiento as $p) { if ($p->importeInicial) { $pdfWriter->printRow(1, "Localizador {$reserva->localizador} - gestión de reserva {$p->porcientoInicial} %", "{$p->nombre}", 150); $pdfWriter->printRow(2, $reserva->moneda->codigo . ' ' . number_format($p->importeInicial, 2, ',', ''), '', 30); $total += $p->importeInicial; } } foreach ($reserva->extras as $p) { if ($p->importeInicial) { $pdfWriter->printRow(1, "Localizador {$p->localizador} - gestión de reserva {$p->porcientoInicial} %", "{$p->nombre}", 150); $pdfWriter->printRow(2, $reserva->moneda->codigo . ' ' . number_format($p->importeInicial, 2, ',', ''), '', 30); $total += $p->importeInicial; } } $pdfWriter->PrintBorderTableRow(' '); $pdfWriter->printRow(1, '', '', 130); $pdfWriter->printRow(2, 'Total: ' . $reserva->moneda->codigo . ' ' . number_format($total, 2, ',', ''), 'Impuestos y tasas incluidas', 50, 'C'); $pdfWriter->printRow(1, '', '', 180, 'C'); $pdfWriter->printRow(2, '', '', 180, 'C'); $pdfWriter->printRow(3, "Si tienes alguna duda sobre la factura, no dudes en consultarnos en\n " . $hotel->distribuidor->emailReservas . " o llamando al " . $hotel->distribuidor->telefonoReservas, '', 250, 'C'); /* $pdfWriter->printRow(2, '', 'dsfgsdfg sdf gsdfgsdfg sdfg sdf gsdfg sdfg '); $pdfWriter->printRow(3, '', 'dsfgsdfg sdf gsdfgsdfg sdfg sdf gsdfg sdfg ');*/ $filename = $template_dir . '/pdf/factura_' . $reserva->localizador . '.pdf'; $pdfWriter->Output(); //return $filename; } catch (Exception $e) { print_r($e); //return false; } }
/** * {@inheritdoc} */ protected function writeAdditionalEncryptDictionaryEntries(PdfWriter $pdfWriter) { $pdfWriter->writeName('Length'); $pdfWriter->writeNumber(128); }