[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/se3master/var/www/se3/html2pdf/examples/ -> exemple09.php (source)

   1  <?php
   2  /**
   3   * HTML2PDF Librairy - example
   4   *
   5   * HTML => PDF convertor
   6   * distributed under the LGPL License
   7   *
   8   * @author      Laurent MINGUET <webmaster@html2pdf.fr>
   9   *
  10   */
  11  
  12  $generate = isset($_GET['make_pdf']);
  13  $nom = isset($_GET['nom']) ? $_GET['nom'] : 'inconnu';
  14  
  15  $nom = substr(preg_replace('/[^a-zA-Z0-9]/isU', '', $nom), 0, 26);
  16  
  17  if ($generate) {
  18      ob_start();
  19  } else {
  20  ?>
  21  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  22  <html>
  23      <head>
  24          <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" >
  25          <title>Exemple d'auto génération de PDF</title>
  26      </head>
  27      <body>
  28  <?php
  29  }
  30  
  31  $url = dirname($_SERVER['REQUEST_URI']).'/res/exemple09.png.php?px=5&amp;py=20';
  32  if (substr($url, 0, 7)!=='http://') {
  33      $url = 'http://'.$_SERVER['HTTP_HOST'].$url;
  34  }
  35  ?>
  36  <br>
  37  Ceci est un exemple de génération de PDF via un bouton :)<br>
  38  <br>
  39  <img src="<?php echo $url; ?>" alt="image_php" ><br>
  40  <br>
  41  <?php
  42      if ($generate) {
  43  ?>
  44  Bonjour <b><?php echo $nom; ?></b>, ton nom peut s'écrire : <br>
  45  <barcode type="C39" value="<?php echo strtoupper($nom); ?>" style="color: #770000" ></barcode><hr>
  46  <br>
  47  <?php
  48      }
  49  ?>
  50  <br>
  51  <?php
  52      if ($generate) {
  53          $content = ob_get_clean();
  54          require_once(dirname(__FILE__).'/../html2pdf.class.php');
  55          try
  56          {
  57              $html2pdf = new HTML2PDF('P', 'A4', 'fr');
  58              $html2pdf->writeHTML($content);
  59              $html2pdf->Output('exemple09.pdf');
  60              exit;
  61          }
  62          catch(HTML2PDF_exception $e) {
  63              echo $e;
  64              exit;
  65          }
  66      }
  67  ?>
  68          <form method="get" action="">
  69              <input type="hidden" name="make_pdf" value="">
  70              Ton nom : <input type="text" name="nom" value=""> -
  71              <input type="submit" value="Generer le PDF" >
  72          </form>
  73      </body>
  74  </html>


Generated: Tue Mar 17 22:47:18 2015 Cross-referenced by PHPXref 0.7.1