Beispiel #1
0
 /**
  * Load a HTML string
  *
  * @param string $string
  * @param string $encoding Not used yet
  * @return static
  */
 public function loadHTML($string, $encoding = null)
 {
     $string = $this->convertEntities($string);
     $this->dompdf->load_html($string, $encoding);
     $this->rendered = false;
     return $this;
 }
 /**
  * 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();
 }
Beispiel #3
0
<?php

require_once 'dompdf/autoload.inc.php';
// reference the Dompdf namespace
use Dompdf\Dompdf;
// instantiate and use the dompdf class
$dompdf = new Dompdf();
$html = '<html>
            <head>
                <link rel="stylesheet" href="../assets/css/print.css" type="text/css" />
            </head>
            <body>' . $_POST['Html'] . '</body>
        </html>';
$dompdf->load_html($html);
// (Optional) Setup the paper size and orientation
$dompdf->set_paper('A4', 'landscape');
// Render the HTML as PDF
$dompdf->render();
// Output the generated PDF to Browser
$dompdf->stream("Diagrama");
exit;
Beispiel #4
0
     } 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);
             $nomeCrip = md5("arquivo" . $rand . $rand2);
             if ($arquivo) {
                 file_put_contents($path['arquivos'] . $nomeCrip . '.pdf', $arquivo);
                 $env = new EnvioDocumento();
                 $env->setEnv_idEscola($_GET['idesc']);
                 $env->setEnv_idRemetente(1);
Beispiel #5
0
    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);
    $env = new EnvioDocumento();
    $env->setEnv_idEscola($_SESSION['idEscolaPre']);
    $env->setEnv_idRemetente(1);
    $env->setEnv_idDestinatario(4);
    $env->setEnv_url($nomeCrip . '.pdf');