Key Features of Aspose.HTML for Python via .NET

Aspose.HTML for Python via .NET combines DOM-based document processing with conversion and rendering APIs. Python applications can create, load, inspect, edit, save, and convert HTML-related documents and work with web technologies such as CSS, SVG, JavaScript, and HTML Canvas.

Use HTMLDocument for document and DOM operations, selector or XPath APIs for navigation and extraction, and the Converter class for common format conversions. Save and rendering options provide additional control over the output.

Document Manipulation

Aspose.HTML for Python via .NET can create, load, edit, and save HTML and related documents without opening a browser interface.

The DOM API provides several ways to locate and inspect content in a loaded document:

See Data Extraction for navigation and resource extraction workflows.

Conversion and Rendering

Aspose.HTML for Python via .NET supports conversion workflows for HTML, XHTML, SVG, MHTML, EPUB, and Markdown sources. Depending on the source and API, output can include HTML, MHTML, Markdown, PDF, XPS, DOCX, and raster images.

The Supported File Formats table distinguishes input formats from output-only formats. Fine-Tuning Converters explains the lower-level rendering APIs and output devices.

Convert HTML to PDF in Python

The verified example below converts document.html to output.pdf:

  1. Import the conversion and saving modules.
  2. Create default PdfSaveOptions for PDF output.
  3. Call Converter.convert_html() with the source file, save options, and output path.
1# Convert HTML to PDF in Python
2
3import aspose.html.converters as conv
4import aspose.html.saving as sav
5
6# Convert HTML to PDF
7conv.Converter.convert_html("document.html", sav.PdfSaveOptions(), "output.pdf")

For source-specific workflows and save options, open Converting Between Formats.

Web Platform and Advanced Features

Feature AreaCapability
HTML parsing and DOMParse HTML into a document tree and work with elements, attributes, text, and document structure through DOM APIs.
CSSRead and modify styles, process stylesheets, and apply CSS during rendering.
JavaScriptProcess supported scripts in loaded documents and configure or restrict script execution when required.
HTML CanvasProcess canvas content created through JavaScript or Canvas APIs during document rendering.
SVGCreate, parse, edit, save, and render SVG documents and elements.
HTML templatesPopulate HTML templates with structured data for generated documents.
Output streamsDirect generated output to application-managed streams instead of fixed file paths.
DOM observationUse MutationObserver APIs to monitor changes made to the document tree.
Web accessibilityRun supported accessibility checks and work with validation results and reports.

Platform Support

Aspose.HTML for Python via .NET packages are available for supported Windows, Linux, and macOS environments. The Python version and processor architecture must match an available package. See System Requirements before choosing a development or deployment environment.

Next Steps