Example #1
6
function pdf_create($html, $filename = '', $stream = TRUE, $invoice_id, $type)
{
    require_once "dompdf/dompdf_config.inc.php";
    if (get_magic_quotes_gpc()) {
        $html = stripslashes($html);
    }
    $dompdf = new DOMPDF();
    $dompdf->load_html($html);
    $dompdf->set_paper("a4", "portrait");
    $dompdf->render();
    $timestamp = date('YmdGis') . $invoice_id;
    $filename = $timestamp . '.pdf';
    if ($stream) {
        $dompdf->stream($filename);
    } else {
        if ($type == 'invoice') {
            $CI =& get_instance();
            $CI->load->helper('file');
            write_file("invoice/" . $filename, $dompdf->output());
            return $filename;
        } else {
            if ($type == 'salary') {
                $CI =& get_instance();
                $CI->load->helper('file');
                write_file("salary_slip/" . $filename, $dompdf->output());
                return $filename;
            }
        }
    }
}
 public function render($view = null, $layout = null)
 {
     try {
         ob_start();
         if (defined('DOMPDF_TEMP_DIR')) {
             $dir = new SplFileInfo(DOMPDF_TEMP_DIR);
             if (!$dir->isDir() || !$dir->isWritable()) {
                 trigger_error(__('%s is not writable', DOMPDF_TEMP_DIR), E_USER_WARNING);
             }
         }
         $errors = ob_get_contents();
         ob_end_clean();
         $download = false;
         $name = pathinfo($this->here, PATHINFO_BASENAME);
         $paperOrientation = 'portrait';
         $paperSize = 'letter';
         extract($this->viewVars, EXTR_IF_EXISTS);
         $dompdf = new DOMPDF();
         $dompdf->load_html($errors . parent::render($view, $layout), Configure::read('App.encoding'));
         $dompdf->set_protocol('');
         $dompdf->set_protocol(WWW_ROOT);
         $dompdf->set_base_path('/');
         $dompdf->set_paper($paperSize, $paperOrientation);
         $dompdf->render();
         $dompdf->stream($name, array('Attachment' => $download));
     } catch (Exception $e) {
         $this->request->params['ext'] = 'html';
         throw $e;
     }
 }
 /**
  * Préparation de dompdf pour la conversion
  * 
  * @param string $format      format de la page
  * @param string $orientation orientation de la page
  * 
  * @return void
  */
 function prepare($format, $orientation)
 {
     CAppUI::requireModuleFile("dPcompteRendu", "dompdf_config");
     CAppUI::requireLibraryFile("dompdf/dompdf_config.inc");
     $this->dompdf = new dompdf();
     $this->dompdf->set_base_path(realpath(dirname(__FILE__) . "/../../../../"));
     $this->dompdf->set_paper($format, $orientation);
     if (CAppUI::conf("dPcompteRendu CCompteRendu dompdf_host")) {
         $this->dompdf->set_protocol(isset($_SERVER["HTTPS"]) ? "https://" : "http://");
         $this->dompdf->set_host($_SERVER["SERVER_NAME"]);
     }
 }
Example #4
2
function pdf_create($html, $filename = '', $stream = TRUE)
{
    require_once "dompdf-master/dompdf_config.inc.php";
    $dompdf = new DOMPDF();
    $dompdf->set_paper('a4', 'landscape');
    $dompdf->load_html($html);
    $dompdf->render();
    if ($stream) {
        $dompdf->stream($filename . ".pdf", array("Attachment" => false));
    } else {
        return $dompdf->output();
    }
}
Example #5
1
 public static function cargarDocumento($html, $nombre, $salida, $correo, $curso, $edicion, $orientacion = 'horizontal')
 {
     //$html = file_get_contents('http://localhost/mercal/index.php?ctrl=almacen&acc=mostAlma');
     //$html = file_get_contents('http://localhost/mercal/index.php?ctrl=entrada&acc=listado');
     # Instanciamos un objeto de la clase DOMPDF.
     $mipdf = new DOMPDF();
     # Definimos el tamaño y orientación del papel que queremos.
     # O por defecto tomará el que está en el fichero de configuración. // portrait
     if ($orientacion == 'horizontal') {
         $mipdf->set_paper("A4", "landscape");
     } elseif ($orientacion == 'vertical') {
         $mipdf->set_paper("A4", "portrait");
     }
     $html = preg_replace('/á/', 'á', $html);
     $html = preg_replace('/(Á)/', 'Á', $html);
     $html = preg_replace('/é/', 'é', $html);
     $html = preg_replace('/(É)/', 'É', $html);
     $html = preg_replace('/í/', 'í', $html);
     $html = preg_replace('/(Í)/', 'Í', $html);
     $html = preg_replace('/ó/', 'ó', $html);
     $html = preg_replace('/(Ó)/', 'Ó', $html);
     $html = preg_replace('/ú/', 'ú', $html);
     $html = preg_replace('/(Ú)/', 'Ú', $html);
     $html = preg_replace('/(ñ)/', 'ñ', $html);
     $html = preg_replace('/(Ñ)/', 'Ñ', $html);
     # Cargamos el contenido HTML.
     $mipdf->load_html(utf8_decode($html));
     # Renderizamos el documento PDF.
     $mipdf->render();
     # Enviamos el fichero PDF al navegador.
     //$mipdf ->stream($nombre . '.pdf');
     if ($salida == 'guardar') {
         $output = $mipdf->output();
         //	file_put_contents('recursos/'.$nombre . '.pdf', $output);
         $archivo = 'recursos/' . $nombre . '.pdf';
         //		$archivo = ''.$nombre.'.pdf';
         //	$contacto = new contacto("Certificado de Participación", "Certificado de Participación:", $correo, $archivo, $curso, $edicion);
         //	$resultado = $contacto->enviarCertificado();
     } elseif ($salida == 'descargar') {
         $archivo = $mipdf->stream($nombre . '.pdf');
         $contacto = new contacto("Certificado de Participación", "Certificado de Participación:", $correo);
         $resultado = $contacto->enviarCorreo();
         $mipdf->stream('recursos/' . $nombre . '.pdf');
     } elseif ($salida == 'enviar') {
         $output = $mipdf->output();
         file_put_contents('recursos/Certificado.pdf', $output);
         $archivo = 'recursos/' . $nombre . '.pdf';
         $archivo = '' . $nombre . '.pdf';
         $contacto = new contacto("Certificado de Participación", "Certificado de Participación:", $correo, $archivo, $curso, $edicion);
         $resultado = $contacto->enviarCertificado();
     }
 }
Example #6
1
function pdf_create($html, $filename = '', $stream = TRUE, $paper = 'Letter', $orientation = 'portrait')
{
    require_once "dompdf/dompdf_config.inc.php";
    $dompdf = new DOMPDF();
    $dompdf->load_html($html);
    $dompdf->set_paper($paper, $orientation);
    $dompdf->render();
    if ($stream) {
        $dompdf->stream($filename . '.pdf', array("Attachment" => 0));
    } else {
        return $dompdf->output();
    }
}
Example #7
0
 function html2pdf($html, $nombre = 'formato.pdf', $attach = false)
 {
     $dompdf = new DOMPDF();
     if (preg_match('/<!\\-\\-\\@size_paper (?P<x>[0-9\\.]+)x(?P<y>[0-9\\.]+)\\-\\->/', $html, $matches)) {
         $x = $matches['x'] * 72 / 25.4;
         $y = $matches['y'] * 72 / 25.4;
         $dompdf->set_paper(array(0, 0, $x, $y), $this->orien);
     } else {
         $dompdf->set_paper($this->paper, $this->orien);
     }
     $dompdf->load_html($html);
     $dompdf->render();
     $dompdf->stream($nombre, array('Attachment' => $attach));
 }
 /**
  * Render a pdf document
  * @param string $html The html to be rendered
  *
  * @throws \LogicException
  */
 protected function render($html)
 {
     // DOMPDF doesn't follow PSR convention, it uses classmap in autoload
     // and it requires some config to be used
     define('DOMPDF_ENABLE_AUTOLOAD', false);
     $filePath = $this->rootDir . "/../vendor/dompdf/dompdf/dompdf_config.inc.php";
     if (file_exists($filePath)) {
         require_once $filePath;
     } else {
         throw new \RuntimeException('DomPDF cannot be loaded');
     }
     $this->dompdf = new \DOMPDF();
     $this->dompdf->set_paper(DOMPDF_DEFAULT_PAPER_SIZE);
     $this->dompdf->load_html($html);
     $this->dompdf->render();
 }
 public function initContent()
 {
     parent::initContent();
     $id = $_GET['id'];
     $id_lang = $this->context->language->id;
     $product = new Product((int) $id);
     $link = new Link();
     $url = $link->getProductLink($product);
     $features = Db::getInstance()->ExecuteS('
 		SELECT fl.name feature_name, fvl.value feature_value
 		FROM ' . _DB_PREFIX_ . 'feature_product fp
 		LEFT JOIN ' . _DB_PREFIX_ . 'feature_lang fl ON (fl.id_feature = fp.id_feature AND fl.id_lang=' . $id_lang . ' )
 		LEFT JOIN ' . _DB_PREFIX_ . 'feature_value_lang fvl ON (fvl.id_feature_value = fp.id_feature_value AND fvl.id_lang=' . $id_lang . ')
 		WHERE fp.id_product=' . $id);
     //	print_r($features);
     $images = Image::getImages((int) $id_lang, (int) $product->id);
     //Limitamos el numero de fotos a cuatro solamente
     while (count($images) > 3) {
         $var = array_pop($images);
     }
     $this->context->smarty->assign(array('product' => $product, 'lang' => $id_lang, 'image' => $images, 'dir' => Tools::getHttpHost(true) . __PS_BASE_URI__ . 'modules/pdfproduct', 'email' => Configuration::get('PS_SHOP_EMAIL'), 'url' => $url, 'address' => Configuration::get('ADDRESS_SHOP'), 'background' => Configuration::get('BACKGROUND')));
     $html = $this->context->smarty->fetch(_PS_MODULE_DIR_ . 'pdfproduct/views/templates/front/custom_template_content.tpl');
     $dompdf = new DOMPDF();
     $dompdf->set_option('enable_remote', TRUE);
     $dompdf->load_html($html);
     $dompdf->set_paper('a4', 'portrait');
     $dompdf->render();
     $dompdf->stream('producto');
     //$this->setTemplate('custom_template_content.tpl');
     //file_put_contents($filename, $dompdf->output());
     //$pdf = new PDF($product, 'CustomPdf', Context::getContext()->smarty);
     //$img_file = Tools::getHttpHost(true).__PS_BASE_URI__. '/modules/pdfproduct/views/images/background.jpg';
     //$pdf->pdf_renderer->Image($img_file, 0, 0, 210, 297, '', '', '', false, 300, '', false, false, 0);
     //$pdf->render();
 }
Example #10
0
 public static function creapdf($url, $tam = "letter", $orient = "portrait")
 {
     //		file_put_contents("fila.txt", "");
     $html = file_get_contents($url);
     if (get_magic_quotes_gpc()) {
         $html = stripslashes($html);
     }
     $ini = strpos($html, '<form');
     $fin = strpos($html, '">', $ini);
     if ($ini > 0) {
         $html = substr_replace($html, "", $ini, $fin - $ini + 2);
         $html = str_replace("</form>", "", $html);
     }
     //		file_put_contents("fila.txt", $html . "\r\n", FILE_APPEND);
     $dompdf = new DOMPDF();
     $dompdf->load_html($html);
     $dompdf->set_paper($tam, $orient);
     $dompdf->render();
     $dompdf->view = "FitH";
     $dompdf->statusbar = 0;
     $dompdf->messages = 0;
     $dompdf->navpanes = 0;
     $dompdf->stream("sample.pdf", array("Attachment" => false));
     exit(0);
 }
 function pdf_create($html, $filename, $stream = FALSE)
 {
     require_once "dompdf/dompdf_config.inc.php";
     spl_autoload_register('DOMPDF_autoload');
     $dompdf = new DOMPDF();
     $dompdf->load_html($html);
     $dompdf->set_paper("A4");
     $dompdf->render();
     if ($stream) {
         $dompdf->stream($filename . ".pdf");
     } else {
         $CI =& get_instance();
         $CI->load->helper('file');
         write_file("./pdf-report/" . $filename . ".pdf", $dompdf->output());
         $file = "./pdf-report/" . $filename . ".pdf";
         header('Content-Description: File Transfer');
         header('Content-Type: application/octet-stream');
         header("Content-Type: application/force-download");
         header('Content-Disposition: attachment; filename=' . urlencode(basename($file)));
         header('Expires: 0');
         header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
         header('Pragma: public');
         header('Content-Length: ' . filesize($file));
         ob_clean();
         flush();
         readfile($file);
         exit;
         unlink($file);
     }
 }
Example #12
0
 function html2pdf($html, $nombre = 'formato.pdf')
 {
     $dompdf = new DOMPDF();
     $dompdf->load_html($html);
     $dompdf->set_paper($this->paper, $this->orien);
     $dompdf->render();
     $dompdf->stream($nombre, array('Attachment' => false));
 }
Example #13
0
 /**
  * Generates Pdf from html
  *
  * @return string raw pdf data
  */
 public function output()
 {
     $DomPDF = new DOMPDF();
     $DomPDF->set_paper($this->_Pdf->pageSize(), $this->_Pdf->orientation());
     $DomPDF->load_html($this->_Pdf->html());
     $DomPDF->render();
     return $DomPDF->output();
 }
Example #14
0
function pdf_create($html, $filename, $paper, $orientation, $stream = TRUE)
{
    $dompdf = new DOMPDF();
    $dompdf->set_paper($paper, $orientation);
    $dompdf->load_html($html);
    $dompdf->render();
    $dompdf->stream($filename);
}
Example #15
0
 function Init($html)
 {
     require 'pdf/dompdfp.php';
     $dompdf = new DOMPDF();
     $dompdf->load_html($html);
     $dompdf->set_paper('letter', 'landscape');
     $dompdf->render();
     $dompdf->stream("report.pdf");
 }
 function pdf_create($html, $filename, $stream = TRUE)
 {
     $dompdf = new DOMPDF();
     $dompdf->set_paper("A4");
     $dompdf->load_html($html);
     $dompdf->render();
     $canvas = $dompdf->get_canvas();
     // get height and width of page
     $w = $canvas->get_width();
     $h = $canvas->get_height();
     // get font
     $font = Font_Metrics::get_font("helvetica", "normal");
     $txtHeight = Font_Metrics::get_font_height($font, 7);
     //draw line for signature manager
     $mnline = $h - 10 * $txtHeight - 24;
     $colormn = array(0, 0, 0);
     $canvas->line(20, $mnline, $w - 470, $mnline, $colormn, 1);
     //text for signature Requestor/HOD
     $textmn = "Requestor/HOD";
     $widthmn = Font_Metrics::get_text_width($textmn, $font, 12);
     $canvas->text($w - $widthmn - 480, $mnline, $textmn, $font, 12);
     // draw a line along the bottom
     $y = $h - 2 * $txtHeight - 24;
     $color = array(0, 0, 0);
     $canvas->line(16, $y, $w - 16, $y, $color, 1);
     //draw line for GM/Manager
     //$canvas->line(270, $mnline, $w - 240, $mnline, $colormn, 1);
     $canvas->line(330, $mnline, $w - 170, $mnline, $colormn, 1);
     $texthr = "GM/Manager";
     $widthhr = Font_Metrics::get_text_width($texthr, $font, 12);
     $canvas->text($w - $widthmn - 160, $mnline, $texthr, $font, 12);
     //draw line for HR
     //$canvas->line(270, $mnline, $w - 240, $mnline, $colormn, 1);
     $canvas->line(180, $mnline, $w - 310, $mnline, $colormn, 1);
     $texthr = "HR";
     $widthhr = Font_Metrics::get_text_width($texthr, $font, 12);
     $canvas->text($w - $widthmn - 325, $mnline, $texthr, $font, 12);
     //draw line for IT Officer
     $canvas->line(470, $mnline, $w - 20, $mnline, $colormn, 1);
     $textIT = "IT Officer";
     $canvas->text($w - $widthmn - 30, $mnline, $textIT, $font, 12);
     // set page number on the left side
     //$canvas->page_text(16, $y, "Page: {PAGE_NUM} of {PAGE_COUNT}", $font, 8, $color);
     $canvas->page_text($w - 324, $y, "Page: {PAGE_NUM} of {PAGE_COUNT}", $font, 8, $color);
     // set additional text
     $text = "ESRNL PORTAL";
     $width = Font_Metrics::get_text_width($text, $font, 8);
     $canvas->text($w - $width - 16, $y, $text, $font, 8);
     if ($stream) {
         $dompdf->stream($filename . ".pdf");
     } else {
         $CI =& get_instance();
         $CI->load->helper('file');
         write_file($filename, $dompdf->output());
     }
 }
Example #17
0
 public function render($html, $filename, $attachment = 1, $paper = 'a4', $orientation = 'portrait')
 {
     Yii::import('ext.vendors.pdf.dompdf.*');
     require_once 'dompdf_config.inc.php';
     Yii::registerAutoloader('DOMPDF_autoload');
     $dompdf = new DOMPDF();
     $dompdf->load_html($html);
     $dompdf->set_paper($paper, $orientation);
     $dompdf->render();
     $dompdf->stream($filename . ".pdf", array("Attachment" => $attachment));
 }
Example #18
0
 /**
  * gerar PDF da Danfe.
  *
  * @param null $encoding
  * @return string
  */
 public function getPDF($encoding = null)
 {
     require_once __DIR__ . '/DomPDF/bootstrap.php';
     $html = $this->getHTML();
     $html = $this->convertEntities($html);
     $pdf = new \DOMPDF();
     $pdf->set_base_path(__DIR__);
     $pdf->load_html($html);
     $pdf->set_paper('A4', 'portrait');
     $pdf->render();
     return $pdf->output();
 }
Example #19
0
function pdf_create($html, $filename, $stream = TRUE)
{
    require_once "dompdf/dompdf_config.inc.php";
    $dompdf = new DOMPDF();
    $dompdf->load_html($html);
    $dompdf->set_paper('a4', 'landscape');
    $dompdf->render();
    if ($stream) {
        $dompdf->stream("pricebook.pdf");
    } else {
        write_file("pricebook.pdf", $dompdf->output());
    }
}
Example #20
0
function pdf_create($html, $filename, $stream = TRUE)
{
    require_once BASEPATH . "plugins/dompdf/dompdf_config.inc.php";
    //  require_once("dompdf/dompdf_config.inc.php");
    $dompdf = new DOMPDF();
    $dompdf->set_paper("a4", "portrait");
    $dompdf->load_html($html);
    $dompdf->render();
    if ($stream) {
        $dompdf->stream($filename . ".pdf");
    }
    write_file("./invoices_temp/invoice_{$filename}.pdf", $dompdf->output());
}
Example #21
0
 public static function generaPDF($file = '', $html = '', $paper = 'a4', $download = false)
 {
     require_once '../dompdf/dompdf_config.inc.php';
     $dompdf = new DOMPDF();
     $dompdf->set_paper($paper);
     $dompdf->load_html(utf8_encode($html));
     ini_set("memory_limit", "32M");
     $dompdf->render();
     file_put_contents($file, $dompdf->output());
     if ($download) {
         $dompdf->stream($file);
     }
 }
function pdf_create($html, $filename = '', $stream = TRUE, $papersize = 'letter', $orientation = 'portrait')
{
    require_once "dompdf/dompdf_config.inc.php";
    $dompdf = new DOMPDF();
    $dompdf->load_html($html);
    $dompdf->set_paper($papersize, $orientation);
    $dompdf->render();
    if ($stream) {
        $dompdf->stream($filename . ".pdf");
    } else {
        return $dompdf->output();
    }
}
/**
 * Create a PDF
 *
 * The minimum required to create a PDF is some HTML provided as a string.
 * This is easily done in CI by providing the contents of a view.
 *
 * Example:
 * ------------------------------------------------------
 *   $this->load->helper('pdf_creation');
 *   $html = $this->load->view(
 *             'pdf_template', 
 *             ( isset( $view_data ) ) ? $view_data : '', 
 *             TRUE 
 *   );
 *   pdf_create( $html );
 * ------------------------------------------------------
 *
 * @param  string  HTML to be used for making a PDF
 * @param  array   Configuration options
 */
function pdf_create($html, $config = array())
{
    $defaults = array('output_type' => 'stream', 'filename' => microtime(TRUE) . '.pdf', 'upload_dir' => FCPATH . 'upload_directory/pdfs/', 'load_html' => TRUE, 'html_encoding' => '', 'load_html_file' => FALSE, 'output_compression' => 1, 'set_base_path' => FALSE, 'set_paper' => FALSE, 'paper_size' => 'letter', 'paper_orientation' => 'portrait', 'stream_compression' => 1, 'stream_attachment' => 1);
    // Set options from defaults and incoming config array
    $options = array_merge($defaults, $config);
    // Remove any previously created headers
    if (is_php('5.3.0') && $options['output_type'] == 'stream') {
        header_remove();
    }
    // Load dompdf
    require_once "dompdf/dompdf_config.inc.php";
    // Create a dompdf object
    $dompdf = new DOMPDF();
    // Set supplied base path
    if ($options['set_base_path'] !== FALSE) {
        $dompdf->set_base_path($options['set_base_path']);
    }
    // Set supplied paper
    if ($options['set_paper'] !== FALSE) {
        $dompdf->set_paper($options['paper_size'], $options['paper_orientation']);
    }
    // Load the HTML that will be turned into a PDF
    if ($options['load_html_file'] !== FALSE) {
        // Loads an HTML file
        $dompdf->load_html_file($html);
    } else {
        // Loads an HTML string
        $dompdf->load_html($html, $options['html_encoding']);
    }
    // Create the PDF
    $dompdf->render();
    // If destination is the browser
    if ($options['output_type'] == 'stream') {
        $dompdf->stream($options['filename'], array('compress' => $options['stream_compression'], 'Attachment' => $options['stream_attachment']));
    } else {
        if ($options['output_type'] == 'string') {
            return $dompdf->output($options['output_compression']);
        } else {
            // Get an instance of CI
            $CI =& get_instance();
            // Create upload directories if they don't exist
            if (!is_dir($options['upload_path'])) {
                mkdir($options['upload_path'], 0777, TRUE);
            }
            // Load the CI file helper
            $CI->load->helper('file');
            // Save the file
            write_file($options['upload_path'] . $options['filename'], $dompdf->output());
        }
    }
}
function pdf_create($html, $filename, $stream = TRUE)
{
    if (isset($to_pdf)) {
        $path = $to_pdf['path'];
    }
    $dompdf = new DOMPDF();
    $dompdf->set_paper('letter', 'portrait');
    $dompdf->load_html($html);
    $dompdf->render();
    if ($stream) {
        $dompdf->stream($filename . '.pdf');
    }
    write_file($path . $filename . '.pdf', $dompdf->output());
}
Example #25
0
function pdf_legal($html, $filename = '', $stream = TRUE)
{
    require_once "dompdf/dompdf_config.inc.php";
    $dompdf = new DOMPDF();
    $dompdf->set_paper("Legal", "portrait");
    $dompdf->load_html($html);
    $dompdf->render();
    if ($stream) {
        //$dompdf->stream($filename.".pdf");
        echo $dompdf->stream($filename . ".pdf", array("Attachment" => false));
    } else {
        return $dompdf->output();
    }
}
 static function _html2pdf_dompdf($paper_size, $orientation, $html, $output, $fileName)
 {
     require_once 'packages/dompdf/dompdf_config.inc.php';
     spl_autoload_register('DOMPDF_autoload');
     $dompdf = new DOMPDF();
     $dompdf->set_paper($paper_size, $orientation);
     $dompdf->load_html($html);
     $dompdf->render();
     if ($output) {
         return $dompdf->output();
     } else {
         $dompdf->stream($fileName);
     }
 }
Example #27
0
function pdf_create($html, $filename = '', $paper, $orientation, $stream = TRUE)
{
    require_once "dompdf/dompdf_config.inc.php";
    $dompdf = new DOMPDF();
    $dompdf->set_paper($paper, $orientation);
    $dompdf->load_html($html);
    $dompdf->render();
    if ($stream) {
        $dompdf->stream($filename . ".pdf", array("Attachment" => 0));
    } else {
        $dompdf->stream($filename . ".pdf");
    }
    // For download
}
Example #28
0
function pdf_create_landscape($html, $filename = '', $stream = TRUE)
{
    require_once "dompdf/dompdf_config.inc.php";
    $dompdf = new DOMPDF();
    $dompdf->load_html($html);
    $dompdf->set_paper('a4', 'landscape');
    // change 'a4' to whatever you want
    $dompdf->render();
    if ($stream) {
        $dompdf->stream($filename . ".pdf");
    } else {
        return $dompdf->output();
    }
}
Example #29
0
function pdf_create($html, $orientation, $filename, $stream = TRUE, $paper_size = NULL)
{
    $base = '';
    require_once "dompdf/dompdf_config.inc.php";
    spl_autoload_register('DOMPDF_autoload');
    $dompdf = new DOMPDF();
    if (!empty($paper_size)) {
        $dompdf->set_paper($paper_size, $orientation);
    } else {
        $dompdf->set_paper("a4", $orientation);
    }
    $dompdf->load_html($html);
    $dompdf->render();
    if ($stream) {
        $dompdf->stream($filename . ".pdf");
    } else {
        $ci =& get_instance();
        $ci->load->helper('file');
        if (!is_dir("file")) {
            $cd = mkdir("file", 0777, TRUE);
        }
        write_file('file/' . $filename . '.pdf', $dompdf->output());
    }
}
Example #30
-4
File: Pdf.php Project: ibnoe/dms
 function pdf_create($html, $filename = '', $stream = FALSE)
 {
     require_once APPPATH . "third-party/dompdf_config.inc.php";
     //Require Loader Class n Config
     spl_autoload_register('DOMPDF_autoload');
     //Autoload Resource
     ini_set("memory_limit", "999M");
     ini_set("max_execution_time", "999");
     $dompdf = new DOMPDF();
     //Instansiasi
     $dompdf->load_html($html);
     //Load HTML File untuk dirender
     //   $dompdf->set_base_path(realpath($css));
     $dompdf->set_paper(array(0, 0, 8.5 * 72, 13.5 * 72), "portrait");
     //array(0,0, 8.5 * 72, 11 * 72)
     $dompdf->render();
     //Proses Rendering File
     $canvas = $dompdf->get_canvas();
     $font = Font_Metrics::get_font("helvetica", "bold");
     $canvas->page_text(830, 578, "Halaman: {PAGE_NUM} dari {PAGE_COUNT}", $font, 8, array(0, 0, 0));
     if ($stream == TRUE) {
         $dompdf->stream($filename, array('Attachment' => 0));
     } else {
         $CI =& get_instance();
         $CI->load->helper('file');
         write_file($filename, $dompdf->output());
         //file name adalah ABSOLUTE PATH dari tempat menyimpan file PDF
     }
 }