Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
Aspose.HTML for Java is an on-premise API for loading, creating, editing, saving, and converting HTML and related web formats in Java applications. Use HTMLDocument for HTML DOM operations and the Converter class for supported format conversions.
This FAQ provides direct answers to common questions about Aspose.HTML for Java. Follow the links in each answer for complete Java examples, API options, and troubleshooting guidance.
Aspose.HTML for Java is a Java library for working with HTML documents without automating a web browser. It provides APIs for HTML parsing, DOM editing, CSS and JavaScript processing, data extraction, web accessibility checks, document saving, and conversion to formats such as PDF, DOCX, XPS, and raster images. See the Features List for an overview.
Add the Aspose repository and Aspose.HTML dependency to a Maven or Gradle project, or download the JAR package manually. The Installation guide contains the current repository settings and dependency examples.
Aspose.HTML for Java is a commercial library, but you can install and evaluate it without a license. Evaluation output has restrictions, including watermarks and a conversion page limit. Request a free temporary license to test the full API without evaluation restrictions. See Licensing for the current limitations and license setup.
Supported Java runtimes and operating systems can change as the product evolves. Check System Requirements for the maintained compatibility information before choosing a runtime or deployment image.
Documentation pages contain focused code snippets, while the Aspose.HTML for Java GitHub repository provides complete examples and supporting data files. The How to Run the Examples article explains how to set up and run them.
Use Converter.convertHTML() with PdfSaveOptions. For a local HTML file:
PdfSaveOptions for the PDF output.Converter.convertHTML() with the input path, options, and output path.1// Convert HTML to PDF
2
3Converter.convertHTML("document.html", new PdfSaveOptions(), "output.pdf");See Convert HTML to PDF in Java for HTML strings, documents, custom page settings, and complete examples.
Supported source formats include HTML, XHTML, MHTML, EPUB, SVG, and Markdown. Supported output workflows include HTML-related formats, PDF, XPS, DOCX, and raster images such as PNG, JPEG, TIFF, BMP, and GIF. Not every input format supports every output combination. Use the Supported File Formats table and the conversion guides to choose the correct workflow.
Yes. Load the webpage URL with HTMLDocument, create PdfSaveOptions, and pass the document to Converter.convertHTML(). The application must be able to access the page and its linked resources while the document is loading and rendering. See
Create and Load HTML Documents and
Convert HTML to PDF.
Yes. Use a Converter.convertHTML() overload that accepts an HTML string, a base URI, save options, and an output path. Supply a valid base URI when the markup contains relative paths to images, stylesheets, scripts, fonts, or links.
Yes. Use Converter.convertHTML() with ImageSaveOptions and select the required output format. Image conversion supports PNG, JPEG, TIFF, BMP, and GIF output. See
Convert HTML to Image in Java for file, document, and custom rendering examples.
No. PDF is an output format in Aspose.HTML for Java, not a supported input format. Use Aspose.PDF for Java when a workflow must load or convert an existing PDF document.
Create the save-options class for the target format and configure the settings supported by that class. Depending on the output, options can include page size, margins, resolution, background color, image format, or document-specific settings. Start with Fine-Tuning Converters and then open the guide for the required converter.
HTMLDocument is intended for HTML and XHTML documents. Use SVGDocument for SVG DOM operations. For EPUB and MHTML conversion, use the specialized Converter.convertEPUB() and Converter.convertMHTML() workflows described in the
EPUB Converter and
MHTML Converter guides.
Relative resource URLs are resolved against the document URL or the base URI supplied for in-memory HTML. Use a correct base URI, confirm that local or remote resources are accessible, and make the required fonts available to the rendering environment. For configuration examples, see Create and Load HTML Documents and Environment Configuration.
Yes. Pass a list of output streams to a supported converter overload and manage the resulting streams in application memory. Image conversion can create more than one stream when the result has multiple output pages. See
HTML Output Streams in Java for the MemoryStreamProvider helper and a complete example.
Yes. Create an empty document or load HTML from a file, URL, string, or stream. You can then use DOM APIs to add or remove nodes, change elements and attributes, update text, and modify CSS. Start with Create and Load HTML Documents and Edit HTML Documents.
Call HTMLDocument.save() and use HTMLSaveOptions when you need to control how resources are handled. The save options can determine which linked resources are written and how their URLs are processed. See
Save HTML Documents in Java.
Yes, when saving a document that links to other HTML pages. Configure ResourceHandlingOptions.setMaxHandlingDepth() to control how deeply the save operation follows linked pages. This is a linked-resource traversal setting, not a general batch API for unrelated HTML files. See
Save HTML Documents for depth values and resource-handling examples.
Yes. Load the document, select the required DOM nodes, read their content or attributes, resolve relative URLs, and save or process the results. See Data Extraction in Java, Extract Images from a Website, and Extract SVG from a Website.
Yes. Use CSS selectors to find elements with querySelector() or querySelectorAll(), and use XPath expressions when a query requires XPath navigation. The
HTML DOM Navigation guide includes examples of CSS selectors, XPath, TreeWalker, and NodeFilter.
Yes. Create a Configuration, add the Sandbox.Scripts flag, and load the document with that configuration. Sandboxing can also restrict other document capabilities. See
Environment Configuration for the Java example.
Yes. Use the runtime service from Configuration and set a JavaScript timeout before loading or converting the document. This prevents a long-running script from blocking processing indefinitely. See
JavaScript Runtime Service.
Use the network service and message-handler chain to inspect requests and responses. Custom handlers can log failed requests or modify request and response processing before the next handler runs. See Network Service.
Configure a user stylesheet through the user agent service and pass that Configuration to the document. This lets application CSS participate in rendering without changing the source file. See
User Style Sheet.
Yes. The Web Accessibility API validates HTML against supported WCAG 2.0 rules and returns results that identify failed criteria, techniques, and affected elements. Start with Web Accessibility in Java and Accessibility Validator.
Yes. The application can run in Docker and headless environments when the container includes the required Java runtime, library dependencies, and fonts needed by the documents. See Using Aspose.HTML for Java in Docker and Using Headless Mode.
Check both character encoding and font availability. If the source uses a non-UTF-8 encoding, declare or configure the correct character set. If characters parse correctly but render as boxes, the selected font may not contain the required glyphs or may be unavailable in the environment. See Environment Configuration for charset and custom-font settings.
Use paged-media CSS and the supported Aspose.HTML CSS extensions to place generated content in page margin areas. See CSS Extensions in Java for page-number and margin-box examples.
Rendering can change when machines use different fonts, runtime environments, locale settings, resource access, or Aspose.HTML versions. For reproducible output, keep these inputs and settings consistent and make external resources available during processing.
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.