PDF - Image not found or type unknown

Hi, I am new in October CMS and I need help :slight_smile: I am use version 3.7.5 of October and Renatio.DynamicPDF 7.1.2.

The background image is not displayed in the created pdf. The image is in the public folder. I have probably tried everything. Can anyone help me? THNX!

In controller:

PDF::loadTemplate(‘jch.wallet::pdf.qr_multi’, [‘number’ => $number,‘cislo’ => $cislo, ‘img’ => $imgPath])->setDpi(300)->setIsRemoteEnabled(true)->setIsPhpEnabled(true)
->save(storage_path(‘app/resources/pdf/qr-’.$wallet->id. ‘-’ . $cislo . ‘.pdf’));

In template:

   <style type="text/css" media="screen">

        html{
            margin-left:0;
            margin-right:0;
            margin-top:121px;
        }


        .vizitka{
            width:9cm;
            height: 5cm;
            display: inline-block;
            background-image: url("{{ img }}");
            background-size: cover;
            position: relative;
        }

        .qr{
            position: absolute;
            top:2.4cm;
            left: 6.35cm;
            width:2.2cm;
            height:2.2cm;
        }

        .vizitka:nth-of-type(odd) {
        }





    </style>


<div id="container"><div class="vizitka">
        <img src="{{ number.getPath() }}" class="qr" />
        

    </div>
....

As far as I know, DomPDF should support CSS background images, and I think most of the time problems are caused by a wrong relative path. What is the output of {{ img }} in your CSS?

Looking at the plugin, it says:

To display background image added in layout use following code:

<body style="background: url({{ background_img }}) top left no-repeat;">
1 Like

Hi, thnx - my output is full url

Unfortunately it is not woking :frowning:

Docs also say:

For retrieving stylesheets or images via http following PHP setting must be enabled allow_url_fopen.

When allow_url_fopen is disabled on server try to use relative path. You can use October getLocalPath function on the file object to retrieve it.

→ can you check that? or use a relative path?