コード例 #1
25
ファイル: PdfHandler.php プロジェクト: thytanium/chameleon
 /**
  * Handle handler
  *
  * @return void
  */
 public function handle()
 {
     $dompdf = new Dompdf();
     $dompdf->loadHtml($this->input);
     $dompdf->setPaper('letter');
     $dompdf->render();
     //Page numbers
     $font = $dompdf->getFontMetrics()->getFont("Arial", "bold");
     $dompdf->getCanvas()->page_text(16, 770, "Page: {PAGE_NUM} of {PAGE_COUNT}", $font, 8, array(0, 0, 0));
     echo $dompdf->output();
 }
コード例 #2
1
 function render(Frame $frame)
 {
     if (!$this->_dompdf->get_option("enable_javascript")) {
         return;
     }
     $this->insert($frame->get_node()->nodeValue);
 }
コード例 #3
1
 /**
  * Register the service provider.
  *
  * @throws \Exception
  * @return void
  */
 public function register()
 {
     $configPath = __DIR__ . '/../config/dompdf.php';
     $this->mergeConfigFrom($configPath, 'dompdf');
     $this->app->bind('dompdf.options', function () {
         $defines = $this->app['config']->get('dompdf.defines');
         if ($defines) {
             $options = [];
             foreach ($defines as $key => $value) {
                 $key = strtolower(str_replace('DOMPDF_', '', $key));
                 $options[$key] = $value;
             }
         } else {
             $options = $this->app['config']->get('dompdf.options');
         }
         return $options;
     });
     $this->app->bind('dompdf', function () {
         $options = $this->app->make('dompdf.options');
         $dompdf = new Dompdf($options);
         $dompdf->setBasePath(realpath(base_path('public')));
         return $dompdf;
     });
     $this->app->alias('dompdf', Dompdf::class);
     $this->app->bind('dompdf.wrapper', function ($app) {
         return new PDF($app['dompdf'], $app['config'], $app['files'], $app['view']);
     });
 }
コード例 #4
1
 /**
  * Register the service provider.
  *
  * @throws \Exception
  * @return void
  */
 public function register()
 {
     $configPath = __DIR__ . '/../config/dompdf.php';
     $this->mergeConfigFrom($configPath, 'dompdf');
     $this->app->bind('dompdf', function ($app) {
         $dompdf = new Dompdf();
         $dompdf->setBasePath(realpath(base_path('public')));
         return $dompdf;
     });
     $this->app->alias('dompdf', 'DOMPDF');
     $this->app->bind('dompdf.wrapper', function ($app) {
         return new PDF($app['dompdf'], $app['config'], $app['files'], $app['view']);
     });
 }
コード例 #5
1
 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;
 }
コード例 #6
1
ファイル: CPDF.php プロジェクト: BrunoDeBarros/dompdf
 function get_font_baseline($font, $size)
 {
     $ratio = $this->_dompdf->getOptions()->getFontHeightRatio();
     return $this->get_font_height($font, $size) / $ratio;
 }
コード例 #7
1
ファイル: AbstractRenderer.php プロジェクト: onyxnz/quartzpos
 /**
  * Render a background image over a rectangular area
  *
  * @param string $url   The background image to load
  * @param float $x      The left edge of the rectangular area
  * @param float $y      The top edge of the rectangular area
  * @param float $width  The width of the rectangular area
  * @param float $height The height of the rectangular area
  * @param Style $style  The associated Style object
  *
  * @throws \Exception
  */
 protected function _background_image($url, $x, $y, $width, $height, $style)
 {
     if (!function_exists("imagecreatetruecolor")) {
         throw new \Exception("The PHP GD extension is required, but is not installed.");
     }
     $sheet = $style->get_stylesheet();
     // Skip degenerate cases
     if ($width == 0 || $height == 0) {
         return;
     }
     $box_width = $width;
     $box_height = $height;
     //debugpng
     if ($this->_dompdf->get_option("debugPng")) {
         print '[_background_image ' . $url . ']';
     }
     list($img, $type, ) = Cache::resolve_url($url, $sheet->get_protocol(), $sheet->get_host(), $sheet->get_base_path(), $this->_dompdf);
     // Bail if the image is no good
     if (Cache::is_broken($img)) {
         return;
     }
     //Try to optimize away reading and composing of same background multiple times
     //Postponing read with imagecreatefrom   ...()
     //final composition parameters and name not known yet
     //Therefore read dimension directly from file, instead of creating gd object first.
     //$img_w = imagesx($src); $img_h = imagesy($src);
     list($img_w, $img_h) = Helpers::dompdf_getimagesize($img);
     if (!isset($img_w) || $img_w == 0 || !isset($img_h) || $img_h == 0) {
         return;
     }
     $repeat = $style->background_repeat;
     $dpi = $this->_dompdf->get_option("dpi");
     //Increase background resolution and dependent box size according to image resolution to be placed in
     //Then image can be copied in without resize
     $bg_width = round((double) ($width * $dpi) / 72);
     $bg_height = round((double) ($height * $dpi) / 72);
     //Need %bg_x, $bg_y as background pos, where img starts, converted to pixel
     list($bg_x, $bg_y) = $style->background_position;
     if (Helpers::is_percent($bg_x)) {
         // The point $bg_x % from the left edge of the image is placed
         // $bg_x % from the left edge of the background rectangle
         $p = (double) $bg_x / 100.0;
         $x1 = $p * $img_w;
         $x2 = $p * $bg_width;
         $bg_x = $x2 - $x1;
     } else {
         $bg_x = (double) ($style->length_in_pt($bg_x) * $dpi) / 72;
     }
     $bg_x = round($bg_x + $style->length_in_pt($style->border_left_width) * $dpi / 72);
     if (Helpers::is_percent($bg_y)) {
         // The point $bg_y % from the left edge of the image is placed
         // $bg_y % from the left edge of the background rectangle
         $p = (double) $bg_y / 100.0;
         $y1 = $p * $img_h;
         $y2 = $p * $bg_height;
         $bg_y = $y2 - $y1;
     } else {
         $bg_y = (double) ($style->length_in_pt($bg_y) * $dpi) / 72;
     }
     $bg_y = round($bg_y + $style->length_in_pt($style->border_top_width) * $dpi / 72);
     //clip background to the image area on partial repeat. Nothing to do if img off area
     //On repeat, normalize start position to the tile at immediate left/top or 0/0 of area
     //On no repeat with positive offset: move size/start to have offset==0
     //Handle x/y Dimensions separately
     if ($repeat !== "repeat" && $repeat !== "repeat-x") {
         //No repeat x
         if ($bg_x < 0) {
             $bg_width = $img_w + $bg_x;
         } else {
             $x += $bg_x * 72 / $dpi;
             $bg_width = $bg_width - $bg_x;
             if ($bg_width > $img_w) {
                 $bg_width = $img_w;
             }
             $bg_x = 0;
         }
         if ($bg_width <= 0) {
             return;
         }
         $width = (double) ($bg_width * 72) / $dpi;
     } else {
         //repeat x
         if ($bg_x < 0) {
             $bg_x = -(-$bg_x % $img_w);
         } else {
             $bg_x = $bg_x % $img_w;
             if ($bg_x > 0) {
                 $bg_x -= $img_w;
             }
         }
     }
     if ($repeat !== "repeat" && $repeat !== "repeat-y") {
         //no repeat y
         if ($bg_y < 0) {
             $bg_height = $img_h + $bg_y;
         } else {
             $y += $bg_y * 72 / $dpi;
             $bg_height = $bg_height - $bg_y;
             if ($bg_height > $img_h) {
                 $bg_height = $img_h;
             }
             $bg_y = 0;
         }
         if ($bg_height <= 0) {
             return;
         }
         $height = (double) ($bg_height * 72) / $dpi;
     } else {
         //repeat y
         if ($bg_y < 0) {
             $bg_y = -(-$bg_y % $img_h);
         } else {
             $bg_y = $bg_y % $img_h;
             if ($bg_y > 0) {
                 $bg_y -= $img_h;
             }
         }
     }
     //Optimization, if repeat has no effect
     if ($repeat === "repeat" && $bg_y <= 0 && $img_h + $bg_y >= $bg_height) {
         $repeat = "repeat-x";
     }
     if ($repeat === "repeat" && $bg_x <= 0 && $img_w + $bg_x >= $bg_width) {
         $repeat = "repeat-y";
     }
     if ($repeat === "repeat-x" && $bg_x <= 0 && $img_w + $bg_x >= $bg_width || $repeat === "repeat-y" && $bg_y <= 0 && $img_h + $bg_y >= $bg_height) {
         $repeat = "no-repeat";
     }
     //Use filename as indicator only
     //different names for different variants to have different copies in the pdf
     //This is not dependent of background color of box! .'_'.(is_array($bg_color) ? $bg_color["hex"] : $bg_color)
     //Note: Here, bg_* are the start values, not end values after going through the tile loops!
     $filedummy = $img;
     $is_png = false;
     $filedummy .= '_' . $bg_width . '_' . $bg_height . '_' . $bg_x . '_' . $bg_y . '_' . $repeat;
     //Optimization to avoid multiple times rendering the same image.
     //If check functions are existing and identical image already cached,
     //then skip creation of duplicate, because it is not needed by addImagePng
     if ($this->_canvas instanceof CPDF && $this->_canvas->get_cpdf()->image_iscached($filedummy)) {
         $bg = null;
     } else {
         // Create a new image to fit over the background rectangle
         $bg = imagecreatetruecolor($bg_width, $bg_height);
         switch (strtolower($type)) {
             case "png":
                 $is_png = true;
                 imagesavealpha($bg, true);
                 imagealphablending($bg, false);
                 $src = imagecreatefrompng($img);
                 break;
             case "jpeg":
                 $src = imagecreatefromjpeg($img);
                 break;
             case "gif":
                 $src = imagecreatefromgif($img);
                 break;
             case "bmp":
                 $src = Helpers::imagecreatefrombmp($img);
                 break;
             default:
                 return;
                 // Unsupported image type
         }
         if ($src == null) {
             return;
         }
         //Background color if box is not relevant here
         //Non transparent image: box clipped to real size. Background non relevant.
         //Transparent image: The image controls the transparency and lets shine through whatever background.
         //However on transparent image preset the composed image with the transparency color,
         //to keep the transparency when copying over the non transparent parts of the tiles.
         $ti = imagecolortransparent($src);
         if ($ti >= 0) {
             $tc = imagecolorsforindex($src, $ti);
             $ti = imagecolorallocate($bg, $tc['red'], $tc['green'], $tc['blue']);
             imagefill($bg, 0, 0, $ti);
             imagecolortransparent($bg, $ti);
         }
         //This has only an effect for the non repeatable dimension.
         //compute start of src and dest coordinates of the single copy
         if ($bg_x < 0) {
             $dst_x = 0;
             $src_x = -$bg_x;
         } else {
             $src_x = 0;
             $dst_x = $bg_x;
         }
         if ($bg_y < 0) {
             $dst_y = 0;
             $src_y = -$bg_y;
         } else {
             $src_y = 0;
             $dst_y = $bg_y;
         }
         //For historical reasons exchange meanings of variables:
         //start_* will be the start values, while bg_* will be the temporary start values in the loops
         $start_x = $bg_x;
         $start_y = $bg_y;
         // Copy regions from the source image to the background
         if ($repeat === "no-repeat") {
             // Simply place the image on the background
             imagecopy($bg, $src, $dst_x, $dst_y, $src_x, $src_y, $img_w, $img_h);
         } else {
             if ($repeat === "repeat-x") {
                 for ($bg_x = $start_x; $bg_x < $bg_width; $bg_x += $img_w) {
                     if ($bg_x < 0) {
                         $dst_x = 0;
                         $src_x = -$bg_x;
                         $w = $img_w + $bg_x;
                     } else {
                         $dst_x = $bg_x;
                         $src_x = 0;
                         $w = $img_w;
                     }
                     imagecopy($bg, $src, $dst_x, $dst_y, $src_x, $src_y, $w, $img_h);
                 }
             } else {
                 if ($repeat === "repeat-y") {
                     for ($bg_y = $start_y; $bg_y < $bg_height; $bg_y += $img_h) {
                         if ($bg_y < 0) {
                             $dst_y = 0;
                             $src_y = -$bg_y;
                             $h = $img_h + $bg_y;
                         } else {
                             $dst_y = $bg_y;
                             $src_y = 0;
                             $h = $img_h;
                         }
                         imagecopy($bg, $src, $dst_x, $dst_y, $src_x, $src_y, $img_w, $h);
                     }
                 } else {
                     if ($repeat === "repeat") {
                         for ($bg_y = $start_y; $bg_y < $bg_height; $bg_y += $img_h) {
                             for ($bg_x = $start_x; $bg_x < $bg_width; $bg_x += $img_w) {
                                 if ($bg_x < 0) {
                                     $dst_x = 0;
                                     $src_x = -$bg_x;
                                     $w = $img_w + $bg_x;
                                 } else {
                                     $dst_x = $bg_x;
                                     $src_x = 0;
                                     $w = $img_w;
                                 }
                                 if ($bg_y < 0) {
                                     $dst_y = 0;
                                     $src_y = -$bg_y;
                                     $h = $img_h + $bg_y;
                                 } else {
                                     $dst_y = $bg_y;
                                     $src_y = 0;
                                     $h = $img_h;
                                 }
                                 imagecopy($bg, $src, $dst_x, $dst_y, $src_x, $src_y, $w, $h);
                             }
                         }
                     } else {
                         print 'Unknown repeat!';
                     }
                 }
             }
         }
         imagedestroy($src);
     }
     /* End optimize away creation of duplicates */
     $this->_canvas->clipping_rectangle($x, $y, $box_width, $box_height);
     //img: image url string
     //img_w, img_h: original image size in px
     //width, height: box size in pt
     //bg_width, bg_height: box size in px
     //x, y: left/top edge of box on page in pt
     //start_x, start_y: placement of image relative to pattern
     //$repeat: repeat mode
     //$bg: GD object of result image
     //$src: GD object of original image
     //When using cpdf and optimization to direct png creation from gd object is available,
     //don't create temp file, but place gd object directly into the pdf
     if (!$is_png && $this->_canvas instanceof CPDF) {
         // Note: CPDF_Adapter image converts y position
         $this->_canvas->get_cpdf()->addImagePng($filedummy, $x, $this->_canvas->get_height() - $y - $height, $width, $height, $bg);
     } else {
         $tmp_dir = $this->_dompdf->get_option("temp_dir");
         $tmp_name = tempnam($tmp_dir, "bg_dompdf_img_");
         @unlink($tmp_name);
         $tmp_file = "{$tmp_name}.png";
         //debugpng
         if ($this->_dompdf->get_option("debugPng")) {
             print '[_background_image ' . $tmp_file . ']';
         }
         imagepng($bg, $tmp_file);
         $this->_canvas->image($tmp_file, $x, $y, $width, $height);
         imagedestroy($bg);
         //debugpng
         if ($this->_dompdf->get_option("debugPng")) {
             print '[_background_image unlink ' . $tmp_file . ']';
         }
         if (!$this->_dompdf->get_option("debugKeepTemp")) {
             unlink($tmp_file);
         }
     }
     $this->_canvas->clipping_end();
 }
コード例 #8
0
 function render(Frame $frame)
 {
     if (!$this->_dompdf->getOptions()->getIsJavascriptEnabled()) {
         return;
     }
     $this->insert($frame->get_node()->nodeValue);
 }
コード例 #9
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();
 }
コード例 #10
0
 public function testRender()
 {
     $dompdf = new Dompdf();
     $dompdf->loadHtml('<strong>Hello</strong>');
     $dompdf->render();
     $dom = $dompdf->getDom();
     $this->assertEquals('', $dom->textContent);
 }
コード例 #11
0
ファイル: PDFLib.php プロジェクト: onyxnz/quartzpos
 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 ($this->_dompdf->get_option("debugPng")) {
             print '[pdflib output unlink ' . $this->_file . ']';
         }
         if (!$this->_dompdf->get_option("debugKeepTemp")) {
             unlink($this->_file);
         }
         $this->_file = null;
         unset($this->_file);
     }
     return $data;
 }
コード例 #12
0
 /**
  * Get a fresh dompdf instance
  *
  * @param  array $options
  * @return Dompdf The dompdf instance
  */
 protected function makeDompdf(array $options)
 {
     $dompdf = new Dompdf();
     $options = $options + $this->options;
     if (isset($options['paper'])) {
         $paper = $options['paper'];
     } else {
         $paper = 'a4';
     }
     if (isset($options['orientation'])) {
         $orientation = $options['orientation'];
     } else {
         $orientation = 'portrait';
     }
     $dompdf->setPaper($paper, $orientation);
     return $dompdf;
 }
コード例 #13
0
ファイル: Pdf.php プロジェクト: 0svald/icingaweb2
 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()));
 }
コード例 #14
0
ファイル: Cache.php プロジェクト: AlexandreSGV/siteentec
 /**
  * Unlink all cached images (i.e. temporary images either downloaded
  * or converted)
  */
 static function clear()
 {
     if (empty(self::$_cache) || self::$_dompdf->get_option("debugKeepTemp")) {
         return;
     }
     foreach (self::$_cache as $file) {
         if (self::$_dompdf->get_option("debugPng")) {
             print "[clear unlink {$file}]";
         }
         unlink($file);
     }
     self::$_cache = array();
 }
コード例 #15
0
ファイル: Stylesheet.php プロジェクト: BrunoDeBarros/dompdf
 /**
  * parse selector + rulesets
  *
  * @param string $str CSS selectors and rulesets
  */
 private function _parse_sections($str)
 {
     // Pre-process: collapse all whitespace and strip whitespace around '>',
     // '.', ':', '+', '#'
     $patterns = array("/[\\s\n]+/", "/\\s+([>.:+#])\\s+/");
     $replacements = array(" ", "\\1");
     $str = preg_replace($patterns, $replacements, $str);
     $DEBUGCSS = $this->_dompdf->getOptions()->getDebugCss();
     $sections = explode("}", $str);
     if ($DEBUGCSS) {
         print '[_parse_sections';
     }
     foreach ($sections as $sect) {
         $i = mb_strpos($sect, "{");
         $selectors = explode(",", mb_substr($sect, 0, $i));
         if ($DEBUGCSS) {
             print '[section';
         }
         $style = $this->_parse_properties(trim(mb_substr($sect, $i + 1)));
         // Assign it to the selected elements
         foreach ($selectors as $selector) {
             $selector = trim($selector);
             if ($selector == "") {
                 if ($DEBUGCSS) {
                     print '#empty#';
                 }
                 continue;
             }
             if ($DEBUGCSS) {
                 print '#' . $selector . '#';
             }
             //if ($DEBUGCSS) { if (strpos($selector,'p') !== false) print '!!!p!!!#'; }
             $this->add_style($selector, $style);
         }
         if ($DEBUGCSS) {
             print 'section]';
         }
     }
     if ($DEBUGCSS) {
         print '_parse_sections]';
     }
 }
コード例 #16
0
ファイル: PDF.php プロジェクト: barryvdh/laravel-dompdf
 /**
  * Render the PDF
  */
 protected function render()
 {
     if (!$this->dompdf) {
         throw new Exception('DOMPDF not created yet');
     }
     $this->dompdf->setPaper($this->paper, $this->orientation);
     $this->dompdf->render();
     if ($this->showWarnings) {
         global $_dompdf_warnings;
         if (count($_dompdf_warnings)) {
             $warnings = '';
             foreach ($_dompdf_warnings as $msg) {
                 $warnings .= $msg . "\n";
             }
             // $warnings .= $this->dompdf->get_canvas()->get_cpdf()->messages;
             if (!empty($warnings)) {
                 throw new Exception($warnings);
             }
         }
     }
     $this->rendered = true;
 }
コード例 #17
0
 $date = date('F d, Y', $row['datetime']);
 /*$name = 'Tran Hieu Nhan';
 	$course = 'PMP® Exam Preparation';
 	$img_signature1 = '<img src="../public/mauBang/sign1.png" />';
 	$logo_signature1 = '<img src="../public/mauBang/logo1.png" />';
 	$name_signature1 = 'Nguyen Binh Phuong, MBA, PMP®';
 	$position_signature1 = 'Instructor';
 	$img_signature2 = '<img src="../public/mauBang/sign2.png" />';
 	$logo_signature2 = '<img src="../public/mauBang/logo2.png" />';
 	$name_signature2 = 'Nguyen Huu Song Phuong';
 	$position_signature2 = 'President and Chief Executive Officer';
 	$pdu = '30';
 	$code = '3AJA789';
 	$date = date('F d, Y');*/
 //instantiate and use the dompdf class
 $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);
コード例 #18
0
ファイル: gerarPDF.php プロジェクト: amorimlima/Hospital
<?php

// include autoloader
require_once 'dompdf/autoload.inc.php';
if (!isset($_SESSION['PATH_SYS'])) {
    require_once '_loadPaths.inc.php';
}
$path = $_SESSION['PATH_SYS'];
include_once $path['controller'] . 'EnvioDocumentoController.php';
$envioDocumentoControler = new EnvioDocumentoController();
// reference the Dompdf namespace
use Dompdf\Dompdf;
// instantiate and use the dompdf class
$dompdf = new Dompdf();
$param = $_SERVER['QUERY_STRING'];
$host = $_SERVER["HTTP_HOST"];
$opts = array("http" => array("method" => "POST", "header" => "Content-type: application/x-www-form-urlencoded\r\n" . "Content-Length: " . strlen($param) . "\r\n", "content" => $param));
$context = stream_context_create($opts);
$folder = substr($_SERVER["HTTP_HOST"], 0, 5) == "local" ? "Hospital/" : "";
$file = file_get_contents("http://{$host}/{$folder}pesquisa_pdf.php", false, $context);
$dompdf->load_html($file);
// (Optional) Setup the paper size and orientation
$dompdf->setPaper('A4', 'portrait');
// Render the HTML as PDF
$dompdf->render();
$arquivo = $dompdf->output("arquivo.pdf", array("Attachment" => true));
$rand = rand(1, 500);
$rand2 = rand(1, 500);
$nomeCrip = md5("arquivo" . $rand . $rand2);
if ($arquivo) {
    file_put_contents($path['arquivos'] . $nomeCrip . '.pdf', $arquivo);
コード例 #19
0
ファイル: index.php プロジェクト: hbarudin/gtg-form-maker
<?php

// include autoloaders and helper functions
require_once 'dompdf/src/functions.inc.php';
require_once 'dompdf/src/autoload.inc.php';
// reference the Dompdf namespace
use Dompdf\Dompdf;
// instantiate and use the dompdf class
$dompdf = new Dompdf();
$dompdf->loadHtml('<h1>Hello world!</h1>');
// (Optional) Setup the paper size and orientation
//$dompdf->setPaper('A4', 'landscape');
// Render the HTML as PDF
$dompdf->render();
// Get the generated PDF file contents
$pdf = $dompdf->output();
// Output the generated PDF to Browser
$dompdf->stream();
コード例 #20
0
 $date = date('F d, Y', $row['datetime']);
 /*$name = 'Tran Hieu Nhan';
 	$course = 'PMP® Exam Preparation';
 	$img_signature1 = '<img src="../public/mauBang/sign1.png" />';
 	$logo_signature1 = '<img src="../public/mauBang/logo1.png" />';
 	$name_signature1 = 'Nguyen Binh Phuong, MBA, PMP®';
 	$position_signature1 = 'Instructor';
 	$img_signature2 = '<img src="../public/mauBang/sign2.png" />';
 	$logo_signature2 = '<img src="../public/mauBang/logo2.png" />';
 	$name_signature2 = 'Nguyen Huu Song Phuong';
 	$position_signature2 = 'President and Chief Executive Officer';
 	$pdu = '30';
 	$code = '3AJA789';
 	$date = date('F d, Y');*/
 //instantiate and use the dompdf class
 $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);
コード例 #21
0
ファイル: DomPdfEngine.php プロジェクト: ceeram/cakepdf
 /**
  * Generates the PDF output.
  *
  * @param Dompdf $DomPDF The Dompdf instance from which to generate the output from.
  * @return string
  */
 protected function _output($DomPDF)
 {
     return $DomPDF->output();
 }
コード例 #22
0
     $escolaJSON = new EscolaJSON();
     $escolaJSON->setEsj_escola($_SESSION['idEscolaPre']);
     $escolaJSON->setEsj_string($query);
     try {
         $idesj = $escolaJSONController->insertAndReturnId($escolaJSON);
         echo json_encode(["status" => 1, "retorno" => "Registro salvo com sucesso.", "idesj" => $idesj]);
     } catch (Exception $e) {
         echo json_encode(["status" => 0, "retorno" => "Erro ao inserir arquivo: {$e->getMessage()}"]);
     }
     break;
 case "getAquivoPdf":
     $envioDocumentoControler = new EnvioDocumentoController();
     $escolaJSONController = new EscolaJSONController();
     if ($_GET["idesc"]) {
         if (function_exists("curl_init")) {
             $dompdf = new Dompdf();
             $host = $_SERVER["HTTP_HOST"];
             $folder = $_SERVER["HTTP_HOST"] == "187.73.149.26:8080" ? "" : "Hospital/";
             //$url = "http://{$host}/{$folder}pesquisa_pdf.php?idesc=".$_GET["idesc"];
             $url = gerarPDF();
             // Carrega o conteúdo da página
             $dompdf->load_html($url);
             // Define o tamanho da página para A4 e orientação para retrato
             $dompdf->setPaper('A4', 'portrait');
             // Gera a visualização do arquivo
             $dompdf->render();
             // Exporta o arquivo
             $arquivo = $dompdf->output("arquivo.pdf", ["Attachment" => true]);
             // Gera um nome criptografado para o arquivo
             $rand = rand(1, 500);
             $rand2 = rand(1, 500);
コード例 #23
0
ファイル: generate.php プロジェクト: Jpastran/diagramas
<?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;
コード例 #24
0
ファイル: Send.php プロジェクト: fvas-elearning/plg-coa
    /**
     * Background image Size: 1343x929 (Aspect ratio: 1.45:1)
     * 
     * 
     * @param \stdClass $obj
     * @param string $dateFrom
     * @param string $dateTo
     * @param string $bgImage
     * @param string $tpl
     * @param string $paperSize
     * @param string $paperOrientation
     * @return Dompdf
     */
    protected function makeCert($obj, $dateFrom = '', $dateTo = '', $bgImage = '', $tpl = '', $paperSize = 'A4', $paperOrientation = 'landscape')
    {
        $now = \Tk\Date::create();
        if (!$dateFrom) {
            $dateFrom = \Tk\Date::create($now->getYear() . '-01-01')->floor()->toString(\Tk\Date::LONG_DATE);
        }
        if (!$dateTo) {
            $dateTo = \Tk\Date::create($now->getYear() . '-12-31')->ceil()->toString(\Tk\Date::LONG_DATE);
        }
        if (!$bgImage) {
            $bgImage = \Tk\Url::create('/data/pdfTestBg.png')->toString();
        }
        if (!$tpl) {
            $tpl = '<div class="content">
  <p class="med">Certificate of Appreciation</p>
  <p class="med">The Faculty of Veterinary Science gratefully acknowledges the support of</p>
  <p class="lg bld">{name}</p>
  <p class="med">for mentoring and training veterinary students from</p>
  <p class="med">The University of Melbourne</p>
  <p class="med">{dateFrom} - {dateTo}</p>
</div>';
        }
        // Format content template
        $tpl = str_replace('{name}', $obj->name, $tpl);
        $tpl = str_replace('{date}', $now->format(\Tk\Date::LONG_DATE), $tpl);
        $tpl = str_replace('{dateFrom}', $dateFrom, $tpl);
        $tpl = str_replace('{dateTo}', $dateTo, $tpl);
        $tpl = str_replace('{year}', $now->toString('Y'), $tpl);
        $tpl = str_replace('{totalUnits}', $obj->totalUnits, $tpl);
        $tpl = str_replace('{totalPlaces}', $obj->totalPlaces, $tpl);
        $html = <<<ENDHTML
<html>
<head>
  <title>Test HTML2PDF</title>
  <style>
@page { margin: 0px; }
body {
  font-family: sans-serif;
  font-size: 10pt;
  margin: 0px;
}
div.cert {
  width: 1122px;
  position: absolute;
  top: 0;
  left: 0;
}
div.cert img {
  width: 100%;
}
div.content {
  position: absolute;
  top: {$this->setup->pdfTopMargin}px;
  left: 0;
  line-height: 1.2em;
  text-align: center;
}
.lg {
  font-size: 20pt;
}
.med {
  font-size: 16pt;
}
.sml {
  font-size: 8pt
}
.bld {
  font-weight: bold;
}
  </style>
</head>
<body>
  <div class="cert">
    <img src="{$bgImage}" alt="" />
  </div>
  {$tpl}
</body>
</html>
ENDHTML;
        set_time_limit(300);
        ini_set('memory_limit', '-1');
        $dompdf = new Dompdf(array('enable_remote' => true));
        $dompdf->setPaper($paperSize, $paperOrientation);
        $dompdf->loadHtml($html);
        $dompdf->render();
        return $dompdf;
    }
コード例 #25
0
ファイル: order.pdf.php プロジェクト: samnabi/shopkit
<?php

// Set detected language
site()->visit('home', $lang);
site()->kirby->localize();
// Page URI sent via POST
$p = page(get('uri'));
// Load dompdf
require kirby()->roots()->plugins() . '/dompdf/autoload.inc.php';
// reference the Dompdf namespace
use Dompdf\Dompdf;
// instantiate the dompdf class
$dompdf = new Dompdf();
// Build the HTML
$html = '<style>body{font-family: sans-serif;}</style>';
$html .= '<h1>' . site()->title() . '</h1>';
$contact = page('contact');
if ($address = $contact->location()->toStructure()->address() and $address != '') {
    $html .= $address->kirbytext();
} else {
    if ($contact->location()->isNotEmpty()) {
        $html .= $contact->location()->kirbytext();
    }
}
if ($phone = $contact->phone() and $phone != '') {
    $html .= '<p>' . $phone . '</p>';
}
if ($email = $contact->email() and $email != '') {
    $html .= '<p>' . $email . '</p>';
}
$html .= '<hr>';
コード例 #26
0
ファイル: chargeback.php プロジェクト: pcqcuong/Report.cu.cc
<?php

$OrderNo = $_POST['inputOrderNo'];
$html = $_POST['submitContent'];
$chargebackFolder = '../../public/chargebacks';
$workingFolder = $chargebackFolder . '/' . $OrderNo;
if (!file_exists($workingFolder)) {
    mkdir($workingFolder, 0777, true);
}
// include autoloader
require_once '../../php/plugins/dompdf/autoload.inc.php';
// reference the Dompdf namespace
use Dompdf\Dompdf;
// instantiate and use the dompdf class
$dompdf = new Dompdf();
$dompdf->loadHtml($html);
// (Optional) Setup the paper size and orientation
$dompdf->setPaper('A4', 'portrait');
// Render the HTML as PDF
$dompdf->render();
$Letter1 = '1_Letter_' . $OrderNo . '.pdf';
file_put_contents($workingFolder . '/' . $Letter1, $dompdf->output());
// Output the generated PDF to Browser
//$dompdf->stream();
$Invoice2 = '';
//inputFileInvoice
if (isset($_FILES['inputFileInvoice']) && $_FILES['inputFileInvoice']['error'] == UPLOAD_ERR_OK) {
    $info = pathinfo($_FILES['inputFileInvoice']['name']);
    $ext = $info['extension'];
    // get the extension of the file
    $newname = '2_Invoice_' . $OrderNo . '.' . $ext;
コード例 #27
0
ファイル: GD.php プロジェクト: hesselek/printed_module
 function get_font_baseline($font, $size)
 {
     $ratio = $this->_dompdf->get_option("font_height_ratio");
     return $this->get_font_height($font, $size) / $ratio;
 }
コード例 #28
0
ファイル: Mailer2.php プロジェクト: sirromas/medical
 function create_registration_data_details($user)
 {
     $dompdf = new Dompdf();
     $message = $this->get_account_confirmation_message($user, true);
     $dompdf->loadHtml($message);
     $dompdf->setPaper('A4', 'portrait');
     $dompdf->render();
     $output = $dompdf->output();
     $file_path = $this->registration_path . "/{$user->email}.pdf";
     file_put_contents($file_path, $output);
 }
コード例 #29
-1
ファイル: Invoice.php プロジェクト: rained23/laravel-billing
 /**
  * Capture the invoice as a PDF and return the raw bytes.
  *
  * @param  array  $data
  * @return string
  */
 public function pdf(array $data = array())
 {
     if (!defined('DOMPDF_ENABLE_AUTOLOAD')) {
         define('DOMPDF_ENABLE_AUTOLOAD', false);
     }
     //  if (file_exists($configPath = base_path().'/vendor/dompdf/dompdf/dompdf_config.inc.php')) {
     // 		 require_once $configPath;
     //  }
     $options = new Options();
     $options->set('isRemoteEnabled', true);
     $dompdf = new Dompdf($options);
     $dompdf->loadHtml($this->view($data)->render());
     $dompdf->render();
     return $dompdf->output();
 }
コード例 #30
-2
 public function printTest()
 {
     $dompdf = new Dompdf();
     $dompdf->loadHtml('Hello world');
     $dompdf->setPaper('A4', 'Landscape');
     $dompdf->render();
     $dompdf->stream();
 }