Using Headless Chrome in classic ASP


to Developers Blog

UPDATE 31/03/2023: A bug in Chrome currently breaks the "export as screenshot" feature that I liked a lot. Screenshots now default to 800/600px and do not respect the window-size parameter anymore. This should be fixed in Google 113. 

UPDATE: I turned this into a GitHub repository. Make sure to give it a try and report any issue! Thanks!


For a customer, I needed to create pdf files in my classic ASP web app. After looking into both commercial and free PDF creating software, I found out that it can easily be done with Headless Chrome. For free!

You need to have Chrome installed on your computer/server.

Here's the code:

In short, this script launches a command line app, changes the directory to the chrome application, runs Chrome with the parameters needed and finally creates a PDF file from the QuickerSite website. Not only a PDF is generated. I also added a screenshot. "Exit" closes the cmd line app. 

Don't get too excited though. This only works if your IUSR has the necessary permissions. This will never work on shared hosting. But if you run your own Windows Server, this might help you out. You also have to create a folder ("D:\Chrome" in this case) where the Chrome user can dump its logs and errors. That's it! 

Creating PDF files and images on the fly is something I'm looking for for quite a while in classic ASP. It looks like having this headless Chrome-thing at my fingertips, is going to help a lot! The most exciting thing about this, is that classic ASP developers are - for once - not forced to use outdated or badly supported (or expensive) COM dll's or one or the other open source PHP library to get the job done. This is Chrome people... probably the best software on the planet. Being able to use Chrome features like creating PDF files and generating (complex) images from any HTML/CSS/JavaScript is a big big thing. This opens up a lot of opportunites to classic ASP developers, as long as you run your own Windows server. Have fun!

to Developers Blog

© QuickerSite webCMS 2024

backtotop