Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
You can convert HTML to various popular formats in Python online or programmatically. Converting from HTML to other formats can perform by using the
convert_html() methods of the Converter class, the
render_to() method of the HTMLDocument class, or the render() method of the
Renderer class.
In the Fine-Tuning Converters chapter, Aspose.HTML for Python via .NET offers alternative methods for rendering HTML-based documents, providing you with greater control over the rendering process in your Python application. Our Python library implements a set of rendering devices: PdfDevice, XpsDevice, DocDevice, and ImageDevice. Each device comes with its own unique options, implemented through the classes PdfRenderingOptions, XpsRenderingOptions, DocRenderingOptions, and ImageRenderingOptions, respectively. For instance, you can modify the page size, adjust margins and colors, reduce file size by changing image quality and resolution, and set a security password for PDF documents.
The current section describes supported scenarios of HTML-based files conversions to other popular formats by using the render_to() method of the HTMLDocument class and the render() methods of the Renderer class:
render_to() and render() accept instances of these rendering devices as parameters, allowing you to convert HTML into PDF, XPS, DOCX, and image formats.This example demonstrates how to easily convert an online HTML page to a PDF document using Aspose.HTML for Python via .NET. Just a few lines of code allow you to load an HTML document from a URL and render it directly into a PDF file with default rendering options.
1import aspose.html as ah
2import aspose.html.rendering.pdf as rp
3
4doc = ah.HTMLDocument("https://docs.aspose.com/html/files/document.html")
5doc.render_to(rp.PdfDevice("output/document.pdf"))A rendering device in Aspose.HTML for Python via .NET represents a 2D drawing surface, implemented through the IDevice interface. It is responsible for converting HTML content into various output formats.
Aspose.HTML for Python via .NET provides the following rendering devices:
Each device includes its own rendering options, available through classes like PdfRenderingOptions, XpsRenderingOptions, DocRenderingOptions, and ImageRenderingOptions. These options let you control output quality, layout, and other settings.
You can download the complete examples and data files from GitHub.
Aspose.HTML offers free Converters – an online collection of tools for converting HTML, XHTML, MHTML, EPUB, XML, or Markdown documents to PDF, XPS, DOCX, JPG, PNG, BMP, TIFF, GIF, Markdown, and other formats. These converters are compatible with any operating system and require no additional software installation. They’re a quick and easy way to convert HTML and HTML-based documents effectively.
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.