wkhtmltopdf, 0.12.6, Warning: Blocked access to file

When upgrade wkhtmltopdf to 0.12.6 , it came to such messages and the image did not show in the target pdf:

 Warning: Blocked access to file /path/to/bpa_product_layering.png 
BTW, the same source html file works well with 0.12.5 asked Jun 11, 2020 at 0:31 user5671078 user5671078

8 Answers 8

This is caused by the change of default behavior in version 0.12.6 of wkhtmltopdf . wkhtmltopdf disables local file access by default now. It could be solved by adding the command line parameter

--enable-local-file-access 

or the combination

--disable-local-file-access --allow
47k 23 23 gold badges 255 255 silver badges 248 248 bronze badges answered Jun 11, 2020 at 0:31 user5671078 user5671078 please add an example..how can i add command line parameter? i am using phthon Commented Jul 9, 2020 at 11:24

@sanjay, I ran into the same issue with Python, you can pass in options in the form of a dictionary. In this case, you could use the option "disable-local-file-access":"" .

Commented Jul 13, 2020 at 20:59 when you get this, when using pandoc then use pandoc --pdf-engine-opt=--enable-local-file-access Commented Sep 1, 2021 at 13:55 i have same problem in symfphony any idea how to finx it ? snapy pdf library Commented Sep 5, 2021 at 13:08 Just using --allow works for me on version 0.12.6. Commented Mar 16, 2022 at 12:53

For those that are using laravel-snappy, add the 'enable-local-file-access' option in the config\snappy.php:

'pdf' => [ 'enabled' => true, 'binary' => env('WKHTML_PDF_BINARY', '/usr/local/bin/wkhtmltopdf'), 'timeout' => false, 'options' => [ 'enable-local-file-access' => true, 'orientation' => 'landscape', 'encoding' => 'UTF-8' ], 'env' => [], ], 'image' => [ 'enabled' => true, 'binary' => env('WKHTML_IMG_BINARY', '/usr/local/bin/wkhtmltoimage'), 'timeout' => false, 'options' => [ 'enable-local-file-access' => true, 'orientation' => 'landscape', 'encoding' => 'UTF-8' ], 'env' => [], ], 

wkhtmltopdf disables local file access by default in the 0.12.6 version