amici-infotech/craft-super-pdf

("is_readable(): open_basedir restriction in effect. (missing installed-fonts.json)

Closed this issue · 2 comments

Hi, we are having an issue with generating a pdf on our site.
So this works fine locally and also on our development site. Once we copied the site to a new location which will be the live site we get the following error:
An exception has been thrown during the rendering of a template ("is_readable(): open_basedir restriction in effect. File(/installed-fonts.json) is not within the allowed path(s): (/var/www/vhosts/sitename.nl/:/tmp/)").

The pdf does not use custom fonts atm either. Now we do have a super-pdf folder in storage but this ones empty. (Also locally and on development) is this where. the installed-fonts.json is supposed to be?

craft: 4.4.9
super-pdf: 2.0.2.3

Thanks in advance!

So default temporary storage path is seems to set as /tmp folder of root. You can change that from your
config/super-pdf.php file

<?php 
return [
    'fontDir' => "/tmp",
    'tempDir' => "/tmp"
];

to

<?php 
return [
    'fontDir' => dirname(__DIR__) . '/storage/super-pdf/tmp',
    'tempDir' => dirname(__DIR__) . '/storage/super-pdf/tmp',
];

or when you are creating pdf, you can change settings to override below variables:

{% set settings = {
    filename: "My_PDF",
    fontDir: "/tmp",
    tempDir: "/tmp"
} %}

to

{% set settings = {
    filename: "My_PDF",
    fontDir: alias("@storage") ~ "/super-pdf/tmp",
    tempDir: alias("@storage") ~ "/super-pdf/tmp",
} %}

Ah it confused me a bit since it worked on the other enviroments. But that fixed it thanks!