Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
Use the Converter class for common conversions with save options. Use document.render_to() to send one loaded document directly to an output device, or use a source-specific renderer when the application needs direct control over the rendering pipeline.
Aspose.HTML for Python via .NET provides a high-level conversion API and a lower-level rendering API. Both can produce PDF, XPS, DOCX, and raster images, but they expose different levels of control.
| Approach | Use it when |
|---|---|
| Converter methods | You need a concise conversion workflow with format-specific save options. This is the usual choice for HTML, SVG, MHTML, EPUB, and Markdown conversion. |
| document.render_to(device) | You already have a loaded document and want to render it directly to a configured output device. |
| Renderer.render() | You need to work explicitly with HtmlRenderer, SvgRenderer, MhtmlRenderer, or EpubRenderer and a target device. |
Save options belong to the high-level Converter workflow. Rendering options are passed to rendering devices in the lower-level workflow. Choose one approach for a conversion rather than combining save options and rendering options in the same call.
The rendering API separates the source type, rendering process, output format, and output settings:
| Component | Purpose | Examples |
|---|---|---|
| Source | Supplies the document or source stream to render | HTMLDocument, SVGDocument, MHTML stream, EPUB stream |
| Renderer | Processes the corresponding source type | HtmlRenderer, SvgRenderer, MhtmlRenderer, EpubRenderer |
| Device | Defines the output format and destination | PdfDevice, XpsDevice, DocDevice, ImageDevice |
| Rendering options | Configure layout and format-specific output behavior | PdfRenderingOptions, XpsRenderingOptions, DocRenderingOptions, ImageRenderingOptions |
The device determines the target format; it does not determine the source type. For example, PdfDevice can receive drawing operations produced from HTML, SVG, MHTML, or EPUB workflows and write them as PDF.
The following example uses the lower-level rendering API with default PDF rendering options. It loads a webpage into an HTMLDocument, creates a PdfDevice, and sends the document to that device with render_to().
To render a loaded document to an output device:
render_to() on the document and pass the device.1import aspose.html as ah
2import aspose.html.rendering.pdf as rp
3
4with ah.HTMLDocument("https://docs.aspose.com/html/files/document.html") as document:
5 device = rp.PdfDevice("document.pdf")
6 document.render_to(device)The result is document.pdf created with the default settings of PdfDevice. To customize page layout, PDF security, image settings, or DOCX output, create the matching rendering-options object and pass it to the corresponding device.
PdfDevice, XpsDevice, DocDevice, or ImageDevice for the required output format.HtmlRenderer, SvgRenderer, MhtmlRenderer, and EpubRenderer for different source types.Use the rendering API when the application needs to:
For ordinary file, string, stream, or URL conversion, start with the appropriate Converter guide and move to the rendering API only when the lower-level workflow provides a practical advantage.
Use the free online HTML applications for quick manual conversions. Use the Aspose.HTML for Python via .NET rendering API when output settings must be controlled in application code.
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.