HTML files are commonly used to display text, images, drawings, etc. over the web. In certain situations, you might need to convert HTML files to PDF files. This article covers how to convert an HTML file to a PDF document on Linux in Java.
Java API to Convert HTML to PDF on Linux
Aspose.HTML for Java API supports creating, editing, or manipulating HTML files and several other file formats. You can configure the API by downloading its JAR file from the New Releases section or from the Maven repository with the below specifications.
<repositories> <repository> <id>snapshots</id> <name>repo</name> <url>http://repository.aspose.com/repo/</url> </repository> </repositories>
<dependencies> <dependency> <groupId>com.aspose</groupId> <artifactId>aspose-html</artifactId> <version>21.6</version> <classifier>jdk16</classifier> </dependency> </dependencies>
Convert HTML to PDF in Java on Linux
You can convert an HTML file to a PDF file on Linux using Java by following the steps below:
- Instantiate an HTMLDocument class instance.
- Initialize an instance of the PdfSaveOptions class.
- Convert HTML to PDF with the convertHTML method.
The following code demonstrates how to convert HTML to PDF file on Linux programmatically in Java:
Get Free Temporary License
For testing the Aspose.HTML for Java API in full capacity without any evaluation limitations, please request a free temporary license.
In this article, you have explored how to convert an HTML to a PDF document on Linux in Java. You can learn several other features by visiting the documentation and API references. Furthermore, please feel free to get in touch with us at the free support forum in case of any queries.