Render PDF

@param bool $print
@param bool $instrucoes

@return string
@throws \Exception
554906
public function renderPDF($print = false, $instrucoes = true)
    {
        $pdf = new Pdf();
        $pdf->addBoleto($this);
        !$print || $pdf->showPrint();
        $instrucoes || $pdf->hideInstrucoes();

        return $pdf->gerarBoleto('S', null);
    }
889093
public function render(array $options = array())
    {
        $options = $this->optionsTratament($options);
        $this->_pdf = new ZfPdf\PdfDocument();
        $this->_font = ZfPdf\Font::fontWithName(ZfPdf\Font::FONT_HELVETICA);

        //$options['colors'] = array_merge($colors, (array) $options['colors']);

        $this->_la = '';
        $larg = $this->calculateCellSize();
        $this->_cellFontSize = 8;

        // Define os estilos do documento
        $this->defineStyles($options);

        // Pega o total de páginas
        $this->getTotalPages($options);

        // Adiciona página ao documento PDF
        $this->addPage($options);

        // Adicionar logomarca se definido nas opções
        $this->addLogo($options);

        // Adiciona Titulo e Subtitulo de acordo com as opções definidas
        $this->addTitle($options);

        //Iniciar a contagem de paginas
        $pagina = 1;

        // Desenha o rodapé do documento
        $this->drawFooter($pagina, $options);

        $this->_page->setFont($this->_font, $this->_cellFontSize);

        $iLarg = 0;
        foreach ($larg as $final) {
            $this->_cell[$iLarg] = round($final * ($this->_page->getWidth() - 80) / array_sum($larg));
            $iLarg++;
        }

        $cellsCount = count($this->_arrayForm['gridfieldsconfig']);
        $this->_largura = ($this->_page->getWidth() - 80) / $cellsCount;
        $this->_altura = $this->_page->getHeight() - 120;

        // Desenha os nomes dos campos
        $this->drawFieldName($this->_topo, $this->_styleText);

        $this->_page->setStyle($this->_style);

        if (is_array($this->_arrayData) and !empty($this->_arrayData)) {

            $ia = 0;
            $aa = 0;
            foreach ($this->_arrayData as $value) {
                if ($this->_altura <= 80) {

                    // Adiciona página ao documento PDF
                    $this->addPage($options);

                    $pagina++;

                    // Adicionar logomarca se definido nas opções
                    $this->addLogo($options);

                    // Adiciona Titulo e Subtitulo de acordo com as opções definidas
                    $this->addTitle($options);

                    //set font
                    $this->_altura = $this->_page->getHeight() - 120;

                    // Desenha o rodapé do documento
                    $this->drawFooter($pagina, $options);

                    //
                    $this->_largura1 = 40;
                    $this->_page->setFont($this->_font, $this->_cellFontSize + 1);

                    // Desenha os nomes dos campos
                    $this->drawFieldName($this->_topo, $this->_styleText);
                }

                $this->_la = 0;
                $this->_altura = $this->_altura - 16;
                $i = 0;
                $tdf = $ia % 2 ? $this->td : $this->td2;
                $a = 1;

                //A linha horizontal
                //$centrar = round(($this->_page->getWidth() - 80) / 2) + 30;
                if ((int) $this->_la == 0) {
                    $this->_largura1 = 40;
                } else {
                    $this->_largura1 = $this->_cell[$i - 1] + $this->_largura1;
                }
                $this->_la = 0;

                ////////////
                //Vamos saber quantas linhas tem este registo
                $nlines = array();
                $nl = 0;
                foreach ($value as $value2) {
                    $line = $this->widthForStringUsingFontSize(strip_tags(trim($value2)), $this->_font, 8);
                    $nlines[] = ceil($line / $this->_cell[$nl]);
                    $nl++;
                }

                sort($nlines);
                foreach ($value as $value1) {
                    $value1 = strip_tags(trim($value1));
                    if ((int) $this->_la == 0) {
                        $this->_largura1 = 40;
                    } else {
                        $this->_largura1 = $this->_cell[$i - 1] + $this->_largura1;
                    }

                    $this->_page->setStyle($tdf);
                    $this->_page->drawRectangle($this->_largura1, $this->_altura - 4, $this->_largura1 + $this->_cell[$i] + 1, $this->_altura + 12);
                    $this->_page->setStyle($this->_styleText);
                    $this->_page->drawText($value1, $this->_largura1 + 2, $this->_altura, 'UTF-8');
                    $this->_la = $this->_largura1;
                    $i++;
                    $a++;
                }

                $aa++;
                $ia++;
            }
        }
        header('Content-Description: File Transfer');
        header('Cache-Control: public, must-revalidate, max-age=0'); // HTTP/1.1
        header('Pragma: public');
        header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
        header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
        header("Content-Type: application/pdf");
        header('Content-Disposition: attachment; filename="' . $options['name'] . '.pdf"');
        header('Content-Transfer-Encoding: binary');

        echo $this->_pdf->render();
        die();
    }
1162987
public function printDocument()
    {
        header("Content-Type: {$this->_contentType}; {$this->_charset}");

        try {
            $this->controller->processRequest();
        } catch (Exception $e) {
            $message = substr(
                preg_replace('/\s+/', ' ', $e->getMessage()), 0, 150
            );
            header("HTTP/1.0 400 $message");
            throw $e;
        }

        echo $this->getDocument();
    }
1360035
private function printStepExceptionsAndStdOut(OutputPrinter $printer, array $events)
    {
        foreach ($events as $event) {
            $this->printStepStdOut($printer, $event->getTestResult());
            $this->printStepException($printer, $event->getTestResult());
        }
    }
1124122
public function output($options = array())
    {
        if (!isset($options["compress"])) $options["compress"] = true;

        $this->_add_page_text();

        if ($options["compress"]) {
            $this->_pdf->set_value("compress", 6);
        } else {
            $this->_pdf->set_value("compress", 0);
        }

        $this->_close();

        if (self::$IN_MEMORY) {
            $data = $this->_pdf->get_buffer();
        } else {
            $data = file_get_contents($this->_file);

            //debugpng
            if ($this->_dompdf->getOptions()->getDebugPng()) {
                print '[pdflib output unlink ' . $this->_file . ']';
            }
            if (!$this->_dompdf->getOptions()->getDebugKeepTemp()) {
                unlink($this->_file);
            }
            $this->_file = null;
            unset($this->_file);
        }

        return $data;
    }
1284075
public static function printTokens(
        InputInterface $input,
        OutputInterface $output,
        array $tokens
    ) {
        $withMetadata = $input->getOption('with-metadata');
        $table = new Table($output);
        $headers = ['UUID', 'Indices', 'endpoints', 'plugins', 'ttl'];
        if ($withMetadata) {
            $headers[] = 'Metadata';
        }
        $table->setHeaders($headers);

        foreach ($tokens as $token) {
            $row = [
                $token->getTokenUUID()->composeUUID(),
                implode(', ', array_map(function (IndexUUID $index) {
                    return $index->composeUUID();
                }, $token->getIndices())),
                implode(', ', $token->getEndpoints()),
                implode(', ', $token->getPlugins()),
                $token->getTtl(),
            ];

            if ($withMetadata) {
                $metadataRow = [];
                foreach ($token->getMetadata() as $metadataField => $metadataValue) {
                    $metadataRow[] = sprintf("$metadataField = %s",
                        is_bool($metadataValue)
                            ? $metadataValue ? 'true' : 'false'
                            : (
                                is_array($metadataValue)
                                    ? implode(', ', $metadataValue)
                                    : (string) $metadataValue
                            )
                    );
                }
                $row[] = implode(PHP_EOL, $metadataRow);
            }

            $table->addRow($row);
        }

        $table->render();
    }
1011254
private function printDescription(OutputPrinter $printer, FeatureNode $feature)
    {
        if (!$feature->getDescription()) {
            $printer->writeln();

            return;
        }

        foreach (explode("\n", $feature->getDescription()) as $descriptionLine) {
            $printer->writeln(sprintf('%s%s', $this->subIndentText, $descriptionLine));
        }

        $printer->writeln();
    }
186264
public function renderViewPrint( $template, $models, $config = [] ) {

		return $this->renderViewGeneric( $template, $models, CoreGlobal::TPL_VIEW_PRINT, $config );
	}
848216
public function openUrl($url, $print = true)
    {
        $browserOption = $this->input->hasOption('browser') ? $this->input->getOption('browser') : null;
        $open = true;
        $success = false;

        // If the user wants to pipe the output to another command, stop here.
        if ($this->input->hasOption('pipe') && $this->input->getOption('pipe')) {
            $open = false;
            $print = true;
        }
        // Check if the user has requested not to use a browser.
        elseif ($browserOption === '0') {
            $open = false;
        }
        // Check for a display (if not on Windows or OS X).
        elseif (!$this->hasDisplay()) {
            $open = false;
            $this->stdErr->writeln('Not opening URL (no display found)', OutputInterface::VERBOSITY_VERBOSE);
        }

        // Open the URL.
        if ($open && ($browser = $this->getBrowser($browserOption))) {
            $success = $this->shell->executeSimple($browser . ' ' . escapeshellarg($url)) === 0;
        }

        // Print the URL.
        if ($print) {
            $this->output->writeln($url);
        }

        return $success;
    }
1215372
public function print(ValidationFailedException $e, OutputInterface $output) {

		$table = new Table($output);
		$table->setHeaders( ['Field', 'Problem'] );

		$i = 0;
		foreach( $e->getFailures() as $field => $messages ) {
			foreach($messages as $message)
				$table->setRow( $i++, [$field, $message] );

		}

		$table->render();
	}
1315272
public static void print(Exception ex, String strDebugType, int iPriority)
    {
        System.out.println(ex.getMessage());
        ex.printStackTrace();
    }
123755
public function renderOnSuccess($result, SilexKernel $silexKernel)
    {
        if (is_object($result) && method_exists($result, '__toString')) {
            $result = (string)$result;
        }
        elseif (is_bool($result)) {
            $result = $result ? "true" : "false";
        }
        elseif (is_scalar($result)) {
            $result = (string)$result;
        }
        elseif (is_array($result)) {
            $result = nl2br(str_replace(' ', '&nbsp;', json_encode($result, JSON_PRETTY_PRINT)));
        }
        elseif (!is_string($result)) {
            return $this->renderOnException(
                new WrappedExceptionInfo(
                    new \RuntimeException("Unsupported type of result: " . print_r($result, true)),
                    Response::HTTP_INTERNAL_SERVER_ERROR
                ),
                $silexKernel
            );
        }
        
        return new Response($result);
    }
180096
public function render($widget, $forceRender, $isDynamic = false)
    {
        $config = \OxidEsales\Eshop\Core\Registry::getConfig();
        $output = '';
        $suffix = $isDynamic ? '_dynamic' : '';
        $filesParameterName = \OxidEsales\Eshop\Core\ViewHelper\JavaScriptRegistrator::FILES_PARAMETER_NAME . $suffix;
        $scriptsParameterName = \OxidEsales\Eshop\Core\ViewHelper\JavaScriptRegistrator::SNIPPETS_PARAMETER_NAME . $suffix;

        $isAjaxRequest = $this->isAjaxRequest();
        $forceRender = $this->shouldForceRender($forceRender, $isAjaxRequest);

        if (!$widget || $forceRender) {
            if (!$isAjaxRequest) {
                $files = $this->prepareFilesForRendering($config->getGlobalParameter($filesParameterName), $widget);
                $output .= $this->formFilesOutput($files, $widget);
                $config->setGlobalParameter($filesParameterName, null);
                if ($widget) {
                    $dynamicIncludes = (array)$config->getGlobalParameter(\OxidEsales\Eshop\Core\ViewHelper\JavaScriptRegistrator::FILES_PARAMETER_NAME . '_dynamic');
                    $output .= $this->formFilesOutput($dynamicIncludes, $widget);
                    $config->setGlobalParameter(\OxidEsales\Eshop\Core\ViewHelper\JavaScriptRegistrator::FILES_PARAMETER_NAME . '_dynamic', null);
                }
            }

            // Form output for adds.
            $snippets = (array)$config->getGlobalParameter($scriptsParameterName);
            $scriptOutput = $this->formSnippetsOutput($snippets, $widget, $isAjaxRequest);
            $config->setGlobalParameter($scriptsParameterName, null);
            if ($widget) {
                $dynamicScripts = (array) $config->getGlobalParameter(\OxidEsales\Eshop\Core\ViewHelper\JavaScriptRegistrator::SNIPPETS_PARAMETER_NAME . '_dynamic');
                $scriptOutput .= $this->formSnippetsOutput($dynamicScripts, $widget, $isAjaxRequest);
                $config->setGlobalParameter(\OxidEsales\Eshop\Core\ViewHelper\JavaScriptRegistrator::SNIPPETS_PARAMETER_NAME . '_dynamic', null);
            }
            $output .= $this->enclose($scriptOutput, $widget, $isAjaxRequest);
        }

        return $output;
    }
638829
public function renderException(\Exception $e, OutputInterface $output)
    {
        parent::renderException($e, $output);

        if (is_callable($this->exceptionHandler)) {
            try {
                if (method_exists($this->exceptionHandler, '__invoke')) {
                    $this->exceptionHandler->__invoke($e);
                } else {
                    call_user_func($this->exceptionHandler, $e);
                }
            } catch (\Exception $e) {
            }
        }
    }
871588
function output($options = null) {

    // Add page text
    $this->_add_page_text();

    if ( isset($options["compress"]) && $options["compress"] != 1 )
      $this->_pdf->set_value("compress", 0);
    else
      $this->_pdf->set_value("compress", 6);

    $this->_close();

    if ( self::$IN_MEMORY )
      $data = $this->_pdf->get_buffer();

    else {
      $data = file_get_contents($this->_file);

      //debugpng
      if (DEBUGPNG) print '[pdflib output unlink '.$this->_file.']';
      if (!DEBUGKEEPTEMP)

      unlink($this->_file);
      $this->_file = null;
      unset($this->_file);
    }

    return $data;
  }
175931
public function printInlineScript($print = true)
    {
        $this->scriptNonces[] = ($nonce = $this->newNonce());
        if ($print) {
            echo  "<script type='text/javascript' nonce='".$nonce."'>" . $this->scriptInline . "</script>\n";
        } else {
            return  "<script type='text/javascript' nonce='".$nonce."'>" . $this->scriptInline . "</script>\n";
        }
    }
818171
private function printDescription(OutputPrinter $printer, $longTitle)
    {
        $lines = explode("\n", $longTitle);
        array_shift($lines);

        foreach ($lines as $line) {
            $printer->writeln(sprintf('%s%s', $this->subIndentText, $line));
        }
    }