Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active May 11, 2022 22:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-com-gists/2fff978f63b6bdf4720f62cc37ee3eb4 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/2fff978f63b6bdf4720f62cc37ee3eb4 to your computer and use it in GitHub Desktop.
Convert EPUB to JPG or PNG Image in Java
// Prepare a path to a source EPUB file
String sourcePath = "input.epub";
// Prepare a path to save the converted file
String outputPath = "output.jpg";
// Create an instance of ImageSaveOptions
ImageSaveOptions options = new ImageSaveOptions();
options.setFormat(ImageFormat.Jpeg);
options.setSmoothingMode(SmoothingMode.HighQuality);
options.getPageSetup().setAnyPage(new Page(
new Size(
Length.fromInches(4),
Length.fromInches(5.5))));
// Call the ConvertEPUB method to convert EPUB to JPG Image
Converter.convertEPUB(sourcePath, options, outputPath);
// Prepare a path to a source EPUB file
String sourcePath = "input.epub";
// Prepare a path to save the converted file
String outputPath = "output.png";
// Create an instance of ImageSaveOptions
ImageSaveOptions options = new ImageSaveOptions();
options.setFormat(ImageFormat.Png);
options.getPageSetup().getAnyPage().setSize(new Size(500, 500));
// Call the ConvertEPUB method to convert EPUB to PNG Image
Converter.convertEPUB(sourcePath, options, outputPath);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment