Frequently Asked Questions
Q: What is Aspose.HTML for Java, and what can it do?
A: Aspose.HTML for Java is a robust library designed for creating, editing, and converting HTML and related formats, such as XHTML, MHTML, SVG, and EPUB. The library provides comprehensive features such as document object model manipulation, CSS and JavaScript support, and high-quality conversion of HTML and HTML-based documents to PDF, DOCX, PNG, JPEG, and other popular formats.
Q: How to convert HTML to PDF?
A: It is very simple. You can do this literally with a single line of code!
1// Convert HTML to PDF
2Converter.convertHTML("document.html", new PdfSaveOptions(), "output.pdf");
For more examples, please visit the Converting Between Formats guides.
Q: What formats does Aspose.HTML for Java support?
A: Out-of-the-box we support HTML, XHTML, SVG, EPUB, MHTML, and Markdown documents. As a part of the mentioned documents, we also support CSS, JavaScript, XPath and HTML5 Canvas specifications. For more details, please visit the Features List article.
Q: Can I customize rendering during HTML to image conversion?
A: Yes, you can customize image rendering by configuring options in the ImageSaveOptions
class. For instance, you can specify the image format (JPEG, PNG, BMP, GIF, or TIFF), resolution, compression level, etc., ensuring that the output meets your exact requirements. To learn more about
ImageSaveOptions please read the article
Fine-Tuning Converters.
Q: Can I use HTMLDocument to load EPUB file format?
A: In order to load EPUB, MHTML, SVG, or other supported formats, we prepared specialized end-points and described them in the
Create Document and
Converting Between Formats guides. The HTMLDocument
class is designed only to work with HTML files.
Q: Can I use Aspose.HTML for Java to extract information from a document?
A: Sure, we have a powerful API to inspect the content of HTML documents. It is described in the HTML navigation article.
Q: Do you support XPath syntax?
A: Yes.
Moreover, we support CSS Selectors and the native navigation mechanism that is called Document/Element Traversal. You can find examples of usage in the HTML Navigation article.
Q: Is it possible to save a few HTML documents at once?
A: Yes, if you have HTML files that are linked to each other, you can use the MaxHandlingDepth parameter to save them as a set of files.
Q: Is it possible to disable JavaScript for a Document?
A: Yes. You should use sandboxing flags to disable potentially untrusted resources.
Q: How to use the MemoryStream object to store the rendering result instead of the file system?
A: Aspose.HTML for Java allows realizing the MemoryStreamProvider
class as a custom implementation of the java.io.Closeable interface. This class represents a callback mechanism required to handle creating and managing output streams. More detailed information can be found in the article
Output Streams.
Q: How do you check the list of resources that are loaded along with an HTML document?
A: We have a specialized Network Service that gives you full control over all request/response messages. You can use it to trace the requests, create a custom cache, substitute the content of response messages, and much more.
Q: How do you override the document style?
A: There is a User Style Sheet property that can be useful exactly for this purpose.
Q: My document does not parse correctly; I see black squares instead of letters! How can I fix it?
A: We parse document headers to detect the character set (encoding) of the document. If the encoding is not defined we use UTF-8, which is defined as the default for HTML5 specifications. If you know that encoding is different from the default UTF-8, please specify it directly, as described in the article Environment Configuration.
Q: I want to see page numbers at the bottom of the document, how to do this?
A: Since CSS is used to describe the visual layout of the document, we designed specialized CSS Extensions that can be used to write information on page margins.