예제 #1
0
 private static void LoadCatalog()
 {
     // load epub
     foreach (var lang in Directory.GetDirectories("epubs"))
     {
         if (lang.StartsWith("."))
         {
             continue;
         }
         Console.WriteLine(" - Load EPubs from language " + lang);
         var locale = Path.GetFileName(lang);
         // put all books in the first categorie of the suitable language
         foreach (var file in Directory.GetFiles(lang, "*.epub"))
         {
             string   coverPath = Path.Combine(lang, Path.GetFileNameWithoutExtension(file) + ".jpg");
             byte[]   content   = File.ReadAllBytes(file);
             EpubBook book      = EBookFactory.Create(content);
             book.CoverImage       = File.Exists(coverPath) ? File.ReadAllBytes(coverPath) : null;
             book.CoverDescription = String.Format("{0} of {1} published at {2}",
                                                   book.PackageData.MetaData.Title,
                                                   book.PackageData.MetaData.Creator,
                                                   book.PackageData.MetaData.Publisher);
             Console.WriteLine(" - EPub done " + file);
             // the published book simulates a book as it were written be an author, based on the uploaded EPUB
             Published p = new Published();
             SpineParser(book, p);
             WriteFragments(p, Path.GetFileNameWithoutExtension(file) + ".txt");
         } // epubs
     }     // epub
     Console.WriteLine(" - Done");
 }
예제 #2
0
        public ActionResult DownloadEpub(int id)
        {
            EpubBook book = ProductionManager.Instance.GenerateEpubMedia(id);

            byte[]       epub = EBookFactory.SaveBook(book);
            MemoryStream ms   = new MemoryStream(epub);

            return(File(ms.ToArray(), "application/epub+zip", book.PackageData.MetaData.Title.Text + ".epub"));
        }