Node.jsとC++を使ったHTMLをPDFに変換する方法

概要

Aspose.Cells is a professional solution that allows you to generate PDF files from web pages and raw HTML code in your applications.

This article explains how to HTMLをPDFに変換する. It covers the following topics.

Node.jsでのHTMLからPDFへの変換

HTMLをPDFに変換するには?Aspose.Cells for Node.js via C++ライブラリを使えば、数行のコードですぐにHTMLをPDFにプログラム的に変換できます。Aspose.Cells for Node.js via C++は、Excelファイルの生成、修正、変換、レンダリング、印刷が可能なクロスプラットフォームアプリケーションの構築に対応しています。

JavaScriptを使ったHTMLをPDFに変換

次のJavaScriptコードサンプルは、Aspose.Cells for Node.js via C++を使ってHTMLドキュメントをPDFに変換する方法を示しています。

  1. HtmlLoadOptionsクラスのインスタンスを作成します。
  2. Workbookオブジェクトを初期化します。
  3. Workbook.save() メソッドを呼び出して、出力 PDF ドキュメントを保存します。
const AsposeCells = require("aspose.cells.node");
const path = require("path");

// The path to the documents directory.
const dataDir = path.join(__dirname, "data");
const filePath = path.join(dataDir, "sample.html");

// Loads the workbook which contains hidden external links
const options = new AsposeCells.HtmlLoadOptions(AsposeCells.LoadFormat.Html);
const book = new AsposeCells.Workbook(filePath, options);
book.save("out.pdf");

オンラインでHTMLをPDFに変換してみてください

Aspose.Cells for Node.js via C++ presents you online free application 「HTMLをPDFに」, where you may try to investigate the functionality and quality it works.