I am using EpubReader.Cross NuGet Package for reading epub files. For this, I have added a sample .epub book file to my main project and set the Build Action to EmbedResource. As per the document I try to parse the title, author, and coverImage details like below. But details are not correct, please have a look at the below code.
My Code
string fileName = "content.epub";
var assembly = typeof(MainPage).GetTypeInfo().Assembly;
Stream stream = assembly.GetManifestResourceStream($"{assembly.GetName().Name}.{fileName}");
EpubBook epubBook = EpubReader.ReadBook(stream);
// Book's title
string title = epubBook.Title;
Debug.WriteLine("title:>>"+title);
// Book's authors (comma separated list)
string author = epubBook.Author;
Debug.WriteLine("author:>>" + author);
// Book's authors (list of authors names)
List<string> authors = epubBook.AuthorList;
Debug.WriteLine("authors:>>" + authors.Count);
// Book's cover image (null if there is no cover)
byte[] coverImage = epubBook.CoverImage;
Debug.WriteLine("coverImage:>>" + coverImage);
Output
[0:] title:>>be023aa39d417e1493850a0b9de6220c
[0:] author:>>Unknown
[0:] authors:>>1
[0:] coverImage:>>
I think the issue is with reading the .epub file added on the project. My .epub file generated by converting a .opf file, is that cause the issue?
In your case , the issue wasn't caused by your code or the plugin . An EPUB file is a digital ebook saved in the EPUB format, an open XML-based format for digital books and publications.
Some ePUB file doesn't contain the complete information when been created . You could firstly check it in your computer
In Windows , it can been opened by Adobe Digital Editions or Microsoft Edge .
In MacOS , it can been opened by Apple Pages or Apple Books .