Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Configure ImageSaveOptions to embed color profiles in the resulting GIF for accurate color representation.
// Apply a uniform DPI setting in ImageSaveOptions to ensure consistent resolution across all GIF pages.

using System;
using System.IO;

class Program
{
Expand All @@ -12,22 +11,22 @@ static void Main()
string htmlPath = "sample.html";
string outputPath = "output.gif";

if (!File.Exists(htmlPath))
if (!System.IO.File.Exists(htmlPath))
{
File.WriteAllText(htmlPath, "<html><body><h1>Hello, GIF!</h1></body></html>");
System.IO.File.WriteAllText(htmlPath, "<html><body><h1>Hello GIF</h1></body></html>");
}

Aspose.Html.HTMLDocument document = new Aspose.Html.HTMLDocument(htmlPath);

Aspose.Html.Saving.ImageSaveOptions options = new Aspose.Html.Saving.ImageSaveOptions(Aspose.Html.Rendering.Image.ImageFormat.Gif);
// If ImageSaveOptions provides a property to embed color profiles, configure it here.
// Example (uncomment if available):
// options.ColorProfile = true;
options.HorizontalResolution = 300;
options.VerticalResolution = 300;

Aspose.Html.Converters.Converter.ConvertHTML(document, options, outputPath);
}
catch (Exception ex)
{
Console.WriteLine("Error: " + ex.Message);
Console.WriteLine(ex.Message);
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Batch convert a collection of EPUB books to TIFF files using a foreach loop and default conversion settings.

using System;
using System.IO;
using Aspose.Html.Saving;
using Aspose.Html.Rendering.Image;
using Aspose.Html.Converters;

class Program
{
static void Main(string[] args)
{
try
{
// Sample EPUB file paths
string[] epubFiles = new string[] { "book1.epub", "book2.epub" };

// Ensure sample EPUB files exist (empty placeholders)
foreach (string epubPath in epubFiles)
{
if (!File.Exists(epubPath))
{
File.WriteAllBytes(epubPath, new byte[0]);
}
}

// Convert each EPUB to TIFF using default settings
foreach (string epubPath in epubFiles)
{
using (Stream epubStream = File.OpenRead(epubPath))
{
ImageSaveOptions options = new ImageSaveOptions(ImageFormat.Tiff);
string outputPath = Path.ChangeExtension(epubPath, ".tiff");
Aspose.Html.Converters.Converter.ConvertEPUB(epubStream, options, outputPath);
Console.WriteLine($"Converted '{epubPath}' to '{outputPath}'.");
}
}
}
catch (Exception ex)
{
Console.WriteLine("Error: " + ex.Message);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Batch convert all EPUB files in a directory to JPEG images using a loop over Converter.ConvertEPUB.

class Program
{
static void Main()
{
try
{
string inputFolder = "InputEpubs";
string outputFolder = "OutputImages";

System.IO.Directory.CreateDirectory(outputFolder);

foreach (string epubPath in System.IO.Directory.GetFiles(inputFolder, "*.epub"))
{
using (System.IO.Stream stream = System.IO.File.OpenRead(epubPath))
{
Aspose.Html.Saving.ImageSaveOptions options = new Aspose.Html.Saving.ImageSaveOptions(Aspose.Html.Rendering.Image.ImageFormat.Jpeg);
string outputPath = System.IO.Path.Combine(outputFolder, System.IO.Path.GetFileNameWithoutExtension(epubPath) + ".jpg");
Aspose.Html.Converters.Converter.ConvertEPUB(stream, options, outputPath);
}
}

System.Console.WriteLine("Conversion completed.");
}
catch (System.Exception ex)
{
System.Console.WriteLine("Error: " + ex.Message);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Batch process multiple EPUB files to PNG images by programmatically invoking Converter.ConvertEPUB for each entry.

using System;
using System.IO;

class Program
{
static void Main()
{
try
{
string dataDir = "InputEpubs";
string outputDir = "OutputImages";

Directory.CreateDirectory(dataDir);
Directory.CreateDirectory(outputDir);

string[] epubFiles = Directory.GetFiles(dataDir, "*.epub");
if (epubFiles.Length == 0)
{
Console.WriteLine("No EPUB files found in the input directory.");
return;
}

foreach (string epubPath in epubFiles)
{
using (FileStream epubStream = File.OpenRead(epubPath))
{
var options = new Aspose.Html.Saving.ImageSaveOptions();

string baseName = Path.GetFileNameWithoutExtension(epubPath);
string outPath = Path.Combine(outputDir, baseName);
Directory.CreateDirectory(outPath);

Aspose.Html.Converters.Converter.ConvertEPUB(epubStream, options, outPath);
Console.WriteLine($"Converted '{epubPath}' to images in '{outPath}'.");
}
}
}
catch (Exception ex)
{
Console.WriteLine($"Error: {ex.Message}");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Batch transform EPUB documents into GIF animations by iterating over source files and calling Converter.ConvertEPUB.

using System;

class Program
{
static void Main()
{
try
{
string inputDirectory = "InputEpubs";
string outputDirectory = "OutputGifs";

System.IO.Directory.CreateDirectory(inputDirectory);
System.IO.Directory.CreateDirectory(outputDirectory);

string[] epubFiles = System.IO.Directory.GetFiles(inputDirectory, "*.epub");

foreach (string epubPath in epubFiles)
{
string outputPath = System.IO.Path.Combine(
outputDirectory,
System.IO.Path.GetFileNameWithoutExtension(epubPath) + ".gif");

using (System.IO.FileStream epubStream = System.IO.File.OpenRead(epubPath))
{
Aspose.Html.Saving.ImageSaveOptions options = new Aspose.Html.Saving.ImageSaveOptions(
Aspose.Html.Rendering.Image.ImageFormat.Gif);

Aspose.Html.Converters.Converter.ConvertEPUB(epubStream, options, outputPath);
}

Console.WriteLine($"Converted '{epubPath}' to '{outputPath}'.");
}
}
catch (Exception ex)
{
Console.WriteLine("Error: " + ex.Message);
}
}
}

This file was deleted.

This file was deleted.

This file was deleted.

Loading
Loading