Use the sample source code below to convert HTML to PDF in JavaScript using ByteScout Cloud API (low level).
It is also possible to convert PDF to HTML in JavaScript.
https://api.pdf.co/v1/pdf/convert/from/html
var Bytescoutio = require('bytescoutio'); var defaultClient = Bytescoutio.ApiClient.instance; // Configure API key authorization: api_key var api_key = defaultClient.authentications['api_key']; api_key.apiKey = "YOUR API KEY" // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) //api_key.apiKeyPrefix['x-api-key'] = "Token" var api = new Bytescoutio.DefaultApi() var text = ; // {Text} HTML data to convert to PDF. var opts = { 'name': name_example // {String} File name for the generated result. }; var callback = function(error, data, response) { if (error) { console.error(error); } else { console.log('API called successfully. Returned data: ' + data); } }; api.pdfConvertFromHtmlPost(text, opts, callback);
IMPORTANT:
Cloud API is deprecated and was replaced with more powerful and secure www.PDF.co Web API
CLICK HERE
TO LEARN MORE
ABOUT NEW
www.PDF.co
w/ Web API
On-Premise API Server
Cloud API Server