Exemple #1
0
        public void AddResource(string path, string filename, Stream stream)
        {
            string entryName = EpubHelper.CombinePath(path, filename);

            if (!file.ContainsEntry(entryName))
            {
                file.AddEntry(EpubHelper.CombinePath(path, filename), stream);
            }
        }
Exemple #2
0
        public void AddImage(string filename, byte[] bytes)
        {
            string entryName = EpubHelper.CombinePath(Structure.Directories.ImageFolderFullPath, filename);

            if (!file.ContainsEntry(entryName))
            {
                file.AddEntry(EpubHelper.CombinePath(Structure.Directories.ImageFolderFullPath, filename), bytes);
            }
        }
Exemple #3
0
        public void AddCss(string filename, Stream stream)
        {
            string entryName = EpubHelper.CombinePath(Structure.Directories.CssFolderFullPath, filename);

            if (!file.ContainsEntry(entryName))
            {
                file.AddEntry(EpubHelper.CombinePath(Structure.Directories.CssFolderFullPath, filename), stream);
            }
        }
Exemple #4
0
        public void AddContent(string filename, string content)
        {
            string entryName = EpubHelper.CombinePath(Structure.Directories.ContentFolder, filename);

            if (!file.ContainsEntry(entryName))
            {
                file.AddEntry(EpubHelper.CombinePath(Structure.Directories.ContentFolder, filename), content);
            }
        }
Exemple #5
0
        private XmlElement BuildManifestSection()
        {
            XmlElement manifestSection = xmlDocument.CreateXmlElement("manifest");

            //adding ncx file link
            Dictionary <string, string> attributes = new Dictionary <string, string>();

            attributes["id"]         = "ncx";
            attributes["href"]       = structure.Files.NcxFile;
            attributes["media-type"] = Resources.NcxMediaType;
            manifestSection.AppendElement("item", attributes);

            //adding content files links
            attributes["media-type"] = Resources.ContentMediaType;
            foreach (ZipEntry entry in file.GetContentFiles(structure.Directories.ContentFolder))
            {
                string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(entry.FileName);
                contentItems.Add(fileNameWithoutExtension);
                attributes["id"]   = "cnt_" + fileNameWithoutExtension;
                attributes["href"] = EpubHelper.GetRelativePath(structure.Directories.ContentFolder, entry.FileName);
                manifestSection.AppendElement("item", attributes);
            }

            //adding css files links
            attributes["media-type"] = Resources.CssMediaType;
            foreach (ZipEntry entry in file.SelectEntries("*.css", structure.Directories.CssFolderFullPath))
            {
                attributes["id"]   = "style_" + Path.GetFileNameWithoutExtension(entry.FileName);
                attributes["href"] = EpubHelper.GetRelativePath(structure.Directories.ContentFolder, entry.FileName);
                manifestSection.AppendElement("item", attributes);
            }

            //adding images files links
            foreach (ZipEntry entry in file.GetImageFiles(structure.Directories.ImageFolderFullPath))
            {
                attributes["id"]         = "img_" + Path.GetFileNameWithoutExtension(entry.FileName);
                attributes["href"]       = EpubHelper.GetRelativePath(structure.Directories.ContentFolder, entry.FileName);
                attributes["media-type"] = EpubHelper.GetImageMediaType(entry.FileName);
                manifestSection.AppendElement("item", attributes);
            }
            return(manifestSection);
        }