How to HTML to PDF in JavaScript using Cloud API (low level) - ByteScout
Announcement
Our ByteScout SDK products are sunsetting as we focus on expanding new solutions.
Learn More Open modal
Close modal
Announcement Important Update
ByteScout SDK Sunsetting Notice
Our ByteScout SDK products are sunsetting as we focus on our new & improved solutions. Thank you for being part of our journey, and we look forward to supporting you in this next chapter!

How to HTML to PDF in JavaScript using Cloud API (low level)

  • Home
  • /
  • Articles
  • /
  • How to HTML to PDF in JavaScript using Cloud API (low level)

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.

POST endpoint:

https://api.pdf.co/v1/pdf/convert/from/html

Code Sample:

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);

Tutorials:

prev
next