Related Article(s):
Last active
October 27, 2023 06:40
-
-
Save GroupDocsGists/f042bfdab47ce0f808c5fed74cbc3d44 to your computer and use it in GitHub Desktop.
Manage EPUB Metadata using C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Read Dublin Core metadata using C# | |
using (Metadata metadata = new Metadata("path/ebook.epub")) | |
{ | |
var root = metadata.GetRootPackage<EpubRootPackage>(); | |
Console.WriteLine(root.DublinCorePackage.Rights); | |
Console.WriteLine(root.DublinCorePackage.Publisher); | |
Console.WriteLine(root.DublinCorePackage.Title); | |
Console.WriteLine(root.DublinCorePackage.Creator); | |
Console.WriteLine(root.DublinCorePackage.Language); | |
Console.WriteLine(root.DublinCorePackage.Date); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Read EPUB metadata using C# | |
using (Metadata metadata = new Metadata("path/ebook.epub")) | |
{ | |
var root = metadata.GetRootPackage<EpubRootPackage>(); | |
Console.WriteLine(root.EpubPackage.Version); | |
Console.WriteLine(root.EpubPackage.UniqueIdentifier); | |
Console.WriteLine(root.EpubPackage.ImageCover != null ? root.EpubPackage.ImageCover.Length : 0); | |
Console.WriteLine(root.EpubPackage.Description); | |
Console.WriteLine(root.EpubPackage.Title); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Update Dublin Core metadata using C# | |
using (Metadata metadata = new Metadata("path/ebook.epub")) | |
{ | |
var root = metadata.GetRootPackage<EpubRootPackage>(); | |
root.DublinCorePackage.SetProperties(p => p.Name == "dc:creator", new PropertyValue("GroupDocs")); | |
root.DublinCorePackage.SetProperties(p => p.Name == "dc:description", new PropertyValue("metadata updated e-book")); | |
root.DublinCorePackage.SetProperties(p => p.Name == "dc:title", new PropertyValue("Sample EPUB")); | |
root.DublinCorePackage.SetProperties(p => p.Name == "dc:date", new PropertyValue(DateTime.Now.ToString())); | |
metadata.Save("path/ebook.epub"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Update EPUB metadata using C# | |
using (Metadata metadata = new Metadata("path/ebook.epub")) | |
{ | |
var root = metadata.GetRootPackage<EpubRootPackage>(); | |
root.EpubPackage.Creator = "GroupDocs"; | |
root.EpubPackage.Description = "metadata updated e-book"; | |
root.EpubPackage.Format = "EPUB"; | |
root.EpubPackage.Date = DateTime.Now.ToString(); | |
metadata.Save("path/ebook.epub"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment