Nginx-oppskrifter: konvertering fra HTML til PDF

For converting from HTML to PDF, we will need the main nginx and its plugin html2pdf. (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 a ready-made way.)

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 the generator from wt).

This is, of course, not the best generator; before this, I tried a couple more, but found errors in them htmldoc og wkhtmltopdf.

Kilde: habr.com

Kjøp pålitelig hosting for nettsteder med DDoS-beskyttelse, VPS VDS-servere 🔥 Kjøp pålitelig hosting for nettsteder med DDoS-beskyttelse, VPS VDS-servere | ProHoster