server-side printing

0

What is the best way to print an HTML on the server side ?. I am generating an HTML on the client side (with javascript and css) to print it (using window.print ()). I do not want to also have to generate it from the server side the print. I want to be able to pass to the Server the HTML generated on the client's side so that it prints it on one of its printers. Is the best practice?

    
asked by Leonardo 10.12.2018 в 18:33
source

1 answer

0

A fairly easy way to do this is to use wkhtmltopdf which is a Qt WebKit rendering engine on the server side

  • Install wkhtmltopdf
  • You run wkhtmltopdf /ruta/a/tu/html/ejemplo.html ejemplo.pdf on the server
  • With the server-side pdf, you can save it, show it etc.

The only thing you have to take into account are the routes, but it will work javascript, css, everything.

As @JackNavaRow points, you have to give it permission to run, but we assume that our code and the wkhtmltopdf are outside the root document. Another issue to keep in mind is that we have to be careful with the Cross-site scripting because we are running JavaScript on the side from the server.

    
answered by 10.12.2018 в 18:44