Saving pdf from webpage

Connect to the site using APi.
In response, I received the html code.
Is it possible to save this page as a pdf without opening IE?

You could call a pdf creator from command line.
Here are some examples listed: