I'm trying to use Chimp / Webdriver.io / Selenium in Node JS to try to test my @media print CSS to make sure everything shows up correctly when people print from my website.
How can I programatically get Chrome / Firefox to print to PDF? I don't want to convert a screenshot to PDF. I want the PDF to look like what it will look like when printed.
Then, how can I scan the PDF to make sure that the results are correct?
Success! I had to install/use the following tools:
html-pdf-chrome is used to magically call Chrome to convert some given HTML to a PDF in the manner that Chrome would normally use to print. pdfreader is a package that reads said PDF and then provides the text inside of it.
After browsing to the page I want to print using webdriver, I can call:
Then, to get the text in the PDF, I call this function: