Convert HTML to PDF via Cloud Node.js SDK
Export HTML documents to multiple formats including PDF with Aspose.PDF Cloud Node.js SDK
Get StartedHow to Convert HTML to PDF Using Node.js SDK
To convert HTML to PDF, we’ll use Aspose.PDF Cloud Node.js SDK This Cloud SDK SDK assists Node.js programmers in developing cloud-based PDF creator, annotator, editor, and converter apps using Node.js programming language via Aspose.PDF REST API. Open NPM package manager, search for Aspose.PDF Cloud, and install. You may also use the following command from the Package Manager Console.
Package Manager Console Command
npm install asposepdfcloud --save
Steps to Convert HTML to PDF via Node.js
Aspose.PDF Cloud Node.js developers can easily load & convert HTML files to PDF in just a few lines of code.
- Load your Application Secret and Key from the JSON file or set credentials in another way
- Create an object to connect to the Cloud API
- Upload your document file
- Perform the conversion using putHtmlInStorageToPdf
- Download the result if needed it
System Requirements
It is easy to get started with Aspose.PDF Cloud Node.js SDK and there is nothing to install. Simply create an account at Aspose for Cloud and get your application information. Once you have the App SID & key, you are ready to give the Aspose.PDF Cloud Node.js SDK.
- CPU: 1GHz
- RAM: 512Mb
- Free space on disk: 20Mb
- Any OS Microsoft Windows, Mac OS, Linux x32/x64
- node.js v4.8 or higher
This sample code shows HTML to PDF Cloud Node.js SDK Conversion
const fs = require("fs");
const credentials = require("./credentials.json");
const { PdfApi } = require("asposepdfcloud");
// Load your Application Secret and Key from the JSON file or set credentials in another way
async function convertHTMLtoPDF() {
const localImageFileName = "C:\\Samples\\sample.html";
const storageFileName = "sample.html";
const pdfApi = new PdfApi(credentials.id, credentials.key);
let fileData = await fs.readFile(localImageFileName);
try {
let uploadResult = await pdfApi.uploadFile(storageFileName, fileData);
console.log(uploadResult.response.text);
}
catch (error) {
console.error(error.response.text);
}
try {
let convertResult = await pdfApi.putHtmlInStorageToPdf("sample-html-to-pdf.pdf", storageFileName);
console.log(convertResult.response.text);
const buffer = await pdfApi.downloadFile(STORAGE_FILENAME);
} catch (error) {
console.error(error.response.text);
}
}
Free App to Convert HTML to PDF
Check our live demos for HTML to PDF conversion with following benefits.
About Aspose.PDF Cloud Node.js SDK
Aspose.PDF Cloud is a true REST API that enables you to perform a wide range of document processing operations including creation, manipulation, conversion and rendering of PDF documents in the cloud. Our Cloud SDKs are wrappers around REST API in various programming languages, allowing you to process documents in language of your choice quickly and easily, gaining all benefits of strong types and IDE highlights. This repository contains new generation SDKs for Aspose.PDF Cloud and examples. These SDKs are now fully supported. If you have any questions, see any bugs or have enhancement request, feel free to reach out to us at Free Support Forums.
HTML What is HTML File Format
HTML (Hyper Text Markup Language) is the extension for web pages created for display in browsers. Known as language of the web, HTML has evolved with requirements of new information requirements to be displayed as part of web pages. The latest variant is known as HTML 5 that gives a lot of flexibility for working with the language. HTML pages are either received from server, where these are hosted, or can be loaded from local system as well. Each HTML page is made up of HTML elements such as forms, text, images, animations, links, etc. These elements are represented by tags such as img, a, p and several others where each tag has start and end. It can also embed applications written in scripting languages such as JavaScript and Style Sheets (CSS) for overall layout representation.
Read MorePDF What is PDF File Format
Portable Document Format (PDF) is a type of document created by Adobe back in 1990s. The purpose of this file format was to introduce a standard for representation of documents and other reference material in a format that is independent of application software, hardware as well as Operating System. PDF files can be opened in Adobe Acrobat Reader/Writer as well in most modern browsers like Chrome, Safari, Firefox via extensions/plug-ins. Most of the commercially available software suites also offer conversion of their documents to PDF file format without the requirement of any additional software component. Thus, PDF file format has full capability to contain information like text, images, hyperlinks, form-fields, rich media, digital signatures, attachments, metadata, Geospatial features and 3D objects in it that can become as part of source document.
Read MoreOther Supported Conversions
You can also convert MD into many other file formats including few listed below.