For converting from HTML to PDF, we will need the main and its plugin . (I provided links to my fork of nginx, as I made some changes that have not yet been pushed to the original repository. You can also use .)
To convert HTML to PDF from a file
location =/html_to_pdf_from_file {
html2pdf on; # enable pdf filter
}To convert HTML to PDF from text
location =/html_to_pdf_from_text {
html2pdf on; # aktiverer pdf-filter
return 200 "<p style="background-color: #c11">Hei, verden!</p>"; # returnerer HTML
}To convert HTML to PDF from a proxy
location =/html_to_pdf_from_proxy {
html2pdf on; # enable pdf filter
proxy_pass something_that_returns_html; # redirect to where HTML is returned
}as a result, when accessing these locations, a PDF will be returned instead of HTML, generated based on it (with the help of ).
This is, of course, not the best generator; before this, I tried a couple more, but found errors in them og .
Kilde: habr.com
