📅  最后修改于: 2023-12-03 15:05:58.454000             🧑  作者: Mango
wkhtmltopdf enable-local-file-access
- Shell-Bashwkhtmltopdf
is a command-line tool that converts HTML pages into PDF documents. It is widely used to generate PDFs from web pages, but it can also convert local HTML files on your computer. By default, wkhtmltopdf
does not allow access to local files due to security concerns. However, you can enable local file access by using the enable-local-file-access
option.
To use wkhtmltopdf
, you need to install it on your computer. Visit the official website of wkhtmltopdf
to download the package for your operating system. Once you have downloaded the package, extract it and add the wkhtmltopdf
executable to your system path.
The enable-local-file-access
option allows wkhtmltopdf
to access local files. This option is disabled by default to prevent malicious scripts from accessing files on your computer. You can enable local file access by adding the --enable-local-file-access
option to your wkhtmltopdf
command:
wkhtmltopdf --enable-local-file-access /path/to/local/file.html output.pdf
You can also enable local file access by setting the WKHTMLTOPDF_CMD_OPTIONS
environment variable:
export WKHTMLTOPDF_CMD_OPTIONS="--enable-local-file-access"
wkhtmltopdf /path/to/local/file.html output.pdf
Note that enabling local file access can be dangerous if you're not careful. Always make sure to only open files that you trust.
wkhtmltopdf
is a powerful tool for converting HTML pages into PDF documents. By enabling local file access, you can also use it to convert local HTML files on your computer. However, you should be careful when enabling this option to prevent malicious scripts from accessing your files.