private void AssertOcf(OcfDocument expected, OcfDocument actual) { // There are some epubs with multiple root files. // i.e. 1 normal and 1 for braille. // We don't have multiple root file support, therefore Take(1) for now. // Currently it is also assumed that the first root file is the main root file. // This is a dangerous assumption. AssertCollection(expected.RootFiles.Take(1), actual.RootFiles, (a, b) => { Assert.Equal(a.FullPath, b.FullPath); Assert.Equal(a.MediaType, b.MediaType); }); Assert.Equal(expected.RootFilePath, actual.RootFilePath); }
public static OcfDocument Read(XDocument xml) { if (xml == null) { throw new ArgumentNullException(nameof(xml)); } if (xml.Root == null) { throw new ArgumentException("XML document has no root element.", nameof(xml)); } var rootFiles = xml.Root?.Element(OcfElements.RootFiles)?.Elements(OcfElements.RootFile); var ocf = new OcfDocument { RootFiles = rootFiles.AsObjectList(elem => new OcfRootFile { FullPath = (string)elem.Attribute(OcfRootFile.Attributes.FullPath), MediaType = (string)elem.Attribute(OcfRootFile.Attributes.MediaType) }) }; return(ocf); }
/* * @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ * @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ * @@@@ Method @@@@ * @@@@****************************Read Epub ******************************************************@@@@ * @@@@ @@@@ * @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ * @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ */ //------------method geeting smil fil ----------- public void ProcessEpub(string currentFile) { try { string EpubNummerOnly = Path.GetFileNameWithoutExtension(currentFile); // Read an epub file EpubBook book = EpubReader.Read(currentFile); // Read metadata string title = book.Title; FinalReportlist.Add("Title of book = " + title); //******Author****** var authors = book.Authors; int Authors_count = 0; string Authors_Metadata = ""; foreach (var eachData in authors) { Authors_count++; Authors_Metadata = Authors_Metadata + " (" + eachData + "), "; } FinalReportlist.Add("Author of book= (" + Authors_count + ")" + Authors_Metadata); //******images*********** ICollection <EpubByteFile> images = book.Resources.Images; FinalReportlist.Add("Images in book= (" + images.Count + ")"); //******other metadata*********** // Access internal EPUB format specific data structures. EpubFormat format = book.Format; OcfDocument ocf = format.Ocf; OpfDocument opf = format.Opf; NcxDocument ncx = format.Ncx; NavDocument nav = format.Nav; var bookVersion = format.Opf.EpubVersion; var bookIsbnID = format.Opf.Metadata.Identifiers; var allMetadata = opf.Metadata.Languages; string language_Metadata = ""; foreach (var eachData in allMetadata) { language_Metadata = language_Metadata + eachData + ", "; } FinalReportlist.Add("Language of of book= (" + allMetadata.Count + ")" + language_Metadata); FinalReportlist.Add("version of book= " + bookVersion); // Get table of contents FinalReportlist.Add("\n*****Table of Content*****"); ICollection <EpubChapter> chapters = book.TableOfContents; foreach (var eachH1chapter in chapters) { FinalReportlist.Add(eachH1chapter.Title); //*******writing h2 Chapter**** if (eachH1chapter.SubChapters.Count >= 1) { var h2chapter = eachH1chapter.SubChapters; foreach (var eachH2chapter in h2chapter) { FinalReportlist.Add("\t" + eachH2chapter.Title); //*******writing h3 Chapter**** if (eachH2chapter.SubChapters.Count >= 1) { var h3chapter = eachH2chapter.SubChapters; foreach (var eachH3chapter in h3chapter) { FinalReportlist.Add("\t\t" + eachH3chapter.Title); } } } } } }// try end catch (Exception e) { string error = "\n Error in syncStart " + Program.Current_bookPath; Console.WriteLine(error + e); Program.Global_error = Program.Global_error + error; } // catch end } //syncStart end