Convert EPUB to TIFF | C#

With Aspose.HTML, you can convert EPUB to TIFF format programmatically with full control over a wide range of conversion parameters. In this article, you find information on how to convert EPUB to TIFF using ConvertEPUB() methods of the Converter class, and how to apply ImageSaveOptions and ICreateStreamProvider parameters.

Online EPUB Converter

You can check the Aspose.HTML API functionality and convert EPUB in real-time. Please load an EPUB file from the local file system, select the output format and run the example. In the example, the save options are set by default. You will immediately receive the result as a separate file.

                
            

If you want to convert EPUB to TIFF programmatically, please see the following C# code examples.

Convert EPUB to TIFF

Using Converter.ConvertEPUB() methods is the most common way to convert EPUB files into various formats. To convert EPUB to TIFF, you should follow a few steps:

  1. Open an existing EPUB file. In the example, we use the OpenRead() method of System.IO.FileStream class to open and read an EPUB file from the file system at the specified path.
  2. Create a new ImageSaveOptions object with TIFF ImageFormat. By default, the Format property is PNG.
  3. Use the ConvertEPUB() method of the Converter class to save EPUB as a TIFF image. You need to pass the EPUB file stream, ImageSaveOptions, and output file path to the ConvertEPUB() method for EPUB to TIFF conversion.

Please take a look over the following C# code snippet which shows the process of converting EPUB to TIFF using Aspose.HTML for .NET.

 1using System.IO;
 2using Aspose.Html;
 3using Aspose.Html.Converters;
 4using Aspose.Html.Rendering.Image;
 5using Aspose.Html.Saving;
 6...
 7   // Open an existing EPUB file for reading
 8   using var stream = File.OpenRead(DataDir + "input.epub");
 9
10   // Prepare a path for converted file saving 
11   string savePath = Path.Combine(OutputDir, "input-output.tiff");
12
13   // Initialize ImageSaveOptions 
14   var options = new ImageSaveOptions(ImageFormat.Tiff);
15
16   // Call the ConvertEPUB() method to convert EPUB to TIFF
17   Converter.ConvertEPUB(stream, options, savePath);

You can download the complete examples and data files from GitHub.

Save Options

Aspose.HTML allows converting EPUB to TIFF using default or custom save options. ImageSaveOptions usage enables you to tune the rendering process. You can specify the page size, margins, CSS, compression, etc.

PropertyDescription
CompressionSets Tagged Image File Format (TIFF) Compression. By default, this property is LZW.
CSSGets a CssOptions object which is used for configuration of CSS properties processing.
FormatSets the ImageFormat (JPG, PNG, BMP, TIFF, or GIF). By default, this property is PNG.
BackgroundColorThis property sets the color that will fill the background. By default, this property is Transparent.
PageSetupThis property gets a page setup object and uses it for configuration output page-set.
HorizontalResolutionSets horizontal resolution for output images in pixels per inch. The default value is 300 dpi.
VerticalResolutionSets vertical resolution for output images in pixels per inch. The default value is 300 dpi.
SmoothingModeThis property sets the rendering quality for this image. Available values are Invalid, Default, HighSpeed, HighQuality, None, and AntiAlias.
TextGets a TextOptions object which is used for configuration of text rendering.

To learn more about the ImageSaveOptions class, please read the Fine-Tuning Converters article.

Convert EPUB to TIFF using ImageSaveOptions

To convert EPUB to TIFF with ImageSaveOptions specifying, you should follow a few steps:

  1. Open an existing EPUB file.
  2. Create a new ImageSaveOptions object and specify save options.
  3. Use the ConvertEPUB() method of the Converter class to save EPUB as a TIFF image. You need to pass the EPUB file stream, ImageSaveOptions, and output file path to the ConvertEPUB() method to convert EPUB to TIFF.

The following C# code snippet shows how to convert EPUB to TIFF using custom save options:

 1using System.IO;
 2using Aspose.Html;
 3using Aspose.Html.Converters;
 4using Aspose.Html.Rendering.Image;
 5using Aspose.Html.Saving;
 6using System.Drawing;
 7using Aspose.Html.Drawing;
 8using System.Drawing.Drawing2D;
 9...
10    // Open an existing EPUB file for reading
11    using var stream = File.OpenRead(DataDir + "input.epub");
12
13    // Prepare a path for converted file saving 
14    string savePath = Path.Combine(OutputDir, "input-options.tiff");
15
16    // Initialize ImageSaveOptions
17    var options = new ImageSaveOptions(ImageFormat.Tiff)
18    {
19        Compression = Compression.None,
20        SmoothingMode = SmoothingMode.HighQuality,
21        HorizontalResolution = 400,
22        VerticalResolution = 400,
23        BackgroundColor = System.Drawing.Color.AliceBlue
24    };
25    options.PageSetup.AnyPage = new Page(new Aspose.Html.Drawing.Size(800, 500), new Margin(30, 20, 10, 10));
26
27    // Call the ConvertEPUB() method to convert EPUB to TIFF
28    Converter.ConvertEPUB(stream, options, savePath);

The ImageSaveOptions() constructor initializes an instance of the ImageSaveOptions class that is passed to ConvertEPUB() method. The ConvertEPUB() method takes the stream, options, output file path savePath and performs the conversion operation.

In the example, we use:

You can download the complete examples and data files from GitHub.

Aspose.HTML offers a free online EPUB to TIFF Converter that converts EPUB to TIFF image with high quality, easy and fast. Just upload, convert your files and get results in a few seconds!

Text “Banner EPUB to TIFF Converter”

Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.