示例#1
0
        /// <summary>
        /// Entry point for epub 3 converter
        /// </summary>
        /// <param name="projInfo">values passed including epub2 exported files and changed to epub3 support</param>
        /// <returns>true if succeeds</returns>
        public bool Export(PublicationInformation projInfo)
        {
            bool epub3Export = false;
            string oebpsPath = Common.PathCombine(Epub3Directory, "OEBPS");
            string cssFile = Common.PathCombine(oebpsPath, "book.css");

            var preProcessor = new PreExportProcess();
            preProcessor.ReplaceStringInFile(cssFile, "{direction:ltr}", "{direction:ltr;}");
            preProcessor.ReplaceStringInFile(cssFile, "direction:", "dir:");
            //preProcessor.RemoveStringInCss(cssFile, "direction:");


            var xhmltohtml5Space = Loadxhmltohtml5Xslt(projInfo.ProjectInputType.ToLower());

            Convertxhtmltohtml5(oebpsPath, xhmltohtml5Space);

            ModifyContainerXML();

            ModifyContentOPF(projInfo, oebpsPath);

            ModifyTocContent(oebpsPath);

            ModifyCoverpage(oebpsPath);

            epub3Export = true;

            return epub3Export;
        }
示例#2
0
        private static void ModifyTocContent(string oebpsPath)
        {
            var epub3Toc = LoadEpub3Toc();

            string ncxTempFile = Common.PathCombine(oebpsPath, "toctemp.ncx");
            string ncxfile = Common.PathCombine(oebpsPath, "toc.ncx");
            File.Copy(ncxfile, ncxTempFile, true);
            string epub3TocFile = Common.PathCombine(oebpsPath, "toc.xhtml");
            if (File.Exists(ncxfile))
            {
                Common.ApplyXslt(ncxfile, epub3Toc);
                File.Copy(ncxfile, epub3TocFile, true);
                if (File.Exists(ncxTempFile))
                {
                    File.Copy(ncxTempFile, ncxfile, true);
                    var preProcessor = new PreExportProcess();
                    preProcessor.ReplaceStringInFile(ncxfile, ".xhtml", ".html");
                    File.Delete(ncxTempFile);
                }
            }
        }