如何使用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.
C++中的HTML转PDF转换
如何将HTML转换为PDF?使用Aspose.Cells for C++库,您可以轻松通过几行代码实现HTML到PDF的程序转换。Aspose.Cells for C++具有构建跨平台应用的能力,能够生成、修改、转换、渲染和打印所有Excel文件。
C++将HTML转换为PDF
以下C++代码示例演示如何使用Aspose.Cells for C++将HTML文档转换为PDF。
- 创建HtmlLoadOptions类的实例。
- 初始化Workbook对象。
- 通过调用Workbook.Save()方法保存输出PDF文档。
#include <iostream>
#include "Aspose.Cells.h"
using namespace Aspose::Cells;
int main()
{
Aspose::Cells::Startup();
// Create HTML load options
HtmlLoadOptions options(LoadFormat::Html);
// Load the HTML file into a workbook
U16String inputFilePath(u"sample.html");
Workbook book(inputFilePath, options);
// Save the workbook as PDF
U16String outputFilePath(u"out.pdf");
book.Save(outputFilePath);
std::cout << "HTML file converted to PDF successfully!" << std::endl;
Aspose::Cells::Cleanup();
}
尝试在线将HTML转换为PDF
Aspose.Cells for C++ presents you with an online free application “HTML转PDF”, where you may try to investigate the functionality and quality it works.