Aspose.HTML for .NET FAQ

This FAQ answers practical Aspose.HTML for .NET questions about HTML conversion, document loading, DOM selection, custom fonts, output streams, sandboxing, and rendering behavior in C# applications.

Use this page as a quick route to the most common Aspose.HTML for .NET tasks. Each answer points to a deeper article when the task needs full code, options, or troubleshooting details.

Installation and Licensing

How do I install Aspose.HTML for .NET?

Install the package from NuGet and reference it in your .NET project. The installation guide covers NuGet Package Manager, .NET CLI, Visual Studio, and package update options. See Installation.

Can I evaluate Aspose.HTML for .NET before buying a license?

Yes. You can use the product in evaluation mode, request a temporary license, or apply a purchased license in your application. See Licensing for license types, setup examples, and common licensing issues.

Where can I find complete C# examples?

The documentation pages include focused snippets, and the full example project is available in the Aspose.HTML for .NET GitHub repository. Use it when you need runnable sample projects, input files, and output workflows.

Conversion and Supported Formats

How do I convert HTML to PDF in C#?

Use Converter.ConvertHTML() with PdfSaveOptions. For a simple local HTML file, the conversion can be as short as:

1Aspose.Html.Converters.Converter.ConvertHTML("document.html", new PdfSaveOptions(), "output.pdf");

For full workflows, save options, and related formats, see Converting Between Formats and Convert HTML to PDF in C#.

What document formats does Aspose.HTML for .NET support?

Aspose.HTML for .NET works with HTML, XHTML, SVG, EPUB, MHTML, and Markdown documents. It also supports related web technologies such as CSS, XPath, and HTML5 Canvas in relevant workflows. See Supported File Formats and Features List for details.

Can I convert HTML to image formats?

Yes. Aspose.HTML for .NET can render HTML to raster image formats such as PNG and JPG. Use image save options to control output format, page setup, resolution, and background where applicable. See Convert HTML to PNG in C# and Convert HTML to JPG in C#.

How do I control page size, margins, or scaling during conversion?

Configure rendering options such as PageSetup and PageLayoutOptions before converting. See Resize HTML Output in C# for examples that crop content, fit width or height, and scale PDF, DOCX, XPS, or image output.

Can I flatten PDF form fields after HTML to PDF conversion?

Yes. When a workflow produces a PDF with interactive form fields and you need a fixed, non-editable result, use the PDF flattening workflow. See Flatten PDF in C#.

Can I load EPUB, MHTML, or SVG with HTMLDocument?

HTMLDocument is designed for HTML documents. For EPUB, MHTML, SVG, and other supported inputs, use the specialized APIs and workflows described in Creating a Document and the conversion guides.

DOM Selection and Data Extraction

Can I extract information from an HTML document?

Yes. You can inspect the HTML DOM, navigate nodes, use CSS selectors, evaluate XPath expressions, and extract links, text, images, SVG content, or other resources. Start with Data Extraction and HTML Navigation.

Does Aspose.HTML for .NET support CSS selectors?

Yes. Use QuerySelector() to return the first matching element and QuerySelectorAll() to return all matching elements. See Use CSS Selectors in C# for examples with element, class, id, and complex selectors.

Does Aspose.HTML for .NET support XPath?

Yes. Use Document.Evaluate() to run XPath expressions against HTML or XML documents. See Use XPath in HTML with C# and Select XML Nodes with XPath in C#.

Saving, Resources, and Configuration

Can I save linked HTML documents and resources together?

Yes. When an HTML document references related resources, use the saving workflow and resource-handling options described in Save HTML Document. For linked HTML files, check the MaxHandlingDepth setting in that article.

Can I disable JavaScript or restrict external resources?

Yes. Use sandboxing and environment configuration when a document should not access untrusted scripts, resources, or network locations. See Environment Configuration and Sandboxing.

How can I see which resources are loaded with an HTML document?

Use the network service and message handlers to inspect or control request and response messages. This is useful for tracing resource loading, custom caching, authentication, and substitutions. See Message Handlers and Network Requests.

Can I load a webpage from a URL and save it as PDF?

Yes. You can load a web page by URL and convert it to PDF, while Aspose.HTML handles linked resources according to the configured environment and network behavior. See How to Save a Webpage as a PDF.

How do I set authentication, headers, or request timeouts?

Use message handlers and network configuration to customize requests before a document is loaded or converted. See Authentication and Network Timeouts.

Accessibility and Validation

Can Aspose.HTML for .NET check web accessibility?

Yes. The accessibility APIs can validate HTML documents against accessibility rules and help detect issues that affect users of assistive technologies. Start with Web Accessibility and Web Accessibility Check.

Can I save accessibility validation results?

Yes. Validation results can be inspected and saved for reporting or automated checks. See Web Accessibility Validation Results and Save Accessibility Validation Results.

How do I improve image accessibility in HTML?

Add meaningful alt attributes to informative images and avoid empty or missing text alternatives where image content matters. See Add Alt Text to Images in C# for a focused DOM update workflow.

Deployment and Runtime Environment

Can I use Aspose.HTML for .NET in Docker?

Yes. Docker workflows depend on the runtime image, installed system packages, fonts, and locale settings. See Run Aspose.HTML for .NET in Docker for environment guidance.

Why does HTML to image output miss text in Linux or Docker?

Missing text usually means required fonts are not installed or not available to the rendering process. Install the fonts in the container or configure a custom font folder. See HTML to Image in Linux Docker Fonts and Set Custom Font Folder in C#.

How do I make rendering behavior consistent across machines?

Use the same package version, runtime, input files, fonts, locale settings, and configuration on each machine. Differences in installed fonts or network resource access are common causes of output differences.

Rendering and Troubleshooting

How do I use custom fonts when rendering HTML?

Configure the font lookup folder through FontsSettings.SetFontsLookupFolder() before loading and rendering the document. See Set Custom Font Folder in C# for PDF and image rendering examples.

How do I store rendering output in memory instead of files?

Implement Aspose.Html.IO.ICreateStreamProvider to handle output streams created during rendering. See Output Streams for a memory stream workflow.

How do I add page numbers, headers, or footers to rendered output?

Use CSS and Aspose.HTML CSS extensions for page margin boxes and generated content. See CSS Extensions for page numbers and margin content examples.

Can I convert measurement units such as px, in, cm, and mm?

Yes. Use Unit, UnitType, and GetValue() from the Aspose.Html.Drawing namespace. Aspose.HTML follows the CSS absolute length model where 96 px equals 1 inch. See Convert Pixels to Inches in C#.

Why do I see black squares or incorrect characters in output?

This usually points to encoding or font availability. If the document encoding is not declared, Aspose.HTML follows the HTML5 default behavior and uses UTF-8. If the source uses a different encoding, specify it when loading the document. If glyphs are missing during rendering, configure or install the required fonts. See Environment Configuration and Set Custom Font Folder in C#.

Related Aspose.HTML for .NET Resources