public bool Clean(Epub epub) { var changes = false; foreach (var item in epub.Opf.GetPageItems()) { changes |= Clean(item); } return(changes); }
public void PopulateControls(Epub epub, EpubItem itemToInsertBefore, int chapterNum) { this.epub = epub; this.itemToInsertBefore = itemToInsertBefore; int idVal = epub.Opf.GetPageItems().GetMaxPrefix() + 1; string idNum = idVal.ToString("D4"); textBoxId.Text = "xhtml" + idNum; textBoxTitle.Text = $"Chapter {chapterNum}"; textBoxPath.Text = $"OEBPS/Text/{idNum}_Chapter{chapterNum}.xhtml"; changeEpubAction = InsertChapter; }
public static void ConvertWebpImagesToJpeg(this Epub epub) { var imageItems = epub.Opf.GetImageItems().Where(EpubUtils.IsWebp); var newPaths = new Dictionary <string, string>(); foreach (var item in imageItems.Where(IsWebp)) { var old = item.AbsolutePath; item.ConvertToJpeg(); newPaths.Add(old, item.AbsolutePath); } foreach (var item in epub.Opf.GetPageItems()) { item.RawBytes = item.UpdateXhtmlPage(newPaths); } MessageBox.Show("Done"); }
public void PopulateControlsForUpdate(Epub epub, EpubItem toUpdate) { this.toUpdate = toUpdate; var entryDetails = epub.ToC.FindTocEntry(toUpdate.AbsolutePath); tocEntry = entryDetails.entries[entryDetails.index]; textBoxId.Enabled = false; textBoxId.Text = toUpdate.Id; textBoxTitle.Text = tocEntry.Title; textBoxSource.Text = tocEntry.ContentSrc; textBoxSource.Enabled = false; textBoxPath.Text = toUpdate.AbsolutePath; textBoxPath.Enabled = false; textBox1.Text = toUpdate.RawBytes.ToXhtml().ToString(); changeEpubAction = UpdateChapter; this.Text = "Update Chapter"; button2.Text = "Update"; }
private Epub LoadEpub(string fileName) { var epub = new Epub(); epub.ReadFile(fileName); var errors = epub.Validate(); if (0 < errors.Count) { var sb = new StringBuilder(); sb.AppendLine($"Epub file '{fileName}' has the following errors:"); foreach (var error in errors) { sb.AppendLine(error); } System.Diagnostics.Trace.WriteLine(sb.ToString()); MessageBox.Show(sb.ToString()); } return(epub); }
public static void CombineTwoEpubs() { var epub1 = new Epub(); var epub2 = new Epub(); try { epub1.ReadFile(@"E:\temp\work\zip\unpack\ccg\Cultivation Chat Group.c1313-1325.epub"); epub2.ReadFile(@"E:\temp\work\zip\unpack\ccg\Cultivation Chat Group.c1326-c1331.epub"); var combiner = new EpubCombiner(epub1); combiner.Add(epub2); epub1.WriteFile(@"E:\temp\work\zip\unpack\ccg\Cultivation Chat Group.c1313-c1331.epub"); } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex.ToString()); MessageBox.Show(ex.ToString()); } }
public void Add(Epub toAppend) { this.ToAppend = toAppend; Combine(); }
public EpubCombiner(Epub initial) { InitialEpub = initial; }