📜 ⬆️ ⬇️

Nginx Recipes: Convert from HTML to PDF

To prepare the conversion from HTML to PDF, we need nginx itself and its wkhtmltopdf plugin. (I gave links to my nginx fork, because I made some changes that I couldn’t get into the original repository yet. You can also use a ready-made way .)

To convert HTML to PDF
location =/wkhtmltopdf { wkhtmltopdf_global_settings orientation Landscape; #    wkhtmltopdf_object_settings page "data:text/html,<!DOCTYPE html><html><head><meta http-equiv=\"Content-Type\" content=\"text/html;charset=UTF-8\"/></head><body><p style=\"background-color: #c11\">, !</p></body></html>"; #  PDF  HTML wkhtmltopdf_convert; #   } 

To convert URL to PDF
 location =/wkhtmltopdf { wkhtmltopdf_global_settings orientation Landscape; #    wkhtmltopdf_object_settings page "ya.ru"; #  PDF  URL wkhtmltopdf_convert; #   } 

')

Source: https://habr.com/ru/post/458982/


All Articles