private function printRelatorioHTMLPDF($html)
 {
     $this->getContext()->getConfiguration()->loadHelpers('Partial');
     $mpdf = new mPDF('', 'A4', '', '', 5, 5, 37, 37, 3, 3);
     $mpdf->useOnlyCoreFonts = true;
     // false is default
     $mpdf->SetWatermarkText("PƉROLA NEGRA");
     $mpdf->showWatermarkText = true;
     $mpdf->watermark_font = 'DejaVuSansCondensed';
     $mpdf->watermarkTextAlpha = 0.1;
     $mpdf->SetDisplayMode('fullpage');
     $stylesheet = file_get_contents('css/relatorios.css');
     $mpdf->WriteHTML($stylesheet, 1);
     $mpdf->SetHTMLHeader(utf8_encode(get_partial('header')));
     $mpdf->SetHTMLFooter(utf8_encode(get_partial('footer')));
     $mpdf->SetMargins(0, 0, 65);
     $mpdf->WriteHTML(utf8_encode($html));
     $mpdf->Output();
 }
 /**
  * @param $path
  * @param $print_portrait
  * @param $print_paper_size
  * @param $labels
  * @return bool|string
  */
 public function explodePDF($path, $print_portrait, $print_paper_size, $labels)
 {
     ini_set('memory_limit', '1024M');
     if (!is_file($path)) {
         return false;
     }
     $isPortrait = $print_portrait;
     $paperSize = in_array($print_paper_size, ['A2', 'A3', 'A4', 'A5']) ? $print_paper_size : 'A4';
     $pdfInfo = $this->pdfInfo($path);
     if (!$pdfInfo) {
         return false;
     }
     $pdfSize = array_map(function ($item) {
         return trim((int) $item);
     }, explode('x', $pdfInfo['Page size']));
     $pdfSize['w'] = $pdfSize[0] * 0.75;
     $pdfSize['h'] = $pdfSize[1] * 0.75;
     $paperSizes = ['A2' => ['w' => 420, 'h' => 594], 'A3' => ['w' => 297, 'h' => 420], 'A4' => ['w' => 210, 'h' => 297], 'A5' => ['w' => 148, 'h' => 210]];
     include dirname(__DIR__) . "/lib/mpdf/mpdf.php";
     $mgl = 10;
     $mgr = 10;
     $mgt = 20 + 10;
     $mgb = 5 + 10;
     $mgh = 9;
     $mgf = 9;
     if ($isPortrait) {
         $mgl = 20;
         $mgr = 10;
         $mgt = 5 + 10;
         $mgb = 5 + 10;
         $mgh = 9;
         $mgf = 9;
     }
     $mpdf = new \mPDF('c', $paperSize . ($isPortrait ? '-P' : '-L'));
     $mpdf->SetImportUse();
     $mpdf->SetDisplayMode('fullpage');
     $mpdf->SetCompression(true);
     //$mpdf->SetAutoPageBreak(true);
     $mpdf->mirrorMargins = true;
     $source = $mpdf->SetSourceFile($path);
     $page_w = $isPortrait ? $paperSizes[$paperSize]['w'] : $paperSizes[$paperSize]['h'];
     $page_h = $isPortrait ? $paperSizes[$paperSize]['h'] : $paperSizes[$paperSize]['w'];
     $iter_w = ceil($pdfSize['w'] / $page_w / 2);
     $iter_h = ceil($pdfSize['h'] / $page_h / 1);
     $crop_x = 0;
     $crop_y = 0;
     $head_left = isset($labels['head_left']) ? $labels['head_left'] : '';
     $head_center = isset($labels['head_center']) ? $labels['head_center'] : '';
     $head_right = isset($labels['head_right']) ? $labels['head_right'] : '';
     $footer_left = isset($labels['footer_left']) ? $labels['footer_left'] : '';
     $footer_center = isset($labels['footer_center']) ? $labels['footer_center'] : '';
     $footer_right = isset($labels['footer_right']) ? $labels['footer_right'] : '';
     $header = '
         <table width="100%" style="vertical-align: bottom; font-size: 12pt; font-weight: bold"><tr>
         <td width="33%">' . $head_left . '</td>
         <td width="33%" align="center">' . $head_center . '</td>
         <td width="33%" style="text-align: right;">' . $head_right . '</td>
         </tr></table>
         ';
     $footer = '
         <table width="100%" style="vertical-align: bottom; font-size: 12pt; font-weight: bold"><tr>
         <td width="33%">' . $footer_left . '</td>
         <td width="33%" align="center">' . $footer_center . '</td>
         <td width="33%" style="text-align: right;">' . $footer_right . '</td>
         </tr></table>
         ';
     $mpdf->SetHTMLHeader($header);
     $mpdf->SetHTMLHeader($header, 'E');
     $mpdf->SetHTMLFooter($footer);
     $mpdf->SetHTMLFooter($footer, 'E');
     for ($i = 0; $i < $iter_w; $i++) {
         if ($i > 0) {
             $mpdf->AddPage();
         }
         // '', '', '', '', '', $mgl, $mgr, $mgt, $mgb, $mgh, $mgf
         $tpl = $mpdf->ImportPage($source, $crop_x, $crop_y, $page_w - ($mgl + $mgr), $page_h - ($mgt + $mgb));
         $mpdf->UseTemplate($tpl, $mgl, $mgt);
         if ($iter_h > 2) {
             $mpdf->AddPage();
             $tpl = $mpdf->ImportPage($source, $crop_x, $crop_y, $page_w - ($mgl + $mgr), $page_h - ($mgt + $mgb));
             $mpdf->UseTemplate($tpl, $mgl, $mgt);
         }
         $crop_x += $page_w - ($mgl + $mgr);
     }
     $mpdf->Output($path . 'gen.pdf', 'F');
     return $path . 'gen.pdf';
 }
Example #3
1
 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     $this->app->bind('mpdf.wrapper', function ($app, $cfg) {
         $app['mpdf.pdf'] = $app->share(function ($app) use($cfg) {
             if (!empty($cfg)) {
                 foreach ($cfg as $key => $value) {
                     Config::set('pdf.' . $key, $value);
                 }
             }
             $mpdf = new \mPDF(Config::get('pdf.mode'), Config::get('pdf.defaultFontSize'), Config::get('pdf.defaultFont'), Config::get('pdf.marginLeft'), Config::get('pdf.marginRight'), Config::get('pdf.marginTop'), Config::get('pdf.marginBottom'), Config::get('pdf.marginHeader'), Config::get('pdf.Footer'), Config::get('pdf.orientation'));
             $permissions = [];
             foreach (Config::get('pdf.protection.permissions') as $perm => $enable) {
                 if ($enable) {
                     $permissions[] = $perm;
                 }
             }
             $mpdf->SetProtection($permissions, Config::get('pdf.protection.user_password'), Config::get('pdf.protection.owner_password'), Config::get('pdf.protection.length'));
             $mpdf->SetTitle(Config::get('pdf.title'));
             $mpdf->SetAuthor(Config::get('pdf.author'));
             $mpdf->SetWatermarkText(Config::get('pdf.watermark'));
             $mpdf->showWatermarkText = Config::get('pdf.showWatermark');
             $mpdf->watermark_font = Config::get('pdf.watermarkFont');
             $mpdf->watermarkTextAlpha = Config::get('pdf.watermarkTextAlpha');
             $mpdf->SetDisplayMode(Config::get('pdf.displayMode'));
             return $mpdf;
         });
         return new PdfWrapper($app['mpdf.pdf']);
     });
 }
Example #4
1
 public function index()
 {
     $mpdf = new mPDF('UTF-8', 'A3', '', 'demo', 0, 0);
     $mpdf->SetDisplayMode('fullpage');
     $mpdf->list_indent_first_level = 0;
     // 1 or 0 - whether to indent the first level of a list
     $mpdf->useAdobeCJK = true;
     $mpdf->autoScriptToLang = true;
     $mpdf->autoLangToFont = true;
     $mpdf->useAdobeCJK = true;
     $html = $this->getUrlInfo('http://edusystem.onpspring.org/AdminList/studentsTranscript/userid/238.html');
     var_dump($html);
     exit;
     $mpdf->WriteHTML($html);
     $mpdf->SetDisplayMode('fullpage');
     $mpdf->Output('mpdf.pdf', 'I');
     exit;
 }
Example #5
1
 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     $this->app->bind('mpdf.wrapper', function ($app, $cfg) {
         if ($cfg) {
             $app['mpdf.pdf'] = $app->share(function ($app) use($cfg) {
                 $mpdf = new \mPDF($cfg[0], $cfg[1], $cfg[2], $cfg[3], $cfg[4], $cfg[5], $cfg[6], $cfg[7], $cfg[8], $cfg[9], $cfg[10]);
                 $mpdf->SetProtection(array('print'));
                 $mpdf->SetTitle("");
                 $mpdf->SetAuthor("");
                 $mpdf->SetWatermarkText("");
                 $mpdf->showWatermarkText = true;
                 $mpdf->watermark_font = 'DejaVuSansCondensed';
                 $mpdf->watermarkTextAlpha = 0.1;
                 $mpdf->SetDisplayMode('fullpage');
                 return $mpdf;
             });
         } else {
             $mpdf = new \mPDF('th', 'A4', '', '', 10, 10, 10, 10, 10, 5);
             $mpdf->SetProtection(array('print'));
             $mpdf->SetTitle("");
             $mpdf->SetAuthor("");
             $mpdf->SetWatermarkText("");
             $mpdf->showWatermarkText = true;
             $mpdf->watermark_font = 'DejaVuSansCondensed';
             $mpdf->watermarkTextAlpha = 0.1;
             $mpdf->SetDisplayMode('fullpage');
             $app['mpdf.pdf'] = $mpdf;
         }
         return new PdfWrapper($app['mpdf.pdf']);
     });
     // // work --------------------------------------------------------------------------start ----------
     // 	$this->app['mpdf.pdf'] = $this->app->share(function($app)
     // 	{
     // 		// $cfg =['th','A0','','',10,10,10,10,10,5,'L'];
     // 		$cfg = $app['config']['mpdfconfig.pdf.options'];
     // 		consolelog('cfg',$cfg);
     // 		if($cfg) {
     // 			$mpdf = new \mPDF( $cfg[0],$cfg[1],$cfg[2],$cfg[3],$cfg[4],$cfg[5],$cfg[6],$cfg[7],$cfg[8],$cfg[9],$cfg[10] );
     // 		} else {
     // 			$mpdf=new \mPDF('th','A4','','',10,10,10,10,10,5);
     // 		}
     // 		$mpdf->SetProtection(array('print'));
     // 		$mpdf->SetTitle("TOMATO POS - Invoice");
     // 		$mpdf->SetAuthor("Thongchai Lim");
     // 		$mpdf->SetWatermarkText("Paid");
     // 		$mpdf->showWatermarkText = true;
     // 		$mpdf->watermark_font = 'DejaVuSansCondensed';
     // 		$mpdf->watermarkTextAlpha = 0.1;
     // 		$mpdf->SetDisplayMode('fullpage');
     // 		return $mpdf;
     // 	});
     // 	$this->app['mpdf.wrapper'] = $this->app->share(function($app)
     // 	{
     // 		return new PdfWrapper($app['mpdf.pdf']);
     // 	});
     // // work --------------------------------------------------------------------------end----------
 }
 public function send()
 {
     $this->loadData();
     $mpdf = new mPDF('utf-8', 'A4');
     $mpdf->useOnlyCoreFonts = true;
     $mpdf->SetDisplayMode('fullpage');
     $mpdf->SetAutoFont(0);
     // CSS soubory
     $css[] = './styles/faktura.css';
     // faktura v HTML (PHP, atd.)
     $html[] = KIWI_INVOICE . '?bauth&o=' . $this->id;
     foreach ($css as $filename) {
         @$mpdf->WriteHTML(file_get_contents($filename, true), 1);
     }
     foreach ($html as $filename) {
         @$mpdf->WriteHTML(file_get_contents($this->file2Url($filename)), 2);
     }
     $o_id = sprintf("%03d", $this->data->YID) . "-{$this->data->Year}";
     $name = "invoice_{$o_id}.pdf";
     $mpdf->Output($name, "D");
     // download
 }
 protected function renderPdf($html, $filename, $options)
 {
     $this->_helper->viewRenderer->setNoRender();
     $margin_left = isset($options['margins']['left']) ? $options['margins']['left'] : 15;
     $margin_right = isset($options['margins']['right']) ? $options['margins']['right'] : 15;
     $margin_top = isset($options['margins']['top']) ? $options['margins']['top'] : 15;
     $margin_bottom = isset($options['margins']['bottom']) ? $options['margins']['bottom'] : 15;
     $margin_header = isset($options['margins']['header']) ? $options['margins']['header'] : 15;
     $margin_footer = isset($options['margins']['footer']) ? $options['margins']['footer'] : 15;
     $format = isset($options['format']) ? $options['format'] : 'A4-L';
     $output_mode = isset($options['output']) ? $options['output'] : 'D';
     define('_MPDF_URI', APPLICATION_PATH . '/../library/MPDF54/');
     define('_MPDF_TEMP_PATH', '/var/www/tm/');
     require_once APPLICATION_PATH . "/../library/MPDF54/mpdf.php";
     /* argumentos:
      * mode: codificacao (basicamente)
      * format: formato da pagina (pode ser adicionado -L depois do formato para forcar modo paisagem
      * tamanho da fonte: e passado 0 para que o tamanho seja setado no arquivo CSS
      * fonte
      * margin_left
      * margin_right
      * margin_top
      * margin_bottom
      * margin_header
      * margin_footer
      */
     $mpdf = new mPDF('utf-8', $format, 0, '', $margin_left, $margin_right, $margin_top, $margin_bottom, $margin_header, $margin_footer);
     $mpdf->ignore_invalid_utf8 = true;
     $mpdf->charset_in = 'utf-8';
     $mpdf->SetDisplayMode('fullpage', 'two');
     $mpdf->WriteHTML($mpdf->purify_utf8($html));
     $mpdf->Output($filename . '.pdf', $output_mode);
     exit;
 }
 function loadMpdf($html, $output = null, $param = 1)
 {
     // echo "masuk";
     // echo $output;
     // exit;
     global $CONFIG;
     $pdf_ext = '.pdf';
     $mpdfEngine = '../' . LIBS . 'mpdf/mpdf' . $CONFIG[$this->configkey]['php_ext'];
     if (is_file($mpdfEngine)) {
         require_once $mpdfEngine;
         if ($param == 1) {
             $mpdf = new mPDF('c', 'A4', '', '', 15, 15, 16, 16, 9, 9, 'L');
             $mpdf->SetDisplayMode('fullpage');
         } elseif ($param == 2) {
             $mpdf = new mPDF('', '', '', '', 15, 15, 16, 16, 9, 9, 'P');
             $mpdf->AddPage('L', '', '', '', '', 15, 15, 16, 16, 9, 9);
         }
         // $mpdf=new mPDF('c','A4','','',32,25,27,25,16,13);
         // $mpdf->setFooter('{PAGENO}') ;
         $mpdf->WriteHTML($html);
         $mpdf->Output($output . '-' . date(ymdhis) . $pdf_ext, 'D');
         logFile('load excel success');
     } else {
         logFile('excel lib not found');
     }
     exit;
 }
 function loadMpdf($html, $output = null, $path = null)
 {
     // echo "masuk";
     // echo $output;
     // exit;
     global $CONFIG;
     $hslpath = $path . "hasil/";
     $pdf_ext = '.pdf';
     $mpdfEngine = LIBS . 'mpdf/mpdf' . $CONFIG[$this->configkey]['php_ext'];
     if (is_file($mpdfEngine)) {
         require_once $mpdfEngine;
         $mpdf = new mPDF('c', 'A4', '', '', 32, 25, 27, 25, 16, 13);
         $mpdf->SetDisplayMode('fullpage');
         /*$mpdf=new mPDF('','','','',15,15,16,16,9,9,'P');
           $mpdf->AddPage('L','','','','',15,15,16,16,9,9);
           $mpdf->setFooter('{PAGENO}') ;*/
         $stylesheet = file_get_contents($CONFIG['default']['root_path'] . 'assets/css/mpdfstyleA4.css');
         $mpdf->WriteHTML($stylesheet, 1);
         $mpdf->WriteHTML($html);
         $mpdf->Output($hslpath . $output . $pdf_ext, 'F');
         logFile('load excel success');
         return true;
     } else {
         logFile('excel lib not found');
     }
     exit;
 }
 /**
  * Generates the invoice with MPDF lib.
  * @param $dest
  * @return string
  */
 protected function generate($html_sections, $dest, $paid)
 {
     set_time_limit(0);
     $mpdf_filename = BEWPI_LIB_DIR . 'mpdf/mpdf.php';
     include $mpdf_filename;
     $mpdf_options = $this->get_mpdf_options();
     $mpdf = new mPDF($mpdf_options['mode'], $mpdf_options['format'], $mpdf_options['default_font_size'], $mpdf_options['default_font'], $mpdf_options['margin_left'], $mpdf_options['margin_right'], $mpdf_options['margin_top'], $mpdf_options['margin_bottom'], $mpdf_options['margin_header'], $mpdf_options['margin_footer'], $mpdf_options['orientation']);
     $mpdf->useOnlyCoreFonts = false;
     // false is default
     if ((bool) $this->template_options['bewpi_show_payment_status'] && $paid) {
         $mpdf->SetWatermarkText(__('Paid', 'woocommerce-pdf-invoices'));
         $mpdf->showWatermarkText = true;
     }
     $mpdf->SetDisplayMode('fullpage');
     //$mpdf->useSubstitutions = true;
     $mpdf->autoScriptToLang = true;
     $mpdf->autoLangToFont = true;
     $mpdf->setAutoTopMargin = 'stretch';
     $mpdf->setAutoBottomMargin = 'stretch';
     $mpdf->autoMarginPadding = 10;
     //$mpdf->debug = true;
     //$mpdf->showImageErrors = true;
     if (!empty($html_sections['header'])) {
         $mpdf->SetHTMLHeader($html_sections['header']);
     }
     if (!empty($html_sections['footer'])) {
         $mpdf->SetHTMLFooter($html_sections['footer']);
     }
     $mpdf->WriteHTML($html_sections['style'] . $html_sections['body']);
     $mpdf = apply_filters('bewpi_mpdf', $mpdf);
     $mpdf->Output($dest === 'F' ? $this->full_path : $this->filename, $dest);
 }
Example #11
0
 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     // load config
     $this->mergeConfigFrom(__DIR__ . '/../../config/pdf.php', 'pdf');
     // bind wrapper
     $this->app->bind('mpdf.wrapper', function ($app, $cfg) {
         $app['mpdf.pdf'] = $app->share(function ($app) use($cfg) {
             if (!empty($cfg)) {
                 foreach ($cfg as $key => $value) {
                     Config::set('pdf.' . $key, $value);
                 }
             }
             $mpdf = new \mPDF(Config::get('pdf.mode'), Config::get('pdf.format'), Config::get('pdf.defaultFontSize'), Config::get('pdf.defaultFont'), Config::get('pdf.marginLeft'), Config::get('pdf.marginRight'), Config::get('pdf.marginTop'), Config::get('pdf.marginBottom'), Config::get('pdf.marginHeader'), Config::get('pdf.marginFooter'), Config::get('pdf.orientation'));
             $mpdf->SetProtection(array('print'));
             $mpdf->SetTitle(Config::get('pdf.title'));
             $mpdf->SetAuthor(Config::get('pdf.author'));
             $mpdf->SetWatermarkText(Config::get('pdf.watermark'));
             $mpdf->showWatermarkText = Config::get('pdf.showWatermark');
             $mpdf->watermark_font = Config::get('pdf.watermarkFont');
             $mpdf->watermarkTextAlpha = Config::get('pdf.watermarkTextAlpha');
             $mpdf->SetDisplayMode(Config::get('pdf.displayMode'));
             return $mpdf;
         });
         return new PdfWrapper($app['mpdf.pdf']);
     });
 }
Example #12
0
 /**
  * Erzeugt ein PDF auf Basis der Ć¼bergebenen Funktion.
  * @param $module
  * @param $action
  * @param $param
  * @param null $filename falls kein Dateiname angegeben wird, wird das PDF direkt im Browser ausgegeben
  * @throws \Exception
  */
 public static function generate($module, $action, $param, $filename = null, $template = true, $margin = 0)
 {
     $druckinhalt = new WrapperControl(null, 'druck');
     $druckinhalt->setModule($module)->setAction($action)->addParams($param);
     $pdf = new \mPDF('de-DE', 'A4');
     $pdf->SetDisplayMode('fullpage');
     // Zeigt eine ganze Seite an, wenn das PDF in Acrobat geƶffnet wird
     if ($margin > 0) {
         $pdf->SetTopMargin($margin);
     }
     $pdf->SetFooter('Seite {PAGENO} / {nb}');
     //file_get_contents('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css') .
     $stylesheet = file_get_contents('templates/print/css/default.css');
     $pdf->WriteHTML($stylesheet, 1);
     if ($template && file_exists('site/Print.template.html')) {
         $vars = ['heading' => Application::getCurrentResponse()->getMetadata()->getHeading()];
         $header = Parser::parse(null, null, $vars, file_get_contents('site/Print.template.html'));
         $pdf->WriteHTML($header, 2);
     }
     $pdf->WriteHTML($druckinhalt->toHtml(), 2);
     if ($filename === null) {
         $pdf->Output($module . $action . '.pdf', 'I');
     } else {
         //$filename = Files::validateFilename($filename);
         $pdf->Output($filename, 'F');
     }
     unset($pdf);
 }
Example #13
0
 protected function basicMPdfConfiguration(\mPDF $mPDF)
 {
     $mPDF->biDirectional = false;
     $mPDF->useSubstitutions = false;
     $mPDF->simpleTables = true;
     $mPDF->SetAuthor($this->documentAuthor);
     $mPDF->SetDisplayMode('default', 'continuous');
 }
 /**
  * @param array $options Options for mPDF.
  * @return \mPDF
  */
 protected function createMpdfInstance($options)
 {
     $tempDir = sys_get_temp_dir() . '/mpdf';
     is_dir($tempDir) or mkdir($tempDir);
     defined('_MPDF_TEMP_PATH') or define('_MPDF_TEMP_PATH', $tempDir);
     $mpdf = new \mPDF(isset($options['lang']) ? $options['lang'] : static::DEFAULT_LANGUAGE, isset($options['format']) ? $options['format'] : static::DEFAULT_PAGE_FORMAT, isset($options['fontSize']) ? $options['fontSize'] : static::DEFAULT_FONT_SIZE, isset($options['font']) ? $options['font'] : static::DEFAULT_FONT, isset($options['marginLeft']) ? $options['marginLeft'] : static::DEFAULT_MARGIN, isset($options['marginRight']) ? $options['marginRight'] : static::DEFAULT_MARGIN, isset($options['marginTop']) ? $options['marginTop'] : static::DEFAULT_MARGIN, isset($options['marginBottom']) ? $options['marginBottom'] : static::DEFAULT_MARGIN, isset($options['marginHeader']) ? $options['marginHeader'] : static::DEFAULT_MARGIN, isset($options['marginFooter']) ? $options['marginFooter'] : static::DEFAULT_MARGIN, isset($options['orientation']) ? $options['orientation'] : static::DEFAULT_ORIENTATION);
     $mpdf->SetDisplayMode('fullpage', 'two');
     $mpdf->SetProtection(['copy', 'print', 'print-highres'], null, uniqid(), 128);
     return $mpdf;
 }
Example #15
0
 public function _gen_pdf($html, $paper, $layoutpage)
 {
     ob_end_clean();
     $mpdf = new mPDF('utf-8', $paper);
     ini_set('memory_limit', '100M');
     $mpdf->debug = true;
     $mpdf->SetDisplayMode('fullpage');
     $mpdf->AddPage($layoutpage);
     $mpdf->WriteHTML($html);
     $mpdf->Output();
 }
Example #16
0
 /**
  * Gerar PDF com colunas
  *
  * @param  String $html_data View que vai compor o PDF
  * @param  String $file_name Nome do arquivo
  */
 function create_pdf_col($html_data, $file_name = "")
 {
     if ($file_name == "") {
         $file_name = 'meu-pdf-' . date('d-m-Y');
     }
     require_once APPPATH . 'helpers/mpdf/mpdf.php';
     $hyphenate = new stdClass();
     $mypdf = new mPDF();
     $mypdf->SetDisplayMode('fullpage');
     $hyphenate->mypdf = true;
     $mypdf->KeepColumns = true;
     $mypdf->SetColumns(2, 'J', 5);
     $mypdf->WriteHTML($html_data);
     $mypdf->Output($file_name . '.pdf', 'D');
 }
 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     $this->mergeConfigFrom(__DIR__ . '/../config/pdf.php', 'pdf');
     $this->app->bind('mpdf.wrapper', function ($app, $cfg) {
         if (Config::has('pdf.custom_font_path') && Config::has('pdf.custom_font_data')) {
             define(_MPDF_SYSTEM_TTFONTS_CONFIG, __DIR__ . '/../mpdf_ttfonts_config.php');
         }
         $mpdf = new \mPDF(Config::get('pdf.mode'), Config::get('pdf.format'), Config::get('pdf.default_font_size'), Config::get('pdf.default_font'), Config::get('pdf.margin_left'), Config::get('pdf.margin_right'), Config::get('pdf.margin_top'), Config::get('pdf.margin_bottom'), Config::get('pdf.margin_header'), Config::get('pdf.margin_footer'), Config::get('pdf.orientation'));
         $mpdf->SetTitle(Config::get('pdf.title'));
         $mpdf->SetAuthor(Config::get('pdf.author'));
         $mpdf->SetWatermarkText(Config::get('pdf.watermark'));
         $mpdf->SetDisplayMode(Config::get('pdf.display_mode'));
         $mpdf->showWatermarkText = Config::get('pdf.show_watermark');
         $mpdf->watermark_font = Config::get('pdf.watermark_font');
         $mpdf->watermarkTextAlpha = Config::get('pdf.watermark_text_alpha');
         return new PdfWrapper($mpdf);
     });
 }
Example #18
0
    protected function generateKva(&$id,&$stylesheet,&$content)
    {
        $mpdf = new mPDF('en-x','A4','','');
        $mpdf->debug = true;
        $mpdf->SetDisplayMode('fullpage');

        $mpdf->WriteHTML($stylesheet,1);	// The parameter 1 tells that this is css/style only and no body/html/text
        $mpdf->WriteHTML($content);

        $path = Mage::getBaseDir('media').'/downloadable/'.substr($id,0,3).'/'.substr($id,3,3).'/'.substr($id,6,3).'/'.$id;

        if (!file_exists($path)) {
            mkdir($path, 0777, true);
        }


        $mpdf->Output($path.'/'.$id.'_kva.pdf', 'F');
    }
Example #19
0
 static function generatePDF($content, $orientation = 'P')
 {
     include GLPI_ROOT . "/plugins/monitoring/lib/mpdf/mpdf.php";
     $format = 'A4';
     if ($orientation == 'L') {
         $format .= '-L';
     }
     $pdf = new mPDF('c', $format, '', '', 5, 5, 10, 10, 2, 2, $orientation);
     $pdf->mirrorMargins = true;
     $pdf->SetDisplayMode('fullpage');
     $pdf->showImageErrors = true;
     $css = file_get_contents(GLPI_ROOT . '/plugins/monitoring/css/pdf.css');
     $pdf->WriteHTML($css, 1);
     $content = "<body>" . $content . "</body>";
     $pdf->WriteHTML($content, 2);
     $pdf->output();
     //      $out = $pdf->output(GLPI_PLUGIN_DOC_DIR.'/monitoring/example_001.pdf', 'F');
     exit;
 }
  static public function mpdf( $html_path, $pdf_path, $css_rel_path, $format = 'A4', $download = false) {
        
    // reporting komplett abschalten
    $error_reporting = error_reporting();
    error_reporting(0);
    
    ProjectConfiguration::registerMPDF();
    $mpdf=new mPDF('ch-DE',$format,'8','DejaVuSansCondensed',15,15,30,15,10,10); 
    $mpdf->packTableData = true;
    //$mpdf->debug = true;

    $mpdf->SetDisplayMode('fullpage');
    $mpdf->defaultfooterfontstyle='';
    $mpdf->defaultfooterfontsize='8';
    $mpdf->SetFooter(basename($pdf_path).'|Stand: {DATE j.m.Y H:i}|Seite {PAGENO}/{nbpg}');
    $mpdf->list_indent_first_level = 0; // 1 or 0 - whether to indent the first level of a list
    
    $mpdf->shrink_tables_to_fit=1;
    
    // LOAD a stylesheet
    #$stylesheet = file_get_contents(sfConfig::get('sf_web_dir').'/css/backend/pdf/class_etat.css');
    $stylesheet = file_get_contents(sfConfig::get('sf_web_dir').'/css/'.$css_rel_path);

    $mpdf->WriteHTML($stylesheet,1);  // parameter 1 indicates this is css
    
    $html = file_get_contents($html_path); 
    $mpdf->WriteHTML($html,2);
    
    //$mpdf->SetTitle();
    $mpdf->SetAuthor('');
    $mpdf->SetCreator('rockstep');
    
    if ($download) {
        $mpdf->Output( $pdf_path, 'I');
    } else {
        $mpdf->Output( $pdf_path, 'F');
    }
    
    error_reporting($error_reporting);
        
  }
Example #21
0
 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     $this->package('kendu/l4-mpdf');
     $this->app['mpdf.pdf'] = $this->app->share(function ($app) {
         $base = $app['config']->get('l4-mpdf::config.pdf.base');
         $options = $app['config']->get('l4-mpdf::config.pdf.options');
         $mpdf = new \mPDF(Config::get('pdf.mode'), Config::get('pdf.defaultFontSize'), Config::get('pdf.defaultFont'), Config::get('pdf.marginLeft'), Config::get('pdf.marginRight'), Config::get('pdf.marginTop'), Config::get('pdf.marginBottom'), Config::get('pdf.marginHeader'), Config::get('pdf.Footer'), Config::get('pdf.orientation'));
         $mpdf->SetProtection(array('print'));
         $mpdf->SetTitle(Config::get('pdf.title'));
         $mpdf->SetAuthor(Config::get('pdf.author'));
         $mpdf->SetWatermarkText(Config::get('pdf.watermark'));
         $mpdf->showWatermarkText = Config::get('pdf.showWatermark');
         $mpdf->watermark_font = Config::get('pdf.watermarkFont');
         $mpdf->watermarkTextAlpha = Config::get('pdf.watermarkTextAlpha');
         $mpdf->SetDisplayMode(Config::get('pdf.displayMode'));
         return $mpdf;
     });
     $this->app['mpdf.wrapper'] = $this->app->share(function ($app) {
         return new PdfWrapper($app['mpdf.pdf']);
     });
 }
Example #22
0
 /**
  * Export a pdf
  *
  * @static
  * @param	string	$title		Document title
  * @param	string	$css		CSS Contents
  * @param	string	$html		HTML Contents
  * @param	string	$page_format 	Default A4
  * @param	string	$orientation	Can be P|L
  * @return boolean
  */
 public static function pdf_export($title, $css, $html, $page_format = 'A4', $orientation = 'P')
 {
     // language set
     $l = array();
     $l['a_meta_charset'] = 'UTF-8';
     $l['a_meta_dir'] = 'rtl';
     $l['a_meta_language'] = X4Route_core::$lang;
     $l['w_page'] = _PAGE;
     X4Core_core::auto_load('mpdf_library');
     // create the PDF object
     $mpdf = new mPDF(X4Route_core::$lang, $page_format, 0, 0, 0, 0, 0, 0, $orientation);
     $title = SERVICE . ' - ' . $title . ' - ' . date('Y-m-d H:i:s');
     $mpdf->SetAuthor($_SESSION['nickname']);
     $mpdf->SetCreator(SERVICE);
     $mpdf->SetTitle($title);
     $mpdf->SetDisplayMode('fullwidth');
     $mpdf->WriteHTML($css, 1);
     $mpdf->WriteHTML($html, 2);
     $filename = X4Utils_helper::unspace(str_replace(' - ', '-', $title), true);
     $mpdf->Output($filename . '.pdf', 'D');
     exit;
 }
Example #23
0
 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     $this->package('shinomontaz/l4-mpdf');
     if ($this->app['config']->get('l4-mpdf::config.pdf.enabled')) {
         $this->app['mpdf.pdf'] = $this->app->share(function ($app) {
             $base = $app['config']->get('l4-mpdf::config.pdf.base');
             $options = $app['config']->get('l4-mpdf::config.pdf.options');
             $mpdf = new \mPDF('win-1252', 'A4', '', '', 10, 10, 40, 35, 10, 5);
             $mpdf->SetProtection(array('print'));
             $mpdf->SetTitle("Acme Trading Co. - Invoice");
             $mpdf->SetAuthor("Acme Trading Co.");
             $mpdf->SetWatermarkText("Paid");
             $mpdf->showWatermarkText = false;
             $mpdf->watermark_font = 'DejaVuSansCondensed';
             $mpdf->watermarkTextAlpha = 0.1;
             $mpdf->SetDisplayMode('fullpage');
             return $mpdf;
         });
         $this->app['mpdf.wrapper'] = $this->app->share(function ($app) {
             return new PdfWrapper($app['mpdf.pdf']);
         });
     }
 }
Example #24
0
function pdf($html, $filename = null, $cabecalho = '', $rodape = '')
{
    require APPPATH . "helpers/mpdf/mpdf.php";
    $mpdf = new mPDF();
    //$mpdf->allow_charset_conversion=true;
    $mpdf->charset_in = 'utf-8';
    //Exibir a pagina inteira no browser
    $mpdf->SetDisplayMode('fullpage');
    //CabeƧalho: Seta a data/hora completa de quando o PDF foi gerado + um texto no lado direito
    if ($cabecalho !== '') {
        $mpdf->SetHeader('{DATE j/m/Y H:i}| | ' . $cabecalho);
    }
    //RodapƩ: Seta a data/hora completa de quando o PDF foi gerado + um texto no lado direito
    if ($rodape !== '') {
        $mpdf->SetFooter($rodape);
    }
    $mpdf->WriteHTML($html);
    // define um nome para o arquivo PDF
    if ($filename == null) {
        $filename = date("Y-m-d_his") . '_impressao.pdf';
    }
    $mpdf->Output($filename, 'I');
}
                $content = trim($w);
                $html .= '<indexentry content="' . $content . '" />';
            }
            $html .= $w;
        }
    } else {
        $html .= '<' . $e . '>';
    }
}
//==============================================================
//==============================================================
require_once __DIR__ . '/../vendor/autoload.php';
$mpdf = new mPDF('', 'A4', '', '', 32, 25, 27, 25, 16, 13);
$mpdf->SetDirectionality('rtl');
$mpdf->mirrorMargins = true;
$mpdf->SetDisplayMode('fullpage', 'two');
$mpdf->autoLangToFont = true;
$mpdf->defaultPageNumStyle = 'arabic-indic';
$mpdf->setHeader($h);
$mpdf->setFooter($f);
$mpdf->debug = true;
$stylesheet = file_get_contents('mpdfstyletables.css');
$mpdf->WriteHTML($stylesheet, 1);
// The parameter 1 tells that this is css/style only and no body/html/text
$mpdf->WriteHTML($html);
$mpdf->AddPage();
$mpdf->SetColumns(2, 'J');
$mpdf->WriteHTML($html);
$mpdf->SetColumns(0);
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// INDEX
Example #26
0
</ol>
</li>
</ol>
</li>
<li>Text here lorem ipsum ibisque totum.</li>
<li>Text here lorem <span style="color:red; font-size:9pt; font-family:courier; font-weight: normal; font-style: normal;">ipsum</span> ibisque totum.</li>
<li>Text here lorem ipsum ibisque totum.</li>
<li>Text here lorem ipsum ibisque totum.</li>
<li>Text here lorem ipsum ibisque totum.</li>
<li>Text here lorem ipsum ibisque totum.</li>
<li>Text here lorem ipsum ibisque totum.</li>
<li>Text here lorem ipsum ibisque totum.</li>
</ol>
</div>
';
//==============================================================
//==============================================================
//==============================================================
include "../mpdf.php";
$mpdf = new mPDF('-s');
$mpdf->SetDisplayMode('fullpage');
$mpdf->WriteHTML($html);
$mpdf->list_align_style = 'L';
// Determines alignment of numbers in numbered lists
$mpdf->list_number_suffix = ')';
$mpdf->WriteHTML($html);
$mpdf->Output();
exit;
//==============================================================
//==============================================================
//==============================================================
 public function actionExportPdf()
 {
     //$searchModel = new SecuritasSearch();
     //$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     $session = Yii::$app->session;
     $dataProvider = $session->get('dataProvider');
     $html = $this->renderPartial('_pdf', ['dataProvider' => $dataProvider]);
     //function mPDF($mode='',$format='A4',$default_font_size=0,$default_font='',$mgl=15,$mgr=15,$mgt=16,$mgb=16,$mgh=9,$mgf=9, $orientation='P') {
     $mpdf = new \mPDF('c', 'A4-L', 0, '', 15, 10, 15, 10, 10, 10);
     $header = ['L' => [], 'C' => [], 'R' => ['content' => 'Page {PAGENO} of {nbpg}', 'font-family' => 'sans', 'font-style' => '', 'font-size' => '9'], 'line' => 1];
     $mpdf->SetFooter($header, 'O');
     $mpdf->SetDisplayMode('fullpage');
     $mpdf->list_indent_first_level = 0;
     // 1 or 0 - whether to indent the first level of a list
     $mpdf->WriteHTML($html);
     $mpdf->Output($this->id . '_' . date('YmdHis') . '.pdf', 'D');
     exit;
 }
 /**
  * PDF of a test order is downloaded by this method
  */
 public function downloadpdfAction()
 {
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender(true);
     $id = $this->getRequest()->getParam('id', '');
     $email = $this->getRequest()->getParam('email', 0);
     require_once 'mpdf/mpdf.php';
     $html .= $this->view->action('viewreport', 'patient', 'patient', array('id' => $id));
     $mpdf = new mPDF('+aCJK', 'A4', '', '', 15, 15, 15, 0, 0, 0);
     $mpdf->mirrorMargins = 0;
     $mpdf->setAutoBottomMargin = 'stretch';
     $mpdf->SetDisplayMode('fullwidth');
     $mpdf->WriteHTML($html);
     $fileName = 'PDF_Form' . time() . '.pdf';
     $mpdf->Output('tmp/' . $fileName, $email ? 'F' : 'D');
     if ($email) {
         $patient = patient::getOrderById($id);
         $mail = new PHPMailer();
         $mail->From = '*****@*****.**';
         $mail->FromName = 'Lab';
         $mail->addAddress($patient[0]['email'], '');
         $mail->addAttachment('tmp/' . $fileName);
         $mail->Subject = 'Your Test Report';
         $mail->Body = 'Please find attached report';
         if (!$mail->send()) {
             echo 'Message could not be sent.';
             echo 'Mailer Error: ' . $mail->ErrorInfo;
         } else {
             unlink('tmp/' . $fileName);
             $flashMessenger = $this->_helper->getHelper('FlashMessenger');
             $flashMessenger->addMessage('mail_sent');
             $this->_redirect('/patient/orders');
         }
     }
 }
Example #29
-1
 public function _gen_pdf_ijazah_depan($html, $paper, $layoutpage)
 {
     ob_end_clean();
     //	 $mpdf=new mPDF('utf-8', $paper, '', 0, '', 15, 15, 0, 0, 9, 9);
     ini_set('memory_limit', '500000M');
     $mpdf = new mPDF('c', $paper, '', '', 15, 15, 5, 5, 0, 0);
     $mpdf->SetDisplayMode('fullpage');
     $mpdf->debug = true;
     $mpdf->AddPage($layoutpage);
     $mpdf->WriteHTML($html);
     $mpdf->Output();
 }
 /**
  * Generates the invoice with MPDF lib.
  * @param $dest
  * @return string
  */
 protected function generate($dest, $document)
 {
     set_time_limit(0);
     $mpdf_filename = BEWPI_LIB_DIR . 'mpdf/mpdf.php';
     include $mpdf_filename;
     $mpdf = new mPDF('', 'A4', 0, 'opensans', 17, 17, 150, 50, 20, 0, '');
     $mpdf->useOnlyCoreFonts = false;
     // false is default
     $mpdf->SetTitle($this->title);
     $mpdf->SetAuthor($this->author);
     $mpdf->showWatermarkText = false;
     $mpdf->SetDisplayMode('fullpage');
     $mpdf->useSubstitutions = true;
     $mpdf->SetHTMLHeader($document->header);
     $mpdf->SetHTMLFooter($document->footer);
     $mpdf->WriteHTML($document->css . $document->body);
     $mpdf->Output($document->filename, $dest);
 }