|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CBR.Core.Models;
using System.IO;
namespace CBR.Core.Helpers
{
public class ePUBHelper
{
public class Files
{
public const string Mime = "mimetype";
public const string Container = "META-INF\\container.xml";
public const string PublicationFolder = "OEBPS";
public const string Package = "content.opf";
public const string NcxToc = "toc.ncx";
}
public class XmlMediaTypes
{
public const string Mime = "application/epub+zip";
public const string Container = "application/oebps-package+xml";
public const string Content = "application/xhtml+xml";
public const string Css = "text/css";
public const string NcxToc = "application/x-dtbncx+xml";
public const string Images = "images/";
}
public class XmlNamespaces
{
public const string Container = "urn:oasis:names:tc:opendocument:xmlns:container";
public const string MetaDC = "http://purl.org/dc/elements/1.1/";
public const string MetaOPF = "http://www.idpf.org/2007/opf";
public const string NcxToc = "http://www.daisy.org/z3986/2005/ncx/";
public const string Opf = "http://www.idpf.org/2007/opf";
}
public class XmlAttributes
{
public const string container_identifier = "full-path";
public const string meta_identifier = "identifier";
public const string meta_title = "title";
public const string meta_language = "language";
public const string meta_creator = "creator";
public const string meta_contributor = "contributor";
public const string meta_publisher = "publisher";
public const string meta_subject = "subject";
public const string meta_description = "description";
public const string meta_date = "date";
public const string meta_type = "type";
public const string meta_format = "format";
public const string meta_source = "source";
public const string meta_relation = "relation";
public const string meta_coverage = "coverage";
public const string meta_rights = "rights";
}
static public string GetTOCFile( ePUB doc )
{
string result = string.Empty;
if (!string.IsNullOrEmpty(doc.RootFolder))
result = Path.Combine(doc.RootFolder, doc.OpenPackage.PublicationFolder);
else
result = doc.OpenPackage.PublicationFolder;
result = Path.Combine(result, doc.OpenPackage.ManifestItems.Where(p => p.MediaType == "application/x-dtbncx+xml").First().Reference);
return result;
}
static public string GetCoverFile(ePUB doc)
{
string result = string.Empty;
if (!string.IsNullOrEmpty(doc.RootFolder))
result = Path.Combine(doc.RootFolder, doc.OpenPackage.PublicationFolder);
else
result = doc.OpenPackage.PublicationFolder;
result = Path.Combine(result, doc.OpenPackage.ManifestItems.Where(p => p.Id == doc.OpenPackage.CoverId).First().Reference);
return result;
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
WPF and MVVM fan, I practice C # in all its forms from the beginning of the NET Framework without mentioning C ++ / MFC and other software packages such as databases, ASP, WCF, Web & Windows services, Application, and now Core and UWP.
In my wasted hours, I am guilty of having fathered C.B.R. and its cousins C.B.R. for WinRT and UWP on the Windows store.
But apart from that, I am a great handyman ... the house, a rocket stove to heat the jacuzzi and the last one: a wood oven for pizza, bread, and everything that goes inside
https://guillaumewaser.wordpress.com/
https://fouretcompagnie.wordpress.com/