Comment convertir HTML en PDF avec C++

Vue d’ensemble

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 convertir du HTML en PDF. It covers the following topics.

Conversion HTML en PDF en C++

Comment convertir HTML en PDF ? Avec la bibliothèque Aspose.Cells for C++, vous pouvez facilement convertir HTML en PDF de manière programmatique avec quelques lignes de code. Aspose.Cells for C++ est capable de créer des applications multiplateformes avec la capacité de générer, modifier, convertir, rendre et imprimer tous les fichiers Excel.

Conversion C++ de HTML en PDF

L’exemple de code C++ suivant montre comment convertir un document HTML en PDF en utilisant Aspose.Cells for C++.

  1. Créez une instance de la classe HtmlLoadOptions.
  2. Initialisez l’objet Workbook.
  3. Enregistrez le document PDF de sortie en appelant la méthode Workbook.Save().
#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();
}

Essayez de convertir du HTML en PDF en ligne

Aspose.Cells for C++ presents you with an online free application “HTML en PDF”, where you may try to investigate the functionality and quality it works.