Project Description
Generates ePub packages (i.e. eBooks).


Enables the generation of ePub packages in both .NET 4.5 & Windows Store App. API is fully async and relies only on System.IO.Compression.ZipArchive (i.e. no other NuGet packages).

You can find the NuGet package here: https://www.nuget.org/packages/EPubFactory/.

Code sample:

        private static async Task TestEPub()
        {
            var ePubStream = File.Create("Test.epub");

            using (var writer = await EPubWriter.CreateWriterAsync(
                ePubStream,
                "My Title",
                "Me, The Author",
                "My Unique Identifier"))
            {
                //  Optional parameter
                writer.Publisher = "Demo App";

                //  Add a chapter with string content as x-html
                await writer.AddChapterAsync(
                    "FirstChapter.xhtml",
                    "First Chapter Title",
                    File.ReadAllText("FirstChapter.xhtml"));

                //  Streaming mode
                var chapterStream = writer.GetChapterStream(
                    "SecondChapter.xhtml",
                    "Second Chapter - Streaming");

                //  Fill the chapter-stream
                //  await chapterStream.WriteAsync(...)

                //  Add an image from the disk
                await writer.AddResourceAsync("MyLogo.png", "image/png", File.ReadAllBytes("MyLogo.png"));

                //  Streaming mode for images
                var imageStream = writer.GetResourceStream("MyBackground.jpg", "image/jpeg");

                //  Fill the image-stream
                //  await imageStream.WriteAsync(...)

                //  Must be called async at the end to write down the TOC of the ePub
                await writer.WriteEndOfPackageAsync();
            }
        }

Last edited Nov 7, 2013 at 1:30 AM by vincent_lauzon, version 4