Step 1 – Source Code
First, open the source code in your preferred editor and save it as app.js in a folder. You can get a copy of the source code here.
Step 2 – Add API Key
In line 21, use your PDF.co API Key as the API_Key variable’s value. You can get it here.
Step 3 – Source and Destination File
In line 25, enter the Wikipedia link https://en.wikipedia.org/wiki/Main_Page as the source link and its destination file in line 27.
Step 4 – Run Program
Now, type in
node app.js in the Terminal. Be sure to set the path where the file is stored.
Step 5 – Output File
After the program confirms that the PDF file has been generated, open the folder to see the result.
Step 6 – Webpage to PDF Demo
Here’s the Webpage to PDF in action.