How to convert a Website URL into a PDF file in Node.JS

Cloudmersive
1 min readMar 21, 2020

--

Need to render a website into PDF form? We have a handy little API that will do just that. It takes just a short time to set up — let’s look at how.

We’ll use npm install to get the client installed.

npm install cloudmersive-convert-api-client --save

This now opens up our API to be called with this function here:

var CloudmersiveConvertApiClient = require('cloudmersive-convert-api-client');var defaultClient = CloudmersiveConvertApiClient.ApiClient.instance;// Configure API key authorization: Apikeyvar Apikey = defaultClient.authentications['Apikey'];Apikey.apiKey = 'YOUR API KEY';// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)//Apikey.apiKeyPrefix = 'Token';var apiInstance = new CloudmersiveConvertApiClient.ConvertWebApi();var input = new CloudmersiveConvertApiClient.UrlToPdfRequest(); // UrlToPdfRequest | URL to PDF request parametersvar callback = function(error, data, response) {if (error) {console.error(error);} else {console.log('API called successfully. Returned data: ' + data);}};apiInstance.convertWebUrlToPdf(input, callback);

Enter the URL of the target website and it will be downloaded, processed, and sent back as a PDF. How easy was that! All of our APIs are just as easy to use, and we have hundreds.

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

No responses yet