1. Home
  2. /
  3. GroupDocs.Conversion.LowCode
  4. /
  5. GroupDocs.Conversion.LowCode
  6. /
  7. HtmlToPdfConverter

HtmlToPdfConverter class

Provides a simple API to convert HTML documents to PDF format using the GroupDocs.Conversion LowCode interface.

This converter is part of the LowCode API, which allows you to perform HTML to PDF conversions with minimal code and configuration.

Features:

  • Convert HTML files to PDF with high fidelity
  • Support for password-protected HTML documents
  • Customize loading and conversion via WebLoadOptions and PdfConvertOptions
  • Stream and file-based conversion support

Code Examples:

See the LowCode developer guide for more details: https://docs.groupdocs.net/conversion/developer-guide/

public sealed class HtmlToPdfConverter : Converter<WebLoadOptions, PdfConvertOptions>

Public Members

namedescription
HtmlToPdfConverter(…)Initializes a new instance of the HtmlToPdfConverter class for converting HTML documents to PDF. (2 constructors)
Convert(…)Converts the loaded HTML document to PDF and saves it to the specified file path. (2 methods)

Remarks

Example - Basic conversion:

using GroupDocs.Conversion.LowCode;

// Load license keys
var publicKey = Environment.GetEnvironmentVariable("GD_PUBLIC_KEY");
var privateKey = Environment.GetEnvironmentVariable("GD_PRIVATE_KEY");

// Apply the license
License.Set(publicKey, privateKey);

// Create a converter for the HTML file
var converter = new HtmlToPdfConverter("sample.html");

// Convert HTML to PDF
converter.Convert("sample.pdf");

Example - Advanced conversion with options:

var converter = new HtmlToPdfConverter("sample.html", options =>
{
    options.Zoom = 150; // 150% zoom
    options.SkipExternalResources = true;
});
converter.Convert("styled.pdf", convertOptions =>
{
    convertOptions.Dpi = 300;
    convertOptions.Password = "12345";
});

See Also