Read epub file in ASP.Net using C#

on Jun 17, 2022 12:02 AM

i want to read epub file in webform

Download FREE API for Word, Excel and PDF in ASP.Net: Download
on Jun 18, 2022 06:47 AM
on Jun 18, 2022 06:48 AM

Hi mukesh1,

Use the library EpubReader for reading EPUB files.

Refer below link for more details.

First you need to install the library from nuget in your project.

Then use the code for reading the file.

Note: Here i am reading the Title, Author and the Cover Image.


<asp:Button Text="Read" runat="server" OnClick="OnRead" />
<hr />
        <th>Cover Photo</th>
            <asp:Label ID="lblTitle" runat="server" /></td>
            <asp:Label ID="lblAuthor" runat="server" /></td>
            <asp:Image ID="imgCover" runat="server" Height="200" Width="200" /></td>


using System.Drawing;
using System.IO;
using VersOne.Epub;


protected void OnRead(object sender, EventArgs e)
    // Opens a book and reads all of its content into memory.
    EpubBook epubBook = EpubReader.ReadBook(Server.MapPath("~/Files/Test.epub"));

    // Book's title.
    string title = epubBook.Title;
    lblTitle.Text = title;

    // Book's authors.
    string author = epubBook.Author;
    lblAuthor.Text = title;

    // Book's cover image.
    byte[] coverImageContent = epubBook.CoverImage;
    if (coverImageContent != null)
        using (MemoryStream coverImageStream = new MemoryStream(coverImageContent))
            System.Drawing.Image coverImage = System.Drawing.Image.FromStream(coverImageStream);
            byte[] bytes = (byte[])(new ImageConverter()).ConvertTo(coverImage, typeof(byte[]));
            imgCover.ImageUrl = string.Format("data:image/jpg;base64,{0}", Convert.ToBase64String(bytes));