public function pdf($vendaId)
 {
     $this->loadModel('Venda');
     $this->loadModel('VendaItensProduto');
     $dompdf = new Dompdf();
     $dadosVenda = $this->Venda->find('all', array('conditions' => array('Venda.id' => $vendaId)));
     $produtosVenda = $this->VendaItensProduto->find('all', array('conditions' => array('VendaItensProduto.venda_id' => $vendaId)));
     $html = $this->pegar_venda_como_html($dadosVenda, $produtosVenda);
     $dompdf->loadHtml($html);
     $dompdf->set_paper('a4');
     $dompdf->render();
     $dompdf->stream();
     exit;
 }
Beispiel #2
1
 public function actionPdf()
 {
     $data = $this->getData();
     $searchModel = $data['searchModel'];
     $dataProvider = $data['dataProvider'];
     $title = $data['title'];
     $modelName = $data['modelName'];
     $fields = $this->getFieldsKeys($searchModel->exportFields());
     $options = new Options();
     $options->set('defaultFont', 'times');
     $dompdf = new Dompdf($options);
     $html = '<html><body>';
     $html .= '<h1>' . $title ? $title : $modelName . '</h1>';
     $html .= '<table width="100%" cellspacing="0" cellpadding="0">';
     $html .= '<tr style="background-color: #ececec;">';
     foreach ($fields as $one) {
         $html .= '<td style="border: 2px solid #cccccc; text-align: center; font-weight: 500;">' . $searchModel->getAttributeLabel($one) . '</td>';
     }
     $html .= '</tr>';
     foreach ($dataProvider->getModels() as $model) {
         $html .= '<tr>';
         foreach ($searchModel->exportFields() as $one) {
             if (is_string($one)) {
                 $html .= '<td style="border: 1px solid #cccccc; text-align: left; font-weight: 300; padding-left: 10px;">' . $model[$one] . '</td>';
             } else {
                 $html .= '<td style="border: 1px solid #cccccc; text-align: left; font-weight: 300; padding-left: 10px;">' . $one($model) . '</td>';
             }
         }
         $html .= '</tr>';
     }
     $html .= '</table>';
     $html .= '</body></html>';
     $dompdf->loadHtml($html);
     $dompdf->setPaper('A4', 'landscape');
     $dompdf->render();
     $dompdf->stream($modelName . '_' . time());
 }
Beispiel #3
0
 public function renderControllerAction($controller)
 {
     $this->assertNoHeadersSent();
     ini_set('memory_limit', '384M');
     ini_set('max_execution_time', 300);
     $viewRenderer = $controller->getHelper('viewRenderer');
     $controller->render($viewRenderer->getScriptAction(), $viewRenderer->getResponseSegment(), $viewRenderer->getNoController());
     $layout = $controller->getHelper('layout')->setLayout('pdf');
     $layout->content = $controller->getResponse();
     $html = $layout->render();
     $imgDir = Url::fromPath('img');
     $html = preg_replace('~src="' . $imgDir . '/~', 'src="' . Icinga::app()->getBootstrapDirectory() . '/img/', $html);
     $options = new Options();
     $options->set('defaultPaperSize', 'A4');
     $dompdf = new Dompdf($options);
     $dompdf->loadHtml($html);
     $dompdf->render();
     $request = $controller->getRequest();
     $dompdf->stream(sprintf('%s-%s-%d', $request->getControllerName(), $request->getActionName(), time()));
 }
Beispiel #4
0
<?php

require_once 'dompdf/autoload.inc.php';
// reference the Dompdf namespace
use Dompdf\Dompdf;
// instantiate and use the dompdf class
$dompdf = new Dompdf();
$html = '<html>
            <head>
                <link rel="stylesheet" href="../assets/css/print.css" type="text/css" />
            </head>
            <body>' . $_POST['Html'] . '</body>
        </html>';
$dompdf->load_html($html);
// (Optional) Setup the paper size and orientation
$dompdf->set_paper('A4', 'landscape');
// Render the HTML as PDF
$dompdf->render();
// Output the generated PDF to Browser
$dompdf->stream("Diagrama");
exit;
    $dompdf = new Dompdf();
    $dompdf->set_option('isHtml5ParserEnabled', true);
    //html
    $html = file_get_contents('../public/mauBang/file_html_img.html');
    $html = str_replace('{_name}', $name, $html);
    $html = str_replace('{_course}', $course, $html);
    $html = str_replace('{_img_signature1}', $img_signature1, $html);
    $html = str_replace('{_logo_signature1}', $logo_signature1, $html);
    $html = str_replace('{_name_signature1}', $name_signature1, $html);
    $html = str_replace('{_position_signature1}', $position_signature1, $html);
    $html = str_replace('{_img_signature2}', $img_signature2, $html);
    $html = str_replace('{_logo_signature2}', $logo_signature2, $html);
    $html = str_replace('{_name_signature2}', $name_signature2, $html);
    $html = str_replace('{_position_signature2}', $position_signature2, $html);
    $html = str_replace('{_pdu}', $pdu, $html);
    $html = str_replace('{_code}', $code, $html);
    $html = str_replace('{_date}', $date, $html);
    $dompdf->loadHtml($html);
    //end html
    //(Optional) Setup the paper size and orientation
    $dompdf->setPaper('A4', 'landscape');
    //portrait, landscape
    //Render the HTML as PDF
    $dompdf->render();
    //Stream - Output the generated PDF to Browser
    //$dompdf->output();
    $dompdf->stream('certificate');
    //$dompdf->stream('certificate', array("Attachment" => false));
    exit(0);
}
/*end dompdf*/
Beispiel #6
0
}
$html .= $p->payer_email()->value . '</p>';
$html .= $p->payer_address()->kirbytext();
$html .= '<hr>';
if (strpos($p->products(), 'uri:')) {
    // Show products overview with download links
    foreach ($p->products()->toStructure() as $product) {
        $html .= '<p>' . $product->name() . '<br><small>' . $product->variant();
        $html .= $product->option()->isNotEmpty() ? ' / ' . $product->option() : '';
        $html .= ' / ' . l::get('qty') . $product->quantity();
        $html .= '</small></p>';
    }
} else {
    // Old transaction files from Shopkit 1.0.5 and earlier
    $html .= $p->products()->kirbytext()->bidi();
}
$html .= '<hr>';
$html .= '<p>' . l::get('subtotal') . ': ' . formatPrice($p->subtotal()->value) . '</p>';
$html .= '<p>' . l::get('shipping') . ': ' . formatPrice($p->shipping()->value) . '</p>';
$html .= '<p>' . l::get('tax') . ': ' . formatPrice($p->tax()->value) . '</p>';
$html .= '<p><strong>' . l::get('total') . ': ' . formatPrice($p->subtotal()->value + $p->shipping()->value + $p->tax()->value) . '</strong></p>';
$html .= '<p><strong>' . l::get('gift-certificate') . ': &ndash; ' . formatPrice($p->giftcertificate()->value) . '</strong></p>';
// Load the html
$dompdf->loadHtml($html);
// (Optional) Setup the paper size and orientation
$dompdf->setPaper('A4', 'portrait');
// Render the HTML as PDF
$dompdf->render();
// Output the generated PDF to Browser
$dompdf->stream();
    $dompdf = new Dompdf();
    $dompdf->set_option('isHtml5ParserEnabled', true);
    //html
    $html = file_get_contents('../public/mauBang/file_html_img.html');
    $html = str_replace('{_name}', $name, $html);
    $html = str_replace('{_course}', $course, $html);
    $html = str_replace('{_img_signature1}', $img_signature1, $html);
    $html = str_replace('{_logo_signature1}', $logo_signature1, $html);
    $html = str_replace('{_name_signature1}', $name_signature1, $html);
    $html = str_replace('{_position_signature1}', $position_signature1, $html);
    $html = str_replace('{_img_signature2}', $img_signature2, $html);
    $html = str_replace('{_logo_signature2}', $logo_signature2, $html);
    $html = str_replace('{_name_signature2}', $name_signature2, $html);
    $html = str_replace('{_position_signature2}', $position_signature2, $html);
    $html = str_replace('{_pdu}', $pdu, $html);
    $html = str_replace('{_code}', $code, $html);
    $html = str_replace('{_date}', $date, $html);
    $dompdf->loadHtml($html);
    //end html
    //(Optional) Setup the paper size and orientation
    $dompdf->setPaper('A4', 'landscape');
    //portrait, landscape
    //Render the HTML as PDF
    $dompdf->render();
    //Stream - Output the generated PDF to Browser
    //$dompdf->output();
    //$dompdf->stream('pdf');
    $dompdf->stream("pdf", array("Attachment" => false));
    exit(0);
}
/*end dompdf*/
Beispiel #8
0
<?php

require_once "../autoload.inc.php";
//reference the Dompdf namespace
use Dompdf\Dompdf;
//instantiate and use the dompdf class
$dompdf = new Dompdf();
$dompdf->set_option('isHtml5ParserEnabled', true);
//html
$html = file_get_contents('file_html.php');
$dompdf->loadHtml($html);
//(Optional) Setup the paper size and orientation
$dompdf->setPaper('A4', 'portrait');
//portrait, landscape
//Render the HTML as PDF
$dompdf->render();
//Stream - Output the generated PDF to Browser
//$dompdf->output();
$dompdf->stream('pdf');
 public function baixar_estoque_minimo_pdf()
 {
     $this->loadModel('Produto');
     $this->loadModel('Usuario');
     $dompdf = new Dompdf();
     $usuario = $this->Usuario->find('all', array('conditions' => array('Usuario.id' => $this->instancia)))[0]['Usuario'];
     $conditions = array('conditions' => array('ativo' => 1, 'id_usuario' => $this->instancia, 'Produto.estoque < ' => 'Produto.quantidade_minima'));
     $produtos = $this->Produto->query("select * from produtos as Produto where estoque < quantidade_minima and id_usuario = " . $this->instancia . " and ativo = 1");
     $html = $this->getProdutosEstoqueMinimoComoHtml($produtos);
     $dompdf->loadHtml($html);
     $dompdf->set_paper(array(0, 0, 595.28, count($produtos) * 25));
     $dompdf->render();
     $dompdf->stream();
     exit;
 }
Beispiel #10
-2
 public function printTest()
 {
     $dompdf = new Dompdf();
     $dompdf->loadHtml('Hello world');
     $dompdf->setPaper('A4', 'Landscape');
     $dompdf->render();
     $dompdf->stream();
 }