To prepare the conversion from HTML to PDF, we need ourselves
To convert HTML to PDF from a file
location =/html_to_pdf_from_file {
html2pdf on; # Π²ΠΊΠ»ΡΡΠ°Π΅ΠΌ pdf-ΡΠΈΠ»ΡΡΡ
}
To convert HTML to PDF from text
location =/html_to_pdf_from_text {
html2pdf on; # Π²ΠΊΠ»ΡΡΠ°Π΅ΠΌ pdf-ΡΠΈΠ»ΡΡΡ
return 200 "<p style="background-color: #c11">ΠΠ΄ΡΠ°Π²ΡΡΠ²ΡΠΉ, ΠΌΠΈΡ!</p>"; # Π²ΠΎΠ·Π²ΡΠ°ΡΠ°Π΅ΠΌ HTML
}
To convert HTML to PDF from a proxy
location =/html_to_pdf_from_proxy {
html2pdf on; # Π²ΠΊΠ»ΡΡΠ°Π΅ΠΌ pdf-ΡΠΈΠ»ΡΡΡ
proxy_pass somewhing_that_returns_html; # ΠΏΠ΅ΡΠ΅Π½Π°ΠΏΡΠ°Π²Π»ΡΠ΅ΠΌ Π½Π° ΡΡΠ΄Π°, Π³Π΄Ρ Π²ΠΎΠ·Π²ΡΠ°ΡΠ°Π΅ΡΡΡ HTML
}
as a result, when accessing these locations, instead of HTML, a PDF generated based on it will be returned (using
This, of course, is not the best generator, I tried a couple more before it, but found errors in them
Source: habr.com