Convert EPUB to TIFF in C#

To convert EPUB to TIFF in C#, open the EPUB file as a stream, create ImageSaveOptions with ImageFormat.Tiff, configure TIFF-specific options such as Compression when needed, and call Converter.ConvertEPUB() with the stream, options, and output path.

TIFF is a raster image format often used in archiving, printing, scanning, and document imaging workflows. EPUB to TIFF conversion is useful when a C# application needs image output from eBook content and the downstream process expects TIFF files, compression settings, or document-image style storage.

Before running the examples, install and configure Aspose.HTML for .NET in your project. The complete C# example project is available in the Aspose.HTML for .NET GitHub repository.

Convert an EPUB File to TIFF in C#

A typical file-based conversion uses a readable EPUB file stream, an ImageSaveOptions object with ImageFormat.Tiff, and Converter.ConvertEPUB(). The conversion writes a TIFF image to the specified output path.

The workflow is:

  1. Open the EPUB file with File.OpenRead() or another readable stream.
  2. Create an ImageSaveOptions instance and set the output format to ImageFormat.Tiff. The default Format value is PNG, so the format must be set for TIFF output.
  3. Call Converter.ConvertEPUB(stream, options, savePath) to write the TIFF file.

The following C# code converts an EPUB file to TIFF.

 1// Convert EPUB to TIFF using C#
 2
 3// Open an existing EPUB file for reading
 4using FileStream stream = File.OpenRead(DataDir + "input.epub");
 5
 6// Prepare a path to save the converted file
 7string savePath = Path.Combine(OutputDir, "input-output.tiff");
 8
 9// Create an instance of the ImageSaveOptions class 
10ImageSaveOptions options = new ImageSaveOptions(ImageFormat.Tiff);
11
12// Call the ConvertEPUB() method to convert EPUB to TIFF
13Converter.ConvertEPUB(stream, options, savePath);

TIFF Compression and Output Notes

Use TIFF output when the result is intended for document imaging, archival storage, print-oriented workflows, or systems that expect TIFF rather than web image formats. TIFF is also the image format in this group where Compression is directly relevant. For web previews, EPUB to PNG or EPUB to JPG may be easier to handle.

For TIFF output, create ImageSaveOptions(ImageFormat.Tiff) explicitly because the default ImageSaveOptions.Format value is PNG. The Compression option controls TIFF compression; the default value is LZW. You can also tune page setup, background color, resolution, antialiasing, and text rendering in the options object.

Customize EPUB to TIFF with ImageSaveOptions

Use ImageSaveOptions when the output TIFF needs custom rendering settings. The options object is passed to ConvertEPUB() and controls how EPUB content is rendered to raster image output.

OptionUse it to control
CompressionTIFF compression. Available values include LZW, CCITT3, CCITT4, Rle, and None; the default value is LZW.
CssCSS processing behavior through CssOptions.
FormatThe output image format. The default value is PNG; use ImageFormat.Tiff for TIFF output.
BackgroundColorThe color used to fill the image background. The default value is transparent.
PageSetupPage size, margins, and page layout settings.
HorizontalResolution and VerticalResolutionOutput resolution values used by the rendering process. The default value is 300 dpi for each property.
UseAntialiasingImage rendering quality. Antialiasing is enabled by default.
TextText rendering configuration through TextOptions.

The following example creates a TIFF file with custom ImageSaveOptions.

 1// Convert EPUB to TIFF in C# with custom settings
 2
 3// Open an existing EPUB file for reading
 4using FileStream stream = File.OpenRead(DataDir + "input.epub");
 5
 6// Prepare a path to save the converted file
 7string savePath = Path.Combine(OutputDir, "input-options.tiff");
 8
 9// Create an instance of the ImageSaveOptions class 
10ImageSaveOptions options = new ImageSaveOptions(ImageFormat.Tiff)
11{
12    Compression = Compression.None,
13    UseAntialiasing = true,
14    HorizontalResolution = 400,
15    VerticalResolution = 400,
16    BackgroundColor = System.Drawing.Color.AliceBlue
17};
18options.PageSetup.AnyPage = new Page(new Aspose.Html.Drawing.Size(800, 500), new Margin(30, 20, 10, 10));
19
20// Call the ConvertEPUB() method to convert EPUB to TIFF
21Converter.ConvertEPUB(stream, options, savePath);

In this example, ImageSaveOptions is passed to Converter.ConvertEPUB() together with the EPUB stream and output path. The sample configures TIFF compression, background color, page setup, rendering resolution, and antialiasing for the generated TIFF image.

Related Image Workflows

Related EPUB Conversion Guides

Other Platforms

Try Online EPUB to TIFF Conversion

                
            

Use the online EPUB to TIFF Converter for quick manual conversion. Use Aspose.HTML for .NET when EPUB to TIFF conversion must run inside a C# application, service, or document pipeline.

EPUB to TIFF Converter