Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
EPUB is the most widely supported e-book format. An EPUB file is a ZIP archive that actually contains a website, including HTML files, images, CSS style sheets, and other assets. Converting EPUB to JPG can be helpful when you want to include an EPUB file in a PowerPoint presentation or send it by email. Or, for example, you want to share an EPUB file with someone who doesn’t have an EPUB reader installed.
Aspose.HTML for Java library provides a wide range of EPUB conversions to image formats, such as JPG, PNG, BMP, TIFF, and GIF.
Converting EPUB to any supported image format follows the mandatory steps:
The only difference is in specifying the output image format using the
ImageSaveOptions class. The ImageSaveOptions(format) constructor initializes the options object with the image format specifying. You can set the format to JPG, PNG, BMP, GIF, or TIFF. The default ImageFormat is PNG.
In this article, you will find information on how to convert an EPUB to JPG using Aspose.HTML for Java and how to apply
ImageSaveOptions. You can easily use Java examples to convert EPUB to JPG, which are detailed here, for converting
EPUB to PNG, EPUB to BMP, EPUB to GIF, and EPUB to TIFF. Just set the ImageFormat to ImageSaveOptions!
The static methods of the Converter class are primarily used as the easiest way to convert an EPUB file into various formats. You can convert EPUB to JPG in your Java application literally with a few lines of code!
1// Convert EPUB to JPG using Java
2
3// Open an existing EPUB file for reading
4java.io.FileInputStream fileInputStream = new java.io.FileInputStream("input.epub");
5
6// Invoke the convertEPUB() method to convert EPUB to JPG
7Converter.convertEPUB(fileInputStream, new ImageSaveOptions(ImageFormat.Jpeg), "convert-in-two-lines.jpg");Let’s walk through the step-by-step instructions for a simple EPUB to JPG conversion scenario:
FileInputStream to read the contents of the EPUB file as a stream of bytes.ImageFormat.Png will be used as default image format.convertEPUB(stream, options, savePath) method of the
Converter class to save EPUB as an JPG image. The method takes as parameters stream, options, and savePath and performs the conversion.Using convertEPUB() methods is the most common way to convert EPUB files into various formats. The following Java code snippet shows how to convert EPUB to JPG:
1// Convert EPUB to JPEG using Aspose.HTML for Java
2
3// Open an existing EPUB file for reading
4java.io.FileInputStream fileInputStream = new java.io.FileInputStream("input.epub");
5
6// Create an instance of the ImageSaveOptions class
7ImageSaveOptions options = new ImageSaveOptions(ImageFormat.Jpeg);
8
9// Call the сonvertEPUB() method to convert EPUB to JPG
10Converter.convertEPUB(fileInputStream, options, "input-output.jpg");You can download the complete examples and data files from GitHub.
Aspose.HTML for Java provides the ability to programmatically convert EPUB to JPG with full control over various conversion options using ImageSaveOptions. This feature allows users to customize the rendering process by setting the image format, page size, margins, compression level, media type, and other parameters.
| Method | Description |
|---|---|
| setCompression(value) | Sets the Tagged Image File Format (TIFF) Compression. By default this property is Compression.LZW. |
| getCss | Gets a CssOptions object which is used for configuration of CSS properties processing. |
| setFormat(value) | Sets ImageFormat (JPG, PNG, BMP, TIFF, or GIF). By default this property is ImageFormat.Png. |
| setBackgroundColor(value) | Sets Color which will fill background of every page. Default value is Color.Transparent(Color.getTransparent()). |
| setPageSetup(value) | Gets a page setup object is used for configuration output page-set. |
| setHorizontalResolution(value) | Sets horizontal resolution for output images in pixels per inch. The default value is 300 dpi. |
| setVerticalResolution(value) | Sets vertical resolution for output images in pixels per inch. The default value is 300 dpi. |
| setSmoothingMode(value) | Sets the rendering quality for this image. |
| getText() | Gets a TextOptions object which is used for configuration of text rendering. |
For further information on how to customize the conversion process with ImageSaveOptions you can refer to the Fine-Tuning Converters article.
Aspose.HTML for Java allows converting EPUB to JPG using default or custom save options. The following Java example shows how to use ImageSaveOptions and create a JPG file with custom page-size, margins, resolution, rendering quality, and background color:
FileInputStream to read the contents of the EPUB file as a stream of bytes.setSmoothingMode() method to set the quality of the image smoothing to high.setHorizontalResolution() and setVerticalResolution() methods to set the horizontal and vertical resolution of the image to 400.getBackgroundColor() method to set the background color of the image to AliceBlue.setAnyPage() method to set the size of the image and margins.convertEPUB(stream, options, savePath) method to save EPUB file as a JPG image. The method takes the stream, options, output file path savePath and performs the conversion operation. 1// Convert EPUB to JPG in Java with custom settings
2
3// Open an existing EPUB file for reading
4java.io.FileInputStream fileInputStream = new java.io.FileInputStream("input.epub");
5
6// Initialize ImageSaveOptions
7ImageSaveOptions options = new ImageSaveOptions(ImageFormat.Jpeg);
8options.setSmoothingMode(SmoothingMode.HighQuality);
9options.setHorizontalResolution(Resolution.to_Resolution(400));
10options.setVerticalResolution(Resolution.to_Resolution(400));
11options.setBackgroundColor(Color.getAliceBlue());
12options.getPageSetup().setAnyPage(new Page(new Size(800, 500), new Margin(30, 20, 10, 10)));
13
14// Convert EPUB to JPG
15Converter.convertEPUB(fileInputStream, options, "input-options.jpg");Aspose.HTML for Java allows users to easily convert eBooks into commonly used image JPG format. Using the ImageSaveOptions class, you can customize the output, from resolution to the background color and page layout, ensuring that the resulting images meet your specific requirements. The provided Java examples demonstrate basic and advanced conversion functionality usage, empowering developers to implement various scenarios and use cases.
Aspose.HTML offers a free online EPUB to JPG Converter that converts EPUB to JPG with high quality, easy and fast. Just upload, convert your files and get the result in a few seconds!
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.