HTML to PDF Java Linux

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.

Repository:

 <repositories>
     <repository>
         <id>snapshots</id>
         <name>repo</name>
         <url>http://repository.aspose.com/repo/</url>
     </repository>
</repositories>

Dependency:

 <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:

  1. Instantiate an HTMLDocument class instance.
  2. Initialize an instance of the PdfSaveOptions class.
  3. 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.

Info: If you have Aspose.Slides for Java, you can also use this API to convert HTML to PDF, convert HTML to PPT, convert HTML to JPG, convert HTML to XML, convert HTML to TIFF. Similarly, you can import HTML from PPT, get it from PDF, etc.

Conclusion

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.

See Also