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

Langage PHP Discussion :

domPDF chargement impossible


Sujet :

Langage PHP

  1. #1
    Membre du Club
    Homme Profil pro
    Cobol sur Mainframe et Unix AIX
    Inscrit en
    Mars 2012
    Messages
    196
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Cobol sur Mainframe et Unix AIX

    Informations forums :
    Inscription : Mars 2012
    Messages : 196
    Points : 69
    Points
    69
    Par défaut domPDF chargement impossible
    Bonjour,

    J'ai migré le site de mon asso de Scaleway vers Hostinger.
    Ce qui fonctionnait chez Scaleway ne fonctionne plus chez Hostinger, mais je ne sais pas pourquoi.

    Voici un petit code qui fonctionne bien en local mais pas sur le serveur distant chez Hostinger :
    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
    <?php
    $Nom_Fichier = "_page_test.pdf";
    $html = "<table border='1' width='100%' style='border-collapse: collapse;'>
            <tr>
                <th>Username</th><th>Email</th>
            </tr>
            <tr>
                <td>yssyogesh</td>
                <td>yogesh@makitweb.com</td>
            </tr>
            <tr>
                <td>sonarika</td>
                <td>sonarika@makitweb.com</td>
            </tr>
            <tr>
                <td>vishal</td>
                <td>vishal@makitweb.com</td>
            </tr>
            </table>";
     
    // include autoloader
    require_once 'dompdf/autoload.inc.php';
     
    // reference the Dompdf namespace
    use Dompdf\Dompdf;
     
    // Instantiate and use the dompdf class
    $dompdf = new Dompdf();
    try {
        $dompdf = new Dompdf();
    }
    catch(Exception $e) {
        echo "<br>Message : " . $e->getMessage();
        echo "<br>Code : " . $e->getCode();
        echo "<br>$dompdf = new Dompdf();";
        die();
    }
     
    // Load HTML content
    $dompdf->loadHtml('<h1>Welcome to CodexWorld.com</h1>');
     
    // (Optional) Setup the paper size and orientation
    $dompdf->setPaper('A4', 'landscape');
     
    $dompdf->loadHtml($html, true);
    // Render the HTML as PDF
    try {
        $dompdf->render();
    }
    catch(Exception $e) {
        echo "<br>Message : " . $e->getMessage();
        echo "<br>Code : " . $e->getCode();
        echo "<br>$dompdf = new Dompdf();";
        die();
    }
     
    // Output the generated PDF to Browser
    //$dompdf->stream("codexworld", array("Attachment" => 0));
    try {
        $dompdf->stream($Nom_Fichier, array("Attachment" => 0));
    }
    catch(Exception $e) {
        echo "<br>Message : " . $e->getMessage();
        echo "<br>Code : " . $e->getCode();
        echo "<br>$dompdf = new Dompdf();";
        die();
    }
    echo $html;
    ?>
    Qui-je râté ?

    Auriez-vous une idée ?

    Merci,

    Eddy

  2. #2
    Membre expert
    Avatar de cavo789
    Homme Profil pro
    Développeur Web
    Inscrit en
    Mai 2004
    Messages
    1 793
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : Développeur Web

    Informations forums :
    Inscription : Mai 2004
    Messages : 1 793
    Points : 3 064
    Points
    3 064
    Par défaut
    Sans aucun message d'erreur, nous non plus...

    Donne plus d'informations svp

  3. #3
    Membre du Club
    Homme Profil pro
    Cobol sur Mainframe et Unix AIX
    Inscrit en
    Mars 2012
    Messages
    196
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Cobol sur Mainframe et Unix AIX

    Informations forums :
    Inscription : Mars 2012
    Messages : 196
    Points : 69
    Points
    69
    Par défaut
    je pense avoir une piste.
    Sur Scaleway, j'étais en version Php 7.3 alors que sur Hostinger, c'est 8.0.

    Comment afficher les erreurs, je n'ai qu'une page blanche.

    En tout cas, c'est sympa de me répondre, merci

  4. #4
    Membre expert
    Avatar de cavo789
    Homme Profil pro
    Développeur Web
    Inscrit en
    Mai 2004
    Messages
    1 793
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : Développeur Web

    Informations forums :
    Inscription : Mai 2004
    Messages : 1 793
    Points : 3 064
    Points
    3 064
    Par défaut
    Vois https://www.developpez.net/forums/d2...-ne-s-affiche/
    J'ai posté un code pour ça

  5. #5
    Membre du Club
    Homme Profil pro
    Cobol sur Mainframe et Unix AIX
    Inscrit en
    Mars 2012
    Messages
    196
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Cobol sur Mainframe et Unix AIX

    Informations forums :
    Inscription : Mars 2012
    Messages : 196
    Points : 69
    Points
    69
    Par défaut
    en passant en version 7.3, j'arrive à afficher la page PDF.
    Reste à savoir pourquoi je ne peux pas en version 8.0 : peut-être une mauvaise programmation

  6. #6
    Membre expert
    Avatar de cavo789
    Homme Profil pro
    Développeur Web
    Inscrit en
    Mai 2004
    Messages
    1 793
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : Développeur Web

    Informations forums :
    Inscription : Mai 2004
    Messages : 1 793
    Points : 3 064
    Points
    3 064
    Par défaut
    Dans ton premier message, la ligne 28 $dompdf = new Dompdf(); peut être supprimée puisque doublon avec la ligne 30 qui se trouve, elle, au bon endroit (dans le try). La ligne 35 echo "<br>$dompdf = new Dompdf();"; devrait utiliser non pas le guillement mais l'apostrophe echo '<br>$dompdf = new Dompdf();'; afin que le nom de la variable soit affichée et que PHP ne tente pas d'afficher le contenu de la variable.


    Tu as deux try ... catch ..., autant tout mettre dans le même puisque dans ton cas tu as des lignes non "catchées".


    Ligne 57 //$dompdf->stream("codexworld", array("Attachment" => 0)); peut aussi disparaître.


    Voici donc ce que pourrait devenir ton 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
    <?php
    $Nom_Fichier = "_page_test.pdf";
    $html = "<table border='1' width='100%' style='border-collapse: collapse;'>
            <tr>
                <th>Username</th><th>Email</th>
            </tr>
            <tr>
                <td>yssyogesh</td>
                <td>yogesh@makitweb.com</td>
            </tr>
            <tr>
                <td>sonarika</td>
                <td>sonarika@makitweb.com</td>
            </tr>
            <tr>
                <td>vishal</td>
                <td>vishal@makitweb.com</td>
            </tr>
            </table>";
     
    // include autoloader
    require_once 'dompdf/autoload.inc.php';
     
    // reference the Dompdf namespace
    use Dompdf\Dompdf;
     
    // Instantiate and use the dompdf class
    try {
        $dompdf = new Dompdf();
     
     
        // Load HTML content
        $dompdf->loadHtml('<h1>Welcome to CodexWorld.com</h1>');
     
        // (Optional) Setup the paper size and orientation
        $dompdf->setPaper('A4', 'landscape');
     
        $dompdf->loadHtml($html, true);
     
     
        // Render the HTML as PDF
        $dompdf->render();
     
     
        // Output the generated PDF to Browser
        $dompdf->stream($Nom_Fichier, array("Attachment" => 0));
     
     
    } catch(Exception $e) {
        echo "<br>Message : " . $e->getMessage();
        echo "<br>Code : " . $e->getCode();
        echo '<br>$dompdf = new Dompdf();';
        die();
    }
     
    echo $html;
    ?>
    Maintenant, tu peux ajouter le code que tu as récupéré pour l'affichage des erreurs si cela ne fonctionne toujours pas.

  7. #7
    Membre du Club
    Homme Profil pro
    Cobol sur Mainframe et Unix AIX
    Inscrit en
    Mars 2012
    Messages
    196
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Cobol sur Mainframe et Unix AIX

    Informations forums :
    Inscription : Mars 2012
    Messages : 196
    Points : 69
    Points
    69
    Par défaut
    ce code fonctionne en version 7.4, mais pas en version 8.0

  8. #8
    Membre expert
    Avatar de cavo789
    Homme Profil pro
    Développeur Web
    Inscrit en
    Mai 2004
    Messages
    1 793
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : Développeur Web

    Informations forums :
    Inscription : Mai 2004
    Messages : 1 793
    Points : 3 064
    Points
    3 064
    Par défaut
    Je n'ai pas affirmé le contraire 😉

    Php 8 vient avec des break changes comme par exemple des fonctions notées comme dépréciées en 7.4 et supprimées en 8.

    Maintenant je me demande si ce n'est pas le cas de cet arobase qui serait abandonné avec php 8... J'ai un doute.

    L'arobase est une infamie : "même s'il y a des erreurs, je m'en fou je veux que mon code continue". C'est une aberration. S'il y a une erreur il faut la gérer. Il me semble que php 8 a supprimé le support de cet arobase...

  9. #9
    Membre du Club
    Homme Profil pro
    Cobol sur Mainframe et Unix AIX
    Inscrit en
    Mars 2012
    Messages
    196
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Cobol sur Mainframe et Unix AIX

    Informations forums :
    Inscription : Mars 2012
    Messages : 196
    Points : 69
    Points
    69
    Par défaut
    alors que le petit bout de code fonctionne, j'ai une erreur sur celui-ci qui pourtant, il me semble qu'il est identique, tout du moins, au niveau de dompdf
    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
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    <!--
    *--------------------------------------------------------------------------------------------------*
    *                                                                                                  *
    *                                                                                                  *
    *--------------------------------------------------------------------------------------------------*
     -->
    <?php
    // Turn off error reportingerror_reporting(0);
     
     
    // Report runtime errors
    error_reporting(E_ERROR | E_WARNING | E_PARSE);
     
     
    // Report all errors
    error_reporting(E_ALL);
     
     
    // Same as error_reporting(E_ALL);
    ini_set("error_reporting", E_ALL);
     
     
    header('Content-Type: text/html; charset=utf-8');
     
    define('TARGET', 'documents/palaquees/');    // Repertoire cible
     
    $nb_N0 = 0;
    $nb_N1 = 0;
    $nb_N2 = 0;
    $nb_N3 = 0;
    $nb_N4 = 0;
    $Nb_FJP = 0;
    $Nb_Bronze = 0;
    $Nb_Argent = 0;
    $Nb_Or = 0;
     
    $idSortie = $_GET['idSortie'];
     
    require_once '../../fonctions/Connect_Base.php';
    require_once '../../fonctions/Dates.php';
    require_once '../../fonctions/fonctions_mail.php';
    require_once '../../classes/class_constantes.php';
    require_once '../../fonctions/fonctions_generales.php';
     
    $Nom_ABBR = Recup_Param("CLUB", "Nom", "Abbrégé");
    //$Nom_Long = Recup_Param("CLUB", "Nom", "Long");
     
    require_once '../../classes/class_sorties_club.php';
    $Class_Sorties_Club = new sorties_club($GLOBALS['bdd']);
     
    require_once '../../classes/class_sorties_licencies.php';
    $Class_Sorties_Licencies = new sorties_licencies($GLOBALS['bdd']);
     
    require_once '../../classes/class_licencies.php';
    $Class_Licencies = new licencies($GLOBALS['bdd']);
     
    require_once '../../classes/class_certif_med.php';
    $Class_Certif_Med = new certif_medicaux($GLOBALS['bdd']);
     
    $tab_jours = array('Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi');
    //$J_Moins_11Mois = strftime("%Y%m%d", mktime(0, 0, 0, date('m')-11, date('d'), date('Y')));
    $J_Moins_12Mois = strftime("%Y%m%d", mktime(0, 0, 0, date('m')-12, date('d'), date('Y')));
     
    $UneSortie = $Class_Sorties_Club->select($_GET['idSortie']);
     
    $tabDate = explode('-', $UneSortie['Date']);
    $timestamp = mktime(0, 0, 0, $tabDate[1], $tabDate[2], $tabDate[0]); // mois, jour , année
     
    $jour = date('w', $timestamp); // 0 : dim - 1 : lundi - 2 : mardi - ... - 6 : samedi
    //echo "<br> Timestamp : $timestamp - Jour sortie : $jour";
     
    //$Date_Sortie = $tabDate[0] . $tabDate[1] . $tabDate[2];
     
     
    // Est-ce une sortie nage ?
    // Si oui, il n'y a pas de niveau requis
    $List_Niveaux = $Class_Sorties_Club->select_niveau($idSortie);
    if (count($List_Niveaux) == 0) {
        $Est_Sortie_Nage = TRUE;
    }
    else {
        $Est_Sortie_Nage = FALSE;
    }
     
    // Liste des Participants
    /*
    if (!$Est_Sortie_Nage) {
        $ListPart = $Class_Sorties_Licencies->selectAll($_GET['idSortie']);
    }
    else {
        $ListPart = $Class_Sorties_Licencies->selectAll_Sortie_Nage($_GET['idSortie']);
    }
    */
     
    switch ($UneSortie['idType_Sortie']) {
        case 1:
            $ListPart = $Class_Sorties_Licencies->selectAll_Sortie_Plongee($_GET['idSortie']);
            break;
     
        case 2:
            $ListPart = $Class_Sorties_Licencies->selectAll_Sortie_Apnee($_GET['idSortie']);
            break;
     
        case 3:
            $ListPart = $Class_Sorties_Licencies->selectAll_Sortie_Nage($_GET['idSortie']);
            break;
     
        default:
            break;
    }
     
    $html = "<html>
    	<head>
    		<meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />
    		<title>$Nom_ABBR - Listes des participants sorties club</title>
    		<style type='text/css'>
    			.header,
    			body {
      			font-size: 65%;
    			}
    			.footer {
    			    width: 100%;
    			    text-align: center;
    			    position: fixed;
    			}
    			.header {
    			    top: 25px;
    			}
    			.footer {
    			    bottom: 0px;
    			}
    			.pagenum:before {
    			    content: counter(page);
    			}
    		</style>
    </head>
    
    	<body>
    		<center>
    		<div id='corp'>
    
    			<h2>Le " . $tab_jours[$jour] . " " . DateAffichage($UneSortie['Date'], '-') . " à* " 
    				. substr($UneSortie['Heure_Sur_Site'], 0, 2) . "h" .substr($UneSortie['Heure_Sur_Site'], 3, 2)
    		        . " à* " . $UneSortie['Nom_Site'] . " (" . $UneSortie['Nom_Pays'] . ")"
    			        . " - DP : " . $UneSortie['Prenom'] . " " . $UneSortie['Nom'] ."
    			</h2>";
     
     
     		foreach ($ListPart as $Un_Part) {
     		    $Niveau = $Class_Licencies->Niveau_Date_Donnee($Un_Part['idLicencie'], Niveau_Plongeur, $UneSortie['Date']);
     			switch ($Niveau['Libelle_Niveau_Court']) {
     				case "N0":
     					$nb_N0++;
     					;
     					break;
     				case "N1":
     					$nb_N1++;
     					;
     					break;
     				case "PE40":
     				    $nb_N1++;
     				    ;
     				    break;
     				case "N2":
     					$nb_N2++;
     					;
     					break;
     				case "PE60":
     				    $nb_N2++;
     				    ;
     				    break;
     				case "N3":
     					$nb_N3++;
     					;
     					break;
     				case "N4":
     					$nb_N4++;
     					;
     					break;
     				case "FJP":
     				    $Nb_FJP++;
     				    ;
     				    break;
     				case "JP Bronze";
     				$Nb_Bronze++;
     				;
     				break;
     				case "JP Argent";
     				$Nb_Argent++;
     				;
     				break;
     				case "JP Or";
     				$Nb_Or++;
     				;
     				break;
     
     				default:
     					;
     					break;
     			}
     		}
     
     		if (!$Est_Sortie_Nage) {
     		     $html .= "Nombre de plongeurs : " . count($ListPart) . " - ";
     		}
     		else {
     		    $html .= "Nombre de participants : " . count($ListPart) . " - Dont : ";
     		}
     		if ($Nb_FJP) {
     		    $html .= "<font color='fushia'> $Nb_FJP FJP</font>";
     		}
     		if ($Nb_Bronze) {
     		    if ($Nb_FJP > 0) $html .= " / ";
     		    $html .= "<font color='navy'> $Nb_Bronze Bronze</font>";
     		}
     		if ($Nb_Argent) {
     		    if ($Nb_FJP > 0 or $Nb_Bronze > 0) $html .= " / ";
     		    $html .= "<font color='purple'> $Nb_Argent Argent</font>";
     		}
     		if ($Nb_Or) {
     		    if (Nb_FJP > 0 or $Nb_Bronze > 0 or $Nb_Argent > 0) $html .= " / ";
     		    $html .= "<font color='olive'> $Nb_Or Or</font>";
     		}
     		if ($nb_N0) {
     		    if ($Nb_FJP > 0 or $Nb_Bronze > 0 or $Nb_Argent > 0 or $Nb_Or > 0) $html .= " / ";
     		    $html .= "<font color='black'> $nb_N0 Formation N1 </font>";
     		}
     
     		if ($nb_N1) {
     		    if ($nb_N0 > 0 or $Nb_FJP > 0 or $Nb_Bronze > 0 or $Nb_Argent > 0 or $Nb_Or > 0) $html .= " / ";
     			$html .= "<font color='green'> $nb_N1 N1</font>";
     		}
     
     		if ($nb_N2) {
     		    if ($nb_N0 > 0 or $nb_N1 > 0 or $Nb_FJP > 0 or $Nb_Bronze > 0 or $Nb_Argent > 0 or $Nb_Or > 0) $html .= " / ";
     			$html .= "<font color='blue'> $nb_N2 N2</font>";
     		}
     
     		if ($nb_N3) {
     		    if ($nb_N0 > 0 or $nb_N1 > 0or $nb_N2 > 0 or $Nb_FJP > 0 or $Nb_Bronze > 0 or $Nb_Argent > 0 or $Nb_Or > 0) $html .= " / ";
     			$html .= "<font color='grey'> $nb_N3 N3</font>";
     		}
     		if ($nb_N4) {
     		    if ($nb_N0 > 0 or $nb_N1 > 0 or $nb_N2 > 0 or $nb_N3 > 0 or $Nb_FJP > 0 or $Nb_Bronze > 0 or $Nb_Argent > 0 or $Nb_Or > 0) $html .= " / ";
     			$html .= "<font color='Brown'> $nb_N4 N4</font>";
     		}
     
     
    				$html .= "<table border='1' align='center' CELLPADDING='5' CELLSPACING='0'>
    				<tr>
    				<th> Nom </th>
    				<th> Niveaux <br>acquis </th>
    				<th> Qualification  </th>
    				<th> Personnes à contacter </th>
    				<th> Date dernière plongée <br><small><i>si HC : Hors Club</i></small> </th>
    				<th> Date et heure <br> d'inscription </th>
    				<th> Remarques </th>
    				</tr>";
     
    $i=0;
    foreach ($ListPart as $Un_Part) {
        $i++;
     
        $Certif_Med = $Class_Certif_Med->select_by_idLicencie($Un_Part['idLicencie']);
        $tabDate = explode('-', $Certif_Med['Date_Certif_Medical']);
        $Date_Certif = $tabDate[0] . $tabDate[1] . $tabDate[2];
     
        $Niveau = $Class_Licencies->Niveau_Date_Donnee($Un_Part['idLicencie'], Niveau_Plongeur, $UneSortie['Date']);
        $color = $Niveau['Code_Couleur_Feuille_Palanquee'];
     
     
        $html .= "<tr  bgcolor='$color' align='center'>";
     
        if (getAge(DateAffichage($Un_Part['Date_Naissance'], '-')) < 18 or $Date_Certif < $J_Moins_12Mois) {
            echo "<font color='red'>";
        }
     
     
        $html .= "<td>" . $Un_Part['Prenom'] . " " . $Un_Part['Nom'] . "<br>" . $Un_Part['Telephone'] . "</td>";
        $html .= "<td align='center'>" . $Niveau['Libelle_Niveau_Court'] ;
     
        $Niveau = $Class_Licencies->Niveau_Date_Donnee($Un_Part['idLicencie'], Niveau_Plongeur_Encadrant, $UneSortie['Date']);
        if (isset($Niveau['idNiveau'])){
            $html .= " (" . $Niveau['Libelle_Niveau_Court']. ")";
        }
     
        // Est-ce que la personne est en formation ?
        $Req = "select * from scf_licencies_formation_2 a, scf_code_formation b
    			where a.idSaison    = " . $UneSortie['idSaison'] . "
    			  and a.idLicencie  = " . $Un_Part['idLicencie'] . "
                  and a.idFormation = b.idFormation
                  and a.A_Abandonne is null
                  and b.idType_Formation = 1";
     
        try {
            $dbh = $GLOBALS['bdd']->query($Req);
            $Formation = $dbh->fetch();
        }
        catch (PDOException $e) {
            echo "<h4><br>La requete est : ".$Req;
            die('<br><strong>Erreur : ' . $e->getMessage()) . "</strong></h4>";
        }
     
        if (isset($Formation['idLicencie'])) {
            // Au moment de la plongée, etait-elle déjà validée ?
            if ($Formation['Date_Fin'] >= $UneSortie['Date'] or $Formation['Date_Fin'] == "") {
                $html .= "<br><font color='red'><small><small><small><i>Formation : " . $Formation['Libelle_Abbrege'] . "</i></small></small></small></font>" ; //print_r($Formation);
            }
        }
     
        // 03.10.2021- Pour un encadrant, est-ce le type d'encadrement qu'il fera pour cette plongée ?
        $Type_Encadrement = $Class_Sorties_Licencies->Select_Un_code_encadrer_plongee($Un_Part['idEncadrer_Plongee']);
        if (isset($Type_Encadrement[0])) {
            $html .= "<br><font color='brown'>" . $Type_Encadrement['Lib_Encadrer_Plongee'] . "</font>";
        }
     
     
        $html .= "</td>";
        $html .= "<td align='center'>";
     
        if (!$Est_Sortie_Nage) {
            $Niveau = $Class_Licencies->Niveau_Date_Donnee($Un_Part['idLicencie'], Niveau_Nitrox, $UneSortie['Date']);
            if (isset($Niveau['idNiveau'])) {
                $html .= $Niveau['Libelle_Niveau_Long'];
            }
            $Niveau = $Class_Licencies->Niveau_Date_Donnee($Un_Part['idLicencie'], Niveau_Trimix, $UneSortie['Date']);
            if (isset($Niveau['idNiveau']))
                $html .= "<br>" . $Niveau['Libelle_Niveau_Long'];
        }
     
     
        $html .= "</td>";
        $html .= "<td>" . $Un_Part['Pers_Contact_si_accident'] . "<br>" . $Un_Part['Tel_Pers_Contact_si_accident'];
        if ($Un_Part['Pers_Contact_2_si_accident'] != "") {
            $html .= "<br>" . $Un_Part['Pers_Contact_2_si_accident'] . "<br>" . $Un_Part['Tel_Pers_Contact_2_si_accident'];
        }
        $html .= "</td>";
        $html .= "<td>";
     
                // Récupération de la date de dernière plongée en club
                $Date_Dern_Plongee = $Class_Sorties_Licencies->Date_Dern_Plongee($Un_Part['idLicencie']);
     
                if ($Un_Part['Date_Dern_Sortie_Hors_Club'] == "") {
                    $Date_Dern_Plongee_Hors_Club = 0;
                }
                else {
                    $tabDate = explode('-', $Un_Part['Date_Dern_Sortie_Hors_Club']);
                    $Date_Dern_Plongee_Hors_Club = $tabDate[0] . $tabDate[1] . $tabDate[2];
                }
     
                if ($Date_Dern_Plongee['Date'] == "") {
                    $Date_Dern_Plongee_Club = 0;
                }
                else {
                    $tabDate = explode('-', $Date_Dern_Plongee['Date']);
                    $Date_Dern_Plongee_Club = $tabDate[0] . $tabDate[1] . $tabDate[2];
                }
     
                if ($Date_Dern_Plongee_Club > $Date_Dern_Plongee_Hors_Club) {
                    if ($Date_Dern_Plongee_Club > 0)
                        $html .= DateAffichage($Date_Dern_Plongee['Date'], '-');
                }
                else {
                    if ($Date_Dern_Plongee_Hors_Club > 0) {
                        $html .= DateAffichage($Un_Part['Date_Dern_Sortie_Hors_Club'], "-") . "<font color='red'> (HC) </font>";
                    }
                }
     
     
                //if ($Niveau['Libelle_Niveau_Court'] <= 'N2' or $Niveau['Libelle_Niveau_Court'] == 'PE40' or $Niveau['Libelle_Niveau_Court'] == 'PE60') {
                // Nombre de plongées club avant cette sortie
                $Req = "select * from scf_sorties a, scf_sorties_licencies b
                    					  where a.idSortie = b.idSortie and b.idLicencie = " . $Un_Part['idLicencie'] . " and a.Date < '" . $UneSortie['Date'] . "'";
                try {
                    $dbh = $GLOBALS['bdd']->query($Req);
                    $Nb_Plongees_Club = $dbh->fetchAll();
                }
                catch (PDOException $e) {
                    echo "<h4><br>La requete est : ".$Req;
                    die('<br><strong>Erreur : ' . $e->getMessage()) . "</strong></h4>";
                }
     
                $html .= "<br><font color='brown'><i><small>Nb plongées club : " . count($Nb_Plongees_Club) . "</small></i></font>";
                //}
     
        $html .= "</td>";
        $html .= "<td>" . DateAffichage($Un_Part['Date_Cre'], '-') . "<br> à " . substr($Un_Part['Heure_Cre'], 10, 6);
        $html .= "</td>";
     
        $html .= "<td>";
     
        if (getAge(DateAffichage($Un_Part['Date_Naissance'], '-')) < 18) {
            $html .= " <font color='red'>MINEUR</font>";
        }
     
        if ($Date_Certif < $J_Moins_12Mois) {
            $html .= " <font color='red'> Certificat Médical périmé : " . DateAffichage($Certif_Med['Date_Certif_Medical'], '-'). "</font>";
        }
     
        if ($Certif_Med['idValideur'] == ""){
            $html .= "<br><font color='red'>Le certificat médical n'est pas encore validé</font>";
        }
     
        if ($Un_Part['Recup_Matos_Club']) {
            $html .= "<font color='grey'><small><small><small><br>Passera à la piscine prendre du matos</small></small></small></font>";
        }
        $html .= "</td>";
    	$html .= "</tr>";
    }
     
    $html .= "  
    </table>
    </center>
    
    		</div>
    	</body>
    </html>";
    close_connection();
     
    //$Nom_Serveur = Recup_Adresse_Serveur();
    $Nom_Fichier = TARGET . "Fiche_Palanquee_$idSortie.pdf";
     
    // include autoloader
    require_once 'dompdf/autoload.inc.php';
     
    // reference the Dompdf namespace
    use Dompdf\Dompdf;
     
    // Instantiate and use the dompdf class
    try {
        $dompdf = new Dompdf();
     
     
        // Load HTML content
        $dompdf->loadHtml($html, true);
     
        // (Optional) Setup the paper size and orientation
        $dompdf->setPaper('A4', 'landscape');
     
     
        // Render the HTML as PDF
        $dompdf->render();
     
     
        // Output the generated PDF to Browser
        $dompdf->stream($Nom_Fichier, array("Attachment" => 0));
     
     
    } catch(Exception $e) {
        echo '<br>Erreur à la ligne ', $e->getLine(), ' dans le fichier ', $e->getFile(), '. <br>Une exception a été lancée : ', $e->getMessage();
        echo "<br>Code : " . $e->getCode();
        die();
    }
     
     
    echo $html;
    ?>
    j'ai cette erreur :
    Erreur à la ligne 48 dans le fichier /home/u230373234/domains/scf.asso.fr/public_html/core/pages/dompdf/src/Positioner/Inline.php.
    Une exception a été lancée : No block-level parent found. Not good.

  10. #10
    Membre averti Avatar de ddaweb
    Homme Profil pro
    Webmaster amateur
    Inscrit en
    Janvier 2013
    Messages
    329
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : Webmaster amateur
    Secteur : Associations - ONG

    Informations forums :
    Inscription : Janvier 2013
    Messages : 329
    Points : 429
    Points
    429
    Par défaut
    Citation Envoyé par cavo789 Voir le message
    Php 8 vient avec des break changes comme par exemple des fonctions notées comme dépréciées en 7.4 et supprimées en 8.
    @ Eddoul :

    Pour passer à une nouvelle version de PHP et que cela ne fonctionne plus, j'active les erreurs sur mon serveur local et souvent on peut trouver des pistes
    Si Dompdf utilise des fonctions supprimées dans PHP 8, normal que cela ne fonctionne plus !!
    Je suis passé sur leur site, il ne parle que de 7.1 ou plus ... il est donc possible que PHP 8 n'est pas encore implémenté.

    Pour te donner un exemple avec mpdf (dernière version compatible PHP 8.1) et la différence entre PHP 7.4 et PHP 8.1 afin que cela fonctionne :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    $mpdf->Output('fichier.pdf',D); //----- PHP 7.4 et on ne voit pas l'emplacement du fichier car se trouve dans les temp en pdf sous le nom que j'ai mit
    $mpdf->Output();   // ----- PHP 8.1, mais emplacement de la page visible dans la barre de navigation, le pdf s'ouvre dans la page du code
    Je reste donc pour l'instant en PHP 7.4 vu que je ne veux pas que l'emplacement soit visible ... mais je vais potasser leur manuel ou le D semble toujours présent pour PHP 8 (D=download)

  11. #11
    Membre averti Avatar de ddaweb
    Homme Profil pro
    Webmaster amateur
    Inscrit en
    Janvier 2013
    Messages
    329
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations professionnelles :
    Activité : Webmaster amateur
    Secteur : Associations - ONG

    Informations forums :
    Inscription : Janvier 2013
    Messages : 329
    Points : 429
    Points
    429
    Par défaut
    Je viens d'un peu potasser le manuel et cela ne tient pas à pas grand chose pour que cela fonctionne aussi bien en PHP 7.4 qu'en 8.1 : une histoire de guillemets
    J'ai probablement fait l'erreur pour le 7.4, mais que le 8.1 ne l'accepte plus ... juste pour te montrer qu'il y a des différences de comportement entre les versions PHP

    Code universel dans mon cas:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    $mpdf->Output('fichier.pdf',"D");

Discussions similaires

  1. Création DLL Visual Studio 2008 : Chargement impossible
    Par Bleys dans le forum Visual Studio
    Réponses: 0
    Dernier message: 07/08/2008, 11h03
  2. Chargement impossible derrière un routeur NAT
    Par langevert dans le forum Apache
    Réponses: 6
    Dernier message: 05/05/2008, 17h47
  3. Réponses: 6
    Dernier message: 23/04/2008, 10h15
  4. [Oracle] PHP 5.2 et Oracle 10g : chargement impossible de l'extension oci8
    Par Nounoursonne dans le forum PHP & Base de données
    Réponses: 3
    Dernier message: 25/01/2007, 14h01
  5. [DOM XML] Chargement impossible du fichier XML
    Par lietof dans le forum Bibliothèques et frameworks
    Réponses: 5
    Dernier message: 03/05/2006, 10h37

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