Exemple #1
0
<?php

require_once './core/helper/f.php';
f::import('core/helper/Cifrar.php');
$random1 = Cifrar::random(4, 'int');
$random2 = Cifrar::random(4, 'int');
$texto = $random1 . ' ' . $random2;
$width = 149;
$height = 27;
$image = imagecreatetruecolor($width, $height);
$font = f::getPatchApp() . '/resource/plugin/reCaptcha/fonts/Courier.ttf';
$black = imagecolorallocate($image, 0, 0, 0);
// color negro
$white = imagecolorallocate($image, 255, 255, 255);
// background color blanco
//$black=$white;
imagefilledrectangle($image, 0, 0, $width, $height, $white);
$lineas = mt_rand(10, 15);
for ($i = 0; $i < $lineas; $i++) {
    $max = mt_rand(80, 100);
    $r = mt_rand(100, 200);
    $g = mt_rand(100, 200);
    $b = mt_rand(100, 200);
    $linescolor = imagecolorallocatealpha($image, $r, $g, $b, $max);
    $x1 = mt_rand(0, $width);
    $y1 = mt_rand(0, $height);
    $x2 = mt_rand(0, $width);
    $y2 = mt_rand(0, $height);
    imageline($image, $x1, $y1, $x2, $y2, $linescolor);
}
$aumentar = 16;
Exemple #2
0
    protected function dompdf($titulo, $html, $modo = 'online')
    {
        $htmlpdf = '
        <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
        <html xmlns="http://www.w3.org/1999/xhtml">
            <head>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
            <title>' . $titulo . '</title>
             
            <style>
            body
            {
                font-family:"Trebuchet MS", Arial, Helvetica, sans-serif;
                font-size:12px;
                font-weight:10;
            }
            div.SiguientePagina 
            {
                page-break-after: always;
            }
            </style>
            </head>

            <body>
            <script type="text/php">
            if ( isset($pdf) ) 
            {
              $font = Font_Metrics::get_font("Trebuchet MS");;
              $size = 10;
              $color = array(0,0,0);
              $text_height = Font_Metrics::get_font_height($font, $size);

              $foot = $pdf->open_object();

              $w = $pdf->get_width();
              $h = $pdf->get_height();

              // Draw a line along the bottom
              $y = $h - $text_height - 24;
              $pdf->line(16, $y, $w - 16, $y, $color, 0.5);

              $pdf->close_object();
              $pdf->add_object($foot, "all");

              $text = "Pagina {PAGE_NUM} de {PAGE_COUNT}";  

              // Center the text
              $width = Font_Metrics::get_text_width("Pagina 1 de 2", $font, $size);
              $pdf->page_text($w / 2 - $width / 2, $y, $text, $font, $size, $color);
            }
            </script>
            ' . $html . '
            </body>
        </html>
        ';
        //return $htmlpdf;
        f::import('resource/plugin/dompdf/dompdf_config.inc.php');
        $oDOMPDF = new DOMPDF();
        $oDOMPDF->load_html($htmlpdf);
        //$dompdf->load_html_file('archivos/complementos/dompdf/www/index.php');
        $oDOMPDF->render();
        switch ($modo) {
            case 'download':
                $modo = array("Attachment" => 1);
                break;
            default:
                $modo = array("Attachment" => 0);
                break;
        }
        $oDOMPDF->stream($titulo . ".pdf", $modo);
    }