Search code examples
dockerdompdf

dompdf inside docker container: file_put_contents(x/x) failed to open stream: No such file or directory


I'm running a php app inside docker container and when printing a document I get this error:

file_put_contents(/var/www/html/vendor/dompdf/dompdf/lib/fonts/fonts\aefcc7f4826ca47c6196f471bf48339a.ufm.php): failed to open stream: No such file or directory

After checking I found that the path is indeed wrong and the right path is:

/var/www/html/vendor/dompdf/dompdf/lib/fonts/aefcc7f4826ca47c6196f471bf48339a.ufm.php

and not sure why it adds the extra /fonts !!
when I was running this app on wamp it was working fine, why it's not the case inside a docker container ?!


Solution

  • ok I found the solution and I'm gonna leave it here in case someone may face this issue.

    the problem is in the /lib/dompdf_font_family_cache.php where we need to change backslash \ to forward slash / and this was fixed in the latest version of dompdf (I'm using 0.8.2 and the last version is 0.8.5)

    so all we need to do is ti upgrade to the latest version composer require dompdf/dompdf:^0.8.5