To begin, you can get a copy of the code samples below:
Step 2: Install Request Module
Next, install the request module for file upload. Type the
npm install requests in the terminal.
Step 3: PDF.co API Key
Set your PDF.co API key as the const API_Key value. You can get the PDF.co API Key in your dashboard here.
Step 4: Upload Base64
First, we need to upload the sample file to the /v1/file/upload/base64 endpoint. As well as add a filename value for the name parameter.
Step 5: Base64 Output URL
Next, the PDF.co Upload Base64 API endpoint will generate an output for an image file that we will use to convert to PDF.
Step 6: Convert Image to PDF
Then, we will use the /v1/pdf/convert/from/image endpoint to convert the output link to PDF.
Step 7: Run Program
Finally, run the program by typing the node your_program_name.js in the terminal.
Step 8: Base64 to PDF Demo
Here’s a quick demo to convert Base64 to PDF.