DOMPDF open Bootstrap content lying down and recognize CSS

Asked

Viewed 531 times

3

I am using DOMPDF with the content with Bootstrap. For this, I did so:

 <?php
    ...
    use Dompdf\Dompdf;
    use Dompdf\Options;
    require_once("dompdf/autoload.inc.php");
    $options = new Options();
    $options->set('isRemoteEnabled', TRUE);
    $dompdf = new DOMPDF($options);
    $dompdf->load_html('
    <!DOCTYPE html>
        <html lang="pt-br">
        <head>
                <meta charset="UTF-8">
                <!-- Bootstrap CSS -->
                <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
                <title>Carteira Digital</title>
        </head>
        <body>
        <div class="container-fluid">
                <div class="row">
                        <div class="col">
                             <div class="row" style="background-color: #0C4160; border-bottom: 10px #FEC236 solid;">
                                 Conteúdo
                             </div>
                       </div>
            </div>
');
    $dompdf->setPaper('A4', 'landscape');
    $dompdf->render();

The problem is that the content keeps leaving standing and the background-color: #0C4160; is not being recognized.

  • Before instantiating DOMPDF place $options->set('defaultPaperOrientation' , 'landscape'); and $options->set('defaultPaperSize' , 'A4');. Paper settings should be done before loading content.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.