Convert EPUB to a PNG or JPG Image in Java

EPUB to JPG PNG Java

EPUB file format is popular for printing e-books, brochures, pamphlets, etc. Sometimes you may need to convert an EPUB file to an image for displaying file contents. Therefore, this article guides you on how to convert an EPUB file to a JPG or PNG image programmatically in Java.

EPUB to Image Conversion – Java API Installation

Aspose.HTML for Java can be used to create, edit, and manipulate HTML, MHTML, XPS, EPUB and many other file formats. You can download its JAR files from the New Releases page or paste the following configurations in pom.xml file of your project:

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.12</version>
        <classifier>jdk16</classifier>
    </dependency>
</dependencies>

Convert EPUB to JPG Image in Java

You can convert an EPUB file to a JPG image by following the steps below:

  1. Create an object of the ImageSaveOptions class.
  2. Set the page size and the output image format.
  3. Save the output JPG image with the ConvertEPUB method.

The following code sample elaborates on how to convert an EPUB file to a JPG image in Java:

Convert EPUB to PNG Image Programmatically in Java

You need to follow the steps below in order to convert an EPUB file to a PNG image:

  1. Create an instance of the ImageSaveOptions class.
  2. Set the output image format as PNG.
  3. Convert the EPUB to a PNG image with the ConvertEPUB method.

The following code sample explains how to convert an EPUB file to a PNG image in Java:

Explore Aspose.HTML for Java API

You may take a look at different chapters in the documentation to learn other features included in the API.

Get a Free License

You may request a free temporary license in order to evaluate the API features without any limitations.

Conclusion

In this article, you have explored how to convert an EPUB file to a JPG or PNG image in Java. Moreover, please feel free to reach out to us at the forum in case of any queries.

See Also

Convert HTML to MHT in Java