Is there a way to turn HTML + CSS code into a pdf so it does not look like printing a webpage?

So far I have been exporting my pages to pdf using page-break-before and the likes from the browser. But I get awful margins and it is far too browser specific. I am looking for the same look and feel you get from Latex or Powerpoint presentation exports: well centered, proper margins, custom page size.

Any idea of a script that exports a properly formatted html page to pdf?

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
If this question can be reworded to fit the rules in the help center, please edit the question.

2 Answers
2

There is a tool called wkhtmltopdf that will convert HTML and CSS to PDF with a simple command line call. This tool can be used manually or placed in a script of some sort to run with a button click or what have you. I've used it in PHP like so: