Don’t. Show a web page and open the print dialog, and tell people to save as PDF. All major browsers support this, and the browser HTML to PDF code is the most robust and accurate.
It's very likely to be a massive batch operation of a ton of HTML files that might not even be their own site.