JavaScript API to convert HTML to PDF

JavaScript library to convert HTML to PDF

Use HTML Conversion REST API to create customized document workflows in JavaScript. This is a professional solution to convert HTML to PDF and other document formats online using JavaScript.

View code snippet

Convert HTML to PDF JavaScript REST API

Convert a HTML file to PDF format in JavaScript. This JavaScript library is designed to convert HTML files to a wide variety of file formats using REST API.

The API HTML to PDF Conversion allows JavaScript developers to easily convert HTML to PDF and take advantage of both file formats.

Convert a HTML file to PDF in JavaScript

Converting file formats from HTML to PDF is a complex task. All HTML to PDF format transitions are performed by our JavaScript SDK, while maintaining the main structural and logical content of the source HTML document.

Our JavaScript library is a professional solution to convert HTML, PDF files online. This Cloud SDK gives JavaScript developers powerful functionality and perfect quality PDF output.

The following JavaScript example of using the Conversion API will get you started quickly.

Upload a file you want to convert
Run code
Select the target format from the list
import * as fs from "fs";

const wordsApi = new WordsApi("####-####-####-####-####", "##################");

const doc = fs.createReadStream("Input.html");
const request = new model.ConvertDocumentRequest({
    document: doc,
    format: "pdf"
});

const convert = wordsApi.convertDocument(request)
.then((convertDocumentResult) => {
    console.log("Result of ConvertDocument: ", convertDocumentResult);
});
Run code
  
Copy JavaScript code to the clipboard

How to convert HTML to PDF JavaScript REST API

  1. Install JavaScript library and add the reference (import the library) to your project.
  2. Open the source HTML file in JavaScript.
  3. Call the convertDocument() method, passing the HTML file and the PDF option.
  4. Save the result of conversion as PDF file.

JavaScript library to convert HTML to PDF

Install 'Aspose.Words Cloud SDK for Node.js' using NPM package manager. Run npm install asposewordscloud --save from the command line to install the SDK via the NPM package manager. As an alternative, you can manually clone Aspose.Words Cloud SDK for Node.js source code from GitHub and use it in your project. Please follow these Instructions to quickly get the necessary security credentials and access our REST API.

System Requirements

  • @types/request (version 2.48.3+)
  • lodash (version 4.17.15+)
  • lodash.template (version 4.5.0+)
  • request (version 2.88.0+)
  • request-debug (version 0.2.0+)

Refer to the Repository Documentation to see more details.

Other supported HTML conversions

You can convert HTML to many other file formats:

5%

Subscribe to Aspose Product Updates

Get monthly newsletters and offers directly delivered to your mailbox.

© Aspose Pty Ltd 2001-2024. All Rights Reserved.