0

I'm trying to use dompdf, and even though my script generates a pdf document, the style tag doesn't work, here is my code. I understand how it works and already succesfully used it with only html, but it's the first time I use css and it doesn't work.

    require_once 'dompdf/autoload.inc.php';
?>
<?php

$nom=$_GET['nom'];
$prenom=$_GET['prenom'];
$email=$_GET['email'];
$numeroCommande=$_GET['numerocommande'];
$commandeTotal=$_GET['commandeTotal'];?>
<?php ob_start();?>
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>

    <title>Title</title>
</head>
<body>
<div class='invoice-box'>
        <table cellpadding='0' cellspacing='0'>
            <tr class='top'>
                <td colspan='2'>
                    <table>
                        <tr>
                            <td class='title'>
                                <img src='https://www.hollandbikes.com/img/holland-bikes-logo-1493142780.jpg' style='width:100%; max-width:300px;'>
                            </td>

                            <td>
                                Facture N°: <?php echo $numeroCommande ?> <br>
                                Date: January 1, 2015<br>

                            </td>
                        </tr>
                    </table>
                </td>
            </tr>

            <tr class='information'>
                <td colspan='2'>
                    <table>
                        <tr>
                            <td>
                                Holland Bikes<br>
                                24 rue Firmin Gillot<br>
                                75015 Paris
                            </td>

                            <td>
                                <br>
                                <?php echo $prenom.' '.$nom ?><br>
                                <?php echo $email ?>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>

            <tr class='heading'>
                <td>
                    Méthode de paiement
                </td>

                <td>
                    Carte Bleue
                </td>
            </tr>


            <tr class='total'>
                <td></td>

                <td>
                   Total: <?php echo $commandeTotal ?>€
                </td>
            </tr>
        </table>
    </div>
</body>
</html>
<?php
$html = ob_get_clean();?>

<?php 

require_once 'dompdf/autoload.inc.php';
?>
<?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', 'landscape');

// Render the HTML as PDF
$dompdf->render();

// Output the generated PDF to Browser
$dompdf->stream(); ?>

Do you have any idea why this tag isn't working? It's supposed to accept basic css, that's why I don't understand where the problem is.

JohnDickinson
  • 97
  • 1
  • 3
  • 11
  • Which version of dompdf you are using. Possibly duplicate of this. https://stackoverflow.com/questions/18008637/css-not-working-with-dompdf – pspatel May 22 '18 at 12:31
  • Possible duplicate of [CSS not working with DOMPDF](https://stackoverflow.com/questions/18008637/css-not-working-with-dompdf) – Adrian W May 22 '18 at 12:50
  • Iread the thread and it doesn't answer my question. I'm using the latest version of dompdf and I'm really blocked. – JohnDickinson May 22 '18 at 13:04
  • Apparently, when I add css as a style attribute directly in html, it works, but the non working of the css is really weird. Do you have an explanation? – JohnDickinson May 22 '18 at 13:41

1 Answers1

0

Apparently, the line-height was not supported, I deleted it and it worked perfectly fine.

JohnDickinson
  • 97
  • 1
  • 3
  • 11