IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

PHP & Base de données Discussion :

Génération PDF via HTML2PDF


Sujet :

PHP & Base de données

  1. #1
    Membre averti
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Août 2020
    Messages
    16
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 29
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Transports

    Informations forums :
    Inscription : Août 2020
    Messages : 16
    Par défaut Génération PDF via HTML2PDF
    bonjour j'ai un problème quand je genere le pdf , j'ai des erreur :
    NOTICE: UNDEFINED OFFSET: 6
    CANNOT MODIY HEADER INFORMATION : HEADERS ALREADY SENT
    j'arrive vraiment pas à résoudre le problème merci d'avance
    voilà mon code:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    <?php ob_start(); ?><link rel="icon" href="https://www.didaetoileservice.ma/wp-content/uploads/2020/01/LogoDidaSite.png" />
    <link href="https://fonts.googleapis.com/css?family=Poppins:300,400,500,600,700,800,900" rel="stylesheet">
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
    <link rel="stylesheet" href="../css/style2.css" media="screen">
    <link media="print" href="../css/print.css"  type="text/css" rel="stylesheet" />
        <body><?php
     
     
    require_once '../helpers' . DIRECTORY_SEPARATOR . 'requires.php';
     
     
       $id_inventaire=$_GET['id'];
    $query= "select date,nom_site,ecart,inventaire.id_inventaire,unite,detail_inventaire.valeur,produits.id_produit,produits.designation,det_quantite,site.nom_site,prix from detail_inventaire INNER join inventaire on detail_inventaire.id_inventaire=inventaire.id_inventaire inner join produits on detail_inventaire.id_produit=produits.Id_produit INNER join site on detail_inventaire.id_site=site.id_site where detail_inventaire.id_inventaire='$id_inventaire' ";
            $rslt= mysqli_query($conn, $query);
            $rslta= mysqli_num_rows($rslt);
            $row= mysqli_fetch_array($rslt);
              $site=$row['nom_site'];
              $datee=$row['date'];
             ?>
     
            <div>
     
                <br><table border='1'  style="text-align: center; border: 1px solid #000000; border-collapse: collapse; ">
    <tbody>
    <tr >
        <td style="width: 30%; height: 1px; border: 2px solid #000000; " colspan="1" rowspan="4" nowrap="nowrap"><img src="../img/fr.png"></td>
    <td style="width: 30%; height: 1px; border: 2px solid #000000; " colspan="1" rowspan="2" nowrap="nowrap">Enregistrement</td>
    <td style="width: 30%; border: 2px solid #000000; " colspan="2" rowspan="1" nowrap="nowrap">EN-S03-03</td>
    </tr>
    <tr>
    <td style="width: 30%; border: 2px solid #000000; " colspan="2" rowspan="1" nowrap="nowrap">Version: 01</td>
    </tr>
    <tr>
        <td style="width: 30%; height: 1px; border: 2px solid #000000;" colspan="1" rowspan="2" >Inventaire <b></b></td>
        <td style="width: 30%; border: 2px solid #000000; " colspan="2" rowspan="1" nowrap="nowrap" >Date d'application : 01/10/2019</td>
    </tr>
     
    </tbody>
    </table>
        </div>
            <div>
                <br><br><br>
                <label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Le : <?php echo date('d/m/Y'); ?></label>
                <br><br>
                <label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Site : <?php echo $site; ?></label>
            </div>
     
       <?php
     
    $id_inventaire = $_GET['id'];
    $queryo= "Select type,produits.Id_produit from quantite join produits on produits.Id_produit=quantite.Id_produit   group by type order by Id_produit ";
                 $rslto= mysqli_query($conn, $queryo);
    $tot=0;
     $total=0;
    $query = "select ecart,inventaire.id_inventaire,unite,detail_inventaire.valeur,produits.id_produit,produits.designation,det_quantite,site.nom_site,prix from detail_inventaire INNER join inventaire on detail_inventaire.id_inventaire=inventaire.id_inventaire inner join produits on detail_inventaire.id_produit=produits.Id_produit INNER join site on detail_inventaire.id_site=site.id_site where detail_inventaire.id_inventaire='$id_inventaire' ";
           $rslt = mysqli_query($conn, $query);
    $row = mysqli_num_rows($rslt);
    if ($row > 0) {
        ?><br><br><br><br><br><table id='customers' border='1' align=center  style=" width: 100%" >
                <thead ><tr ><th>Id produit</th><th>designation</th><th>quantité</th><th>Unité</th><th>Prix</th><th>Valeur</th></tr></thead>
            <?php
             while ($rowz= mysqli_fetch_array($rslto)){
                $type=$rowz['type'];
                 $queryy= "Select categorie,produits.Id_produit from quantite join produits on produits.Id_produit=quantite.Id_produit where produits.type= '$type' group by categorie order by Id_produit ";
                 $rslty= mysqli_query($conn, $queryy);
                ?>
                     <tr>
                    <td colspan=7 style="text-align:center; "><u><?php print $type ?></u></td></tr>
               <?php 
           while ($rows= mysqli_fetch_array($rslty)){
           $cat=$rows['categorie']?>
                  <tr>
                    <td colspan=7 style="text-align:center; "><u><?php print $cat ?></u></td></tr>
     <?php
            $tot = 0;
            while ($row = mysqli_fetch_array($rslt)) {
                $site = $row['nom_site'];
                $valeur = $row['det_quantite'] * $row['prix'];
                echo"<tr><td style=' width: 16%'>{$row['id_produit']}</td><td style=' width: 16%'>{$row['designation']}</td><td style=' width: 16%'>{$row['det_quantite']}</td><td style=' width: 16%'>{$row['unite']}</td><td style=' width: 16%'>{$row['prix']} DH</td><td style=' width: 16%'>$valeur dh</td></tr>\n";
     
                $tot = $tot + $valeur;
    }
       echo "<tr><TD>TOTAL</TD><TD>&nbsp;</TD><TD>&nbsp;</TD><TD>&nbsp;</TD><TD>&nbsp;</TD>
    <TD> $tot dh</TD></tr>";
           }}    
      echo"</table>";  
     
            }
            else{
            echo 'error';}?>
     
            <div class="visa" style="position:absolute;
        bottom:10px;
        right:10px;">
            <h3>Visa Gérant : </h3></div>
        </body>
    <?php 
     
     use Spipu\Html2Pdf\Html2Pdf;
     
     
     
     
     
        require_once(dirname(__FILE__) . '/../pdf/vendor/autoload.php');
     
     
     
        $content = ob_get_clean();
     
     
        $html2pdf = new HTML2PDF('P', 'A4', 'fr', true, 'UTF-8');
        $html2pdf->setDefaultFont('Helvetica');
        $html2pdf->pdf->SetDisplayMode('fullpage');
    $html2pdf->WriteHTML($content);
    ob_end_clean();
     $html2pdf->Output(__DIR__ . "/inv_pdf/inventaire-$site-$datee.pdf", 'FI');

  2. #2
    Membre éprouvé
    Homme Profil pro
    Webmaster - Développeur/intégrateur web
    Inscrit en
    Septembre 2011
    Messages
    210
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France, Jura (Franche Comté)

    Informations professionnelles :
    Activité : Webmaster - Développeur/intégrateur web
    Secteur : Conseil

    Informations forums :
    Inscription : Septembre 2011
    Messages : 210
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    CANNOT MODIY HEADER INFORMATION : HEADERS ALREADY SENT
    Cette erreur est courante, elle intervient lorsque l'on tente d'envoyer une en-tête HTTP déjà envoyée.

    Je n'ai pas épluché ton code... mais je pense que tu peux déjà commencer par regarder si aucun contenu n'est envoyé au navigateur avant l'affichage forcé de ton PDF.

    Il y a plus de détails sur cette page : https://php.developpez.com/faq/?page=correction_erreurs , au niveau du paragraphe "Explications et correction de l'erreur "headers already sent".

Discussions similaires

  1. Réponses: 6
    Dernier message: 05/12/2016, 10h39
  2. problème génération PDF avec HTML2PDF
    Par int59 dans le forum Bibliothèques et frameworks
    Réponses: 0
    Dernier message: 12/06/2015, 11h38
  3. Problème de génération PDF via JAVA
    Par sa_38 dans le forum Jasper
    Réponses: 4
    Dernier message: 16/11/2009, 10h39

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo