예제 #1
0
        private void ButExport_Click(object sender, RoutedEventArgs e)
        {
            if (CheckEpub.IsChecked == false && CheckMobi.IsChecked == false)
            {
                return;
            }
            string folderPath = "";
            FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog();

            if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
            {
                folderPath = folderBrowserDialog.SelectedPath;
                ExportInfo exportInfo = new ExportInfo()
                {
                    Title  = TextBoxTitle.Text,
                    Author = TextBoxAuthor.Text,
                    //DatePublish = TextBoxPublishingDate.SelectedDate,
                    SavePath  = folderPath,
                    ImagePath = (ImageName.Tag == null) ? "" : ImageName.Tag.ToString()
                };
                if (CheckEpub.IsChecked == true)
                {
                    parentControl.TextBox.MainControl.SaveAsEpub(exportInfo, project.Files);
                }
                if (CheckMobi.IsChecked == true)
                {
                    parentControl.TextBox.MainControl.SaveAsMobi(exportInfo, project.Files);
                }
            }
        }
예제 #2
0
        //public byte[] ConvertDocumentToPdf(Stream aInputStream)
        //{
        //    byte[] tResult = null;
        //    using (MemoryStream tOutput = new MemoryStream())
        //    {
        //        ConvertDocumentToPdf(aInputStream, tOutput);
        //        tResult = tOutput.ToArray();
        //    }
        //    return tResult;
        //}

        //public void ConvertDocumentToPdf(Stream aInputStream, Stream aOutputStream)
        //{
        //  //  SpireLicense.LicenseProvider.SetLicenseKey(@"sGB6g9jPENUBAIRgo6LnJuyXETnXf19qM7KMKXiy12yslrfh84Ukseil96/AQOrfQyQOjO6iFpO+28+EgRa2bQK5voH908vfGNak2EmkwZolFWRHzujVNaA9Y95ctuKYBm4iVcelMWn8P6hVLxnasVhESC+cMbOh3jeQW3zE/BbVNQrff/HC8RzIJKMsc47TlOirmeYdjn697g65EeQWSrf+kwjm46UfAsdwdok46z9K8fCgGZMpeFnMXz/zt+NlQrkpwar/kCyoVvB+Zw2Fgv4CfvsoxCjaPUZZ01FctmvbxXwiSSdJY9hbj9tTaHfcoo5stjEvaES6AKMANgFeXDde1dKDO3//wJMFHHfrXghdlGVl5Z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HyGOqWAdLA==");
        //    FileFormat tFileFormat = FileFormat.EPub;
        //    Document tDocument = new Document(aInputStream);
        //    tDocument.SaveToStream(aOutputStream, tFileFormat);
        //    tDocument.Close();
        //}
        public void SaveAsMobi(ExportInfo info, List <LoadedFile> files)
        {
            var newPath = info.SavePath;

            info.SavePath = Path.GetTempPath();
            SaveAsEpub(info, files);
            var process = new Process();

            process.StartInfo.UseShellExecute        = false;
            process.StartInfo.RedirectStandardOutput = true;
            process.StartInfo.CreateNoWindow         = true;
            process.StartInfo.FileName  = System.Windows.Forms.Application.StartupPath + "\\" + "kindlegen.exe";
            process.StartInfo.Arguments = Path.Combine(info.SavePath, info.Title + ".epub");
            process.Start();
            process.WaitForExit();
            File.Move(Path.Combine(info.SavePath, info.Title + ".mobi"), Path.Combine(newPath, info.Title + ".mobi"));

            File.Delete(Path.Combine(info.SavePath, info.Title + ".epub"));
        }
예제 #3
0
        public void SaveAsEpub(ExportInfo info, List <LoadedFile> files)
        {
            var document = new Document(InputFormat.XamlPackage);

            foreach (var file in files)
            {
                document.AddFile(file.Path);
            }
            document.Author          = info.Author;
            document.Language        = "en";
            document.Publisher       = "Home entertainment";
            document.PublicationTime = (DateTime.Today);// info.DatePublish;
            document.Rights          = "all";
            document.Title           = info.Title;
            if (info.ImagePath != null && !string.IsNullOrEmpty(info.ImagePath))
            {
                document.PathToCover = info.ImagePath;
            }
            var convertor = new Convertor(document);

            convertor.CreateEpub(Path.Combine(info.SavePath, info.Title + ".epub"));
        }